question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tsup doesn't accurately collect tsconfig.json preferences

See original GitHub issue

After some testing, it looks like tsup doesn’t resolve tsconfig extensions. For example, if my tsconfig was:

{
	"extends": "../tsconfig.base.json",
	"compilerOptions": {
		"baseUrl": "."
	}
}

And ../tsconfig.base.json was:

{
	"compilerOptions": {
		"emitDecoratorMetadata": true
		...
	}
}

Tsup wouldn’t detect any of the extended options, such as emitDecoratorMetadata. This seems to be because you only read the file through fs.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:

const parsedTsConfig = typescript.parseJsonConfigFileContent(tsconfig, typescript.sys, outDir);

You can find a good example of that here, and I could also probably make PR if needed.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
egoistcommented, Jan 29, 2022

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)

0reactions
Lioness100commented, Jan 30, 2022

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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tsup doesn't accurately collect tsconfig.json preferences
Tsup doesn't accurately collect tsconfig.json preferences. ... After some testing, it looks like tsup doesn't resolve tsconfig extensions.
Read more >
tsc apparently not picking up tsconfig.json · Issue #6591 - GitHub
The problem is that tsconfig.json isn't considered when you manually specify your source files on the command line. It's certainly not great ...
Read more >
TypeScript `tsc` not picking up tsconfig.json inside a ...
TypeScript only uses one tsconfig.json and doesn't automatically use subdirectories' tsconfig.json for the files there.
Read more >
TSConfig Reference - Docs on every TSConfig option
Intro to the TSConfig Reference​​ A TSConfig file in a directory indicates that the directory is the root of a TypeScript or JavaScript...
Read more >
Typescript does not resolve modules through tsconfig.json's ...
The problem is that you have "files":[] section that only includes a file from typings. If there is a 'files' section in tsconfig.json,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found