#Does SWC use tsconfig.build.json ?

1 messages · Page 1 of 1 (latest)

broken dock
#

I'm in the process of migrating my builder to SWC, thanks to NestJS version 10.
But now that I'm using .swcrc, do we agree I can delete my tsconfig.build.json, which is no longer in use?

I even tested to confirm this with "nest build -b swc --type-check"
If I set "sourceMap": false, in tsconfig.build.json, it doesn't detect it, while in .swcrc, it does.

sweet tundra
#

Yes, swc does not use tsconfig at all, so you can keep the regular one for typechecking by your IDE, but for building, swc uses its own config

broken dock
#

what do you mean by "at all"? because when I modify my tsconfig.json, it does modify the behavior of the build, but not tsconfig.build.json.

oblique raft
#

Nest's CLI takes your tsconfig and reworks it so it works for SWC. It won't do this for building though, only for dev building. So, if you want your build to also use SWC, you'll need to basically set up SWC for your build. The suggested path is to just use TSC for building as usual.

broken dock
#

it's a bit sad to have two different compilers, but I'll do that for now, it seems the best way, thanks for your clarifications!

sweet tundra
broken dock
# sweet tundra Oh, I did not know that nest cli does this, thanks for the clarification. I have...

oh you've been using swc for a long time with nest?
I've had a look at how the swc compiler works here (https://github.com/nestjs/nest-cli/blob/f27273bf063b9936963a31ab3265122580c6e43e/lib/compiler/swc/swc-compiler.ts#L187), and it's not like tsconfig.json and tsconfig.build.json, it's not detected automatically, so I guess I have to specify it in package.json with --config-file .swcrc-build. Is that how you do it?

sweet tundra
oblique raft
#

Yes. The only advantage of building with SWC is for dev'ing, as you can leave type checking up to your IDE and get a much faster feedback loop. When you finally do a build later for any other environment, you should still do a type check, thus why you'd still run the build process through TSC.