web-infra-dev / modern.js

Modern.js is a web engineering system, including a web framework and a npm package solution.
https://modernjs.dev/en/
MIT License
4.28k stars 352 forks source link

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

Closed kripod closed 1 week ago

kripod commented 1 month ago

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

yimingjfe commented 1 month ago

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?

kripod commented 1 month ago

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.

yimingjfe commented 1 month ago

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?

kripod commented 1 month ago

@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.

yimingjfe commented 1 month ago

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

kripod commented 1 month ago

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.

fi3ework commented 1 month ago

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.