Closed Lioness100 closed 2 years ago
My tsconfig:
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"outDir": "../dist",
"rootDir": ".",
"baseUrl": ".",
"noEmit": true,
"paths": {
"#root/*": ["*"],
"#lib/*": ["lib/*"],
"#types/*": ["lib/types/*"],
"#structures/*": ["lib/structures/*"],
"#utils/*": ["lib/utils/*"],
"#database/*": ["lib/database/*"]
}
},
"include": ["."]
}
The extended tsconfig has emitDecoratorMetadata
Logs:
Furthermore, if there isn't one already, might I suggest an option to manually disable the swc plugin? This would be useful if:
entities
directory if using typeorm, or creating a regex to search for decorators)Should I just submit a PR to the package that reads the tsconfig?
I'd like to use a library that doesn't use the typescript
compiler to load tsconfig.json, since tsup should work without typescript
Maybe add an option: loadTsconfigWithCompiler: true
(or some other name) before this is implemented.
What if, in this library, once and if the raw tsconfig data is collected, the code checks if typescript is installed, uses it to expand the tsconfig if it is, and just keeps the original otherwise?
Edit: loadTsconfigWithCompiler
would work fine as well
Maybe this one would fit the bill in the sense of not using Typescript.
Oooh that looks perfect!
This should be fixed in 5.11.12, please give it a try
btw I made a package for this: https://github.com/egoist/load-tsconfig (even more light-weight than tsconfig-loader)
Great, thank you so much! Can I also make a PR that adds the option to force tsup to use esbuild over swc, even if the emitDecoratorMetadata is enabled somewhere? (Nevermind, I just won't install @swc/core
)
After some testing, it looks like tsup doesn't resolve tsconfig extensions. For example, if my tsconfig was:
And
../tsconfig.base.json
was:Tsup wouldn't detect any of the extended options, such as
emitDecoratorMetadata
. This seems to be because you only read the file throughfs.readFileSync
and use the results directly. However, I believe you need to use typescript's compiler API to get the full contents. Something like this:You can find a good example of that here, and I could also probably make PR if needed.