NPM script stops working when tsconfig extends @sapphire/ts-config
My npm package has a simple build script:
When extending
@sapphire/ts-config
on my tsconfig.json
, it stops working. Using typescript^5.3.2
and rimraf^5.0.5
.
Strangely enough, running tsc
in the same working directory works as expected...
Full tsconfig.json
:
Solution:Jump to solution
to your prebuild add
tsconfig.tsbuildinfo
, that'll probably fix it. It's the cache file for incremental builds which are enabled by the config.7 Replies
Can you elaborate on what you mean with "stops working"
if you mean that it errors, remove
module": "NodeNext",
from the config. @sapphire/ts-config sets it to node16
which is the current latest.
Also you can remove a lot of your own config as it's already set by the sapphire one. You can find references of what sapphire sets in your node_modules or on githubThe scripts don't error, but they act very strangely:
- The first time I execute it (before any build files are created) it does nothing. No errors are thrown either.
- If I then simply execute
tsc
in the same working directory, it will generate build files as it should.
- If I then run npm run build
, it will work flawlessly, deleting the existing dist and types directories and then generating new build files.
- If I then run npm run build
again, it will delete the dist and types directories, but won't generate any new build files. No errors are thrown.
- Any subsequent runs do nothing (like in the first step, since the dist and types directories were deleted it's back from the start)Solution
to your prebuild add
tsconfig.tsbuildinfo
, that'll probably fix it. It's the cache file for incremental builds which are enabled by the config.Yep that was it... This was driving me nuts! Thank you
Also managed to cut down the tsconfig to this thanks to your suggestion:
huh I dont know those bottom 2
I'll have to check what they do
Meh, they are a bit "nit-picky" in my opinion, you don't lose much without them, I guess they could be added to sapphire's extra strict tsconfig, if at all