-
-
Notifications
You must be signed in to change notification settings - Fork 600
[@rollup/plugin-typescript] { compilerOptions: { module: "nodeNext" } } overwritten when coming from "extends" in tsconfig.json #1583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm facing the same issue...
This workaround works, but we loose all the purpose of extending a config... |
Explicitly adding it to the plugin declaration also works. Not ideal, but IMO it's better than having to change tsconfig.json. plugins: [typescript({ module: 'nodeNext' })] |
you can also dynamically add it to to the plugin declaration using something like this in a
Presumably some version of the |
Run into this issue as well. The affected code is located here:
I believe that the whole tsconfig.ts module is due for a refactor as its current behavior is not correct and misleading. The following discussion might help with resolution: microsoft/TypeScript#44573 . There I found mention of https://github.com/dominikg/tsconfck package which can help with parsing of tsconfig files. |
This refactor updates readTsConfigFile to correctly handle nested "extends" properties by using TypeScript’s parsing mechanism instead of basic JSON reading. The new behavior returns a unified JSON object that consolidates all properties from extended tsconfig files. This change addresses issue rollup#1583, ensuring complete config resolution across extended tsconfigs while retaining existing behavior with minimal changes and no breaking modifications.
…tion" from extended config This test asserts that the fix in rollup#1812, which addresses issue rollup#1583, fully inherits both "module" and "moduleResolution" options from the extended tsconfig. Without this fix, the TypeScript compiler would throw an error as described in rollup#1583.
…iler options. Solves rollup#1583
Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ |
Uh oh!
There was an error while loading. Please reload this page.
Expected Behavior
I have two typescript config files: tsconfig.base.json and tsconfig.json.
In the tsconfig.base.json I have
{ compilerOptions: { module: "nodeNext" } }
.tsconfig.json extends tsconfig.base.json.
When I run the typescript config, I expect that it takes the
module: "nodeNext"
into account that I configured in the tsconfig.base.ts.Actual Behavior
The plugin overwrites
{ compilerOptions: { module: "nodeNext" } }
with{ compilerOptions: { module: "esNext" } }
. This produces the following error with TypeScript 5.2 and up (see also microsoft/TypeScript#54567):Additional Information
Cause of the bug
https://github.com/rollup/plugins/blob/typescript-v11.1.3/packages/typescript/src/options/tsconfig.ts#L155-L196
This block gets the JSON parsed tsConfigFile that's used to process the project (in the reproduction, thats
./tsconfig.json
), adds the default options to thecompilerOptions
, and passes it on to TypeScript to completely parse the file, fill in defaults, etc.However, if the tsconfig.json contains an extends which defines the module, the tsconfig.json ends up like this:
These compilerOptions take precedence over the one in the tsconfig.base.json, effectively overriding the project's module setting.
Workaround
Move / copy
{ compilerOptions: { module: "nodeNext" } }
to the tsconfig.json file.This way,
...tsConfigFile.compilerOptions
overwrites the property from...DEFAULT_COMPILER_OPTIONS
. However, it does lead to repetition that theextends
should solve.The text was updated successfully, but these errors were encountered: