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

feat(cli): better error message when failed to resolve non explicit CJS module from ESM #26802

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

Hajime-san
Copy link
Contributor

@Hajime-san Hajime-san commented Nov 10, 2024

Summary

part of

I think it covers almost use cases, while it's not as strict as the Node.js implementation.
Although this is a somewhat complex configuration, it is not expected to have any performance impact on runtime.

Changes

  • app.tsx
import ReactDomServer from 'npm:[email protected]/server'
console.log(ReactDomServer);

before

% deno run app.tsx
error: Unable to load /path/to/Library/Caches/deno/npm/registry.npmjs.org/react-dom/16.8.5/server imported from file:///path/to/app.tsx

Caused by:
    No such file or directory (os error 2)

after

% /path/to/deno/target/debug/deno run app.tsx
error: Unable to load /path/to/Library/Caches/deno/npm/registry.npmjs.org/react-dom/16.8.5/server imported from file:///path/to/app.tsx

Caused by:
    No such file or directory (os error 2)

    info: The module that you are trying to import seems to be a CommonJS.
          However it is not listed in the exports of package.json.
          So it cannot be statically resolved when imported from ESM.
          Consider to include an extension of the module.
    hint: Did you mean to import "react-dom/server.js"?

@Hajime-san Hajime-san force-pushed the show-suggestion-for-cjs branch 3 times, most recently from 5e95117 to 970e5ee Compare November 10, 2024 07:20
@Hajime-san Hajime-san marked this pull request as draft November 15, 2024 03:53
@Hajime-san Hajime-san force-pushed the show-suggestion-for-cjs branch from 970e5ee to c093d22 Compare December 5, 2024 00:52
@Hajime-san Hajime-san force-pushed the show-suggestion-for-cjs branch from c093d22 to e24433d Compare December 5, 2024 00:53
@Hajime-san Hajime-san marked this pull request as ready for review December 5, 2024 02:29
@Hajime-san Hajime-san force-pushed the show-suggestion-for-cjs branch from f9e299d to cbdb67a Compare January 7, 2025 04:08
@Hajime-san
Copy link
Contributor Author

@dsherret @bartlomieju
Could you take a look?

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

Successfully merging this pull request may close these issues.

1 participant