Subpaths imports syntax not working
imjuni opened this issue · comments
- Version: 3.1.1
- Rollup Version: 3.9.1
- Operating System and version (if applicable): wsl2
- Node Version (if applicable): 14.20.1
- Does it work with
tsc
(if applicable): fine works in tsc
Reproduction
I create reproducable repo. Reproducable problem that step,
- checkout reproducable repo.
- run
npm install
- run
npm run rollup:prod
Expected Behavior
Recently, Node.js and TypeScript support subpaths imports. This feature can replace TypeScript Re-Map paths and tsconfig-paths.
But rollup-plugin-ts cannot compile this syntax like that,
[!] (plugin Typescript) RollupError: Cannot find module '#modules/logger.js' or its corresponding type declarations.
I think that rollup-plugin-ts have to do compile this syntax.
Actual Behavior
rollup-plugin-ts cannot resolve this syntax. rollup-plugin-ts display error message like that,
[!] (plugin Typescript) RollupError: Cannot find module '#modules/logger.js' or its corresponding type declarations.
@wessberg is it possible to support moduleResolution: node16
or moduleResolution: nodenext
instead of forced moduleResolution: node
?
@quebits as a temporary workaround patching dist/cjs/index.cjs and/or dist/esm/index.js to use Bundler
rather than NodeJs
fixes this for me (NodeNext
works as well, but it breaks most published modules and doesn't work with dual/mixed CommonJS/ESM packages):
diff --git a/dist/cjs/index.cjs b/dist/cjs/index.cjs
--- a/dist/cjs/index.cjs
+++ b/dist/cjs/index.cjs
@@ -746,7 +746,7 @@ function getForcedCompilerOptions(options) {
// Node resolution is required when 'importHelpers' are true
- moduleResolution: options.pluginOptions.typescript.ModuleResolutionKind.NodeJs,
+ moduleResolution: options.pluginOptions.typescript.ModuleResolutionKind.Bundler,
diff --git a/dist/esm/index.js b/dist/esm/index.js
--- a/dist/esm/index.js
+++ b/dist/esm/index.js
@@ -744,7 +744,7 @@ function getForcedCompilerOptions(options) {
// Node resolution is required when 'importHelpers' are true
- moduleResolution: options.pluginOptions.typescript.ModuleResolutionKind.NodeJs,
+ moduleResolution: options.pluginOptions.typescript.ModuleResolutionKind.Bundler,