modern.js icon indicating copy to clipboard operation
modern.js copied to clipboard

[Feature]: Add override for `noEmit` specified in TSConfig

Open kripod opened this issue 1 year ago • 7 comments

What problem does this feature solve?

When using Modern.js alongside @total-typescript/tsconfig, noEmit: false has to be specified explicitly within tsconfig.json, otherwise modern build fails:

error   ModuleBuildError: 

bundleless DTS failed:

error TS5053: Option 'emitDeclarationOnly' cannot be specified with option 'noEmit'.

Unfortunately, though, when I have noEmit: false specified (either implicitly or explicitly) alongside allowJs: true, IDEs like VS Code show an error message as follows when viewing tsconfig.json while having any JS files within the source directory:

Cannot write file '…/project/src/something.js' because it would overwrite input file.

Therefore, it’d be convenient to allow specifying noEmit: true within the userTsconfig, possibly overriding it by appending --noEmit false to the CLI arguments over here.

What does the proposed API look like?

N/A

kripod avatar May 25 '24 10:05 kripod

Could you provide the project? Because we don't know which tsconfig from @total-typescript/tsconfig you are using, and is app-tools or module-tools used in the project?

yimingjfe avatar May 28 '24 06:05 yimingjfe

Thanks for your response!

Unfortunately, I can’t provide the project itself, as it’s a private one. This is the TSConfig I’m using.

kripod avatar May 28 '24 06:05 kripod

Thanks for your response!

Unfortunately, I can’t provide the project itself, as it’s a private one. This is the TSConfig I’m using.

Understand, what library are you using? @modern-js/app-tools or @modern-js/module-tools?

yimingjfe avatar May 28 '24 12:05 yimingjfe

@modern-js/module-tools, but I also gave Vite’s library mode a go in the meantime and sticked with it for the time being.

kripod avatar May 28 '24 12:05 kripod

I created a project as described to try to reproduce the problem, but it didn't reproduce the problem.

yimingjfe avatar May 30 '24 11:05 yimingjfe

Thanks for creating that!

I forgot to mention I had 'npm-component-es2017' configured as the buildPreset in modern.config.ts. Running your project with that change results in a reproduction.

kripod avatar Jun 01 '24 19:06 kripod

Thanks for creating that!

I forgot to mention I had 'npm-component-es2017' configured as the buildPreset in modern.config.ts. Running your project with that change results in a reproduction.

Can't reproduce the error even adding 'npm-componnet-es2017', the error seems quite like a pure TypeScript misconfiguration, could you check your tsconfig by refering https://stackoverflow.com/a/48798945/8063488.

fi3ework avatar Jun 05 '24 18:06 fi3ework