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

Failed to resolve the module node:* when target ≠ "node" #1036

Open
donmccurdy opened this issue Mar 21, 2023 · 2 comments
Open

Failed to resolve the module node:* when target ≠ "node" #1036

donmccurdy opened this issue Mar 21, 2023 · 2 comments

Comments

@donmccurdy
Copy link
Contributor

Similar to #989, but now occurring only when Microbundle's target is not Node.js. I'm compiling a library that runs in both Node.js and a browser, and the library contains dynamic imports for node built-ins like 'fs', executed only in Node.js.

When importing fs I can add the following to my package.json and everything works fine:

"browser": {
  "fs": false,
  "path": false
},

However, using node:fs, the same thing does not work, and warnings appear with:

"browser": {
  "node:fs": false,
  "node:path": false
},
Failed to resolve the module node:fs

Microbundle v0.15.1, Node.js v18.12.1.

@machao7

This comment was marked as spam.

@rschristian
Copy link
Collaborator

@machao7 You can subscribe to the issue and get notified whenever there's progress. When there is, you'd see it here.

Honestly I'd recommend avoiding the browser field spec anyhow, package.json#exports has completely eclipsed it. Output separate browser & Node bundles, don't rely upon bundlers patching out your imports. It's always been a pretty bad hack for isomorphic modules.

That being said, likely just need to bump @rollup/plugin-node-resolve, looks to be related to rollup/plugins#1048 & rollup/plugins#1124

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