developit / developit/microbundle

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

Open
#1,036 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
8.1k
Forks
358
PR merge metrics
No merged PRs in 30d

Description

Similar to https://github.com/developit/microbundle/issues/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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.