You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a Module with type: commonjs in the package.json it is not possible to have a valid bundle and also use NodeNext as the moduleResolution.
Additional Information
The Rollup Typescript Plugin always overrides the moduleResolution option based on the module option.
When in the tsconfig.json the module option is set to NodeNext the moduleResolution is set to NodeNext. Because in package.json the type is set to commonjs, typescript is compiling to commonjs. Rollup dose't understand commonjs out of the box, so the dependency module dose't get bundled. All of this is what i am expecting!! No issue so far.
To make the output of typescript compatible with rollup i change the module type to ESNext. This config can be compiled with Typescript without errors because typescript is using the moduleResolution of the tsconfig.json file (NodeNext)!!
In Rollup (with Typescript Plugin) this now dose't compile anymore. The reason is, that the typescript plugin is overriding the moduleResolution to node. So typescript can not find the declarations anymore. This is because i'm declaring the exports of the dependency with the exports field in the package.json which typescript ignores for types when it is set to node moduleResolution. This is due to the setModuleResolutionKind function in src/options/tsconfig.ts.
I don't know why this function exists and is implemented like it is. When i change this function to not change the moduleResolution option, everything works as expected.
Maybe it is better to not override this option when ES Modules are specified? I think at least we should keep a way to manually set the moduleResolution option.
The text was updated successfully, but these errors were encountered:
Expected Behavior
I expected that the moduleResolution set in the tsconfig.json is respected and not always overwritten by setModuleResolutionKind.
plugins/packages/typescript/src/options/tsconfig.ts
Lines 106 to 122 in 7b62557
Actual Behavior
In a Module with type: commonjs in the package.json it is not possible to have a valid bundle and also use NodeNext as the moduleResolution.
Additional Information
The Rollup Typescript Plugin always overrides the moduleResolution option based on the module option.
When in the tsconfig.json the module option is set to NodeNext the moduleResolution is set to NodeNext. Because in package.json the type is set to commonjs, typescript is compiling to commonjs. Rollup dose't understand commonjs out of the box, so the dependency module dose't get bundled. All of this is what i am expecting!! No issue so far.
To make the output of typescript compatible with rollup i change the module type to ESNext. This config can be compiled with Typescript without errors because typescript is using the moduleResolution of the tsconfig.json file (NodeNext)!!
In Rollup (with Typescript Plugin) this now dose't compile anymore. The reason is, that the typescript plugin is overriding the moduleResolution to node. So typescript can not find the declarations anymore. This is because i'm declaring the exports of the dependency with the exports field in the package.json which typescript ignores for types when it is set to node moduleResolution. This is due to the setModuleResolutionKind function in src/options/tsconfig.ts.
plugins/packages/typescript/src/options/tsconfig.ts
Line 106 in 7b62557
I don't know why this function exists and is implemented like it is. When i change this function to not change the moduleResolution option, everything works as expected.
Maybe it is better to not override this option when ES Modules are specified? I think at least we should keep a way to manually set the moduleResolution option.
The text was updated successfully, but these errors were encountered: