Skip to content
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

Subpaths imports syntax not working #201

Open
imjuni opened this issue Jan 12, 2023 · 2 comments
Open

Subpaths imports syntax not working #201

imjuni opened this issue Jan 12, 2023 · 2 comments

Comments

@imjuni
Copy link

imjuni commented Jan 12, 2023

  • 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,

  1. checkout reproducable repo.
  2. run npm install
  3. 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.

@quebits
Copy link

quebits commented Feb 9, 2023

@wessberg is it possible to support moduleResolution: node16 or moduleResolution: nodenext instead of forced moduleResolution: node?

@chocolateboy
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants