developit / developit/microbundle

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

Offen
#1,036 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
8.1k
Forks
358
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Start by reproducing the issue with Microbundle v0.15.1, a non-Node target, and the package.json browser mappings for node:fs and node:path. Compare the behavior with the mappings for fs and path; done means node-prefixed built-ins resolve without warnings for browser-compatible builds.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, node.js
Bereich
build-system
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.