webpack: resolve.fallback and resolve.alias do not work with `node:` prefix
Bug report
resolve.fallback and resolve.alias do not work with node: prefix
What is the current behavior?
Module build failed: UnhandledSchemeError: Reading from "node:fs" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
If the current behavior is a bug, please provide the steps to reproduce.
webpack.config.js
module.exports = {
mode: "development",
target: "web",
entry: "./entry.js",
resolve: {
fallback: {
path: false,
'node:path': false,
},
alias: {
path: false,
'node:path': false,
}
}
};
entry.js
import * as mod from "node:fs";
console.log(mod);
What is the expected behavior?
fallback and aliases should work
Other relevant information: webpack version: 5.52.0 Node.js version: any Operating System: any Additional tools: any
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 26
- Comments: 15 (12 by maintainers)
Commits related to this issue
- chore: downgrade env-paths 3.0.0 -> 2.2.1 sigh, env-paths 3.0.0 uses `import x from 'node:os'` which webpack isn't happy with (yet) https://github.com/webpack/webpack/issues/14166 — committed to starpit/madwizard by starpit 5 years ago
- chore: downgrade env-paths 3.0.0 -> 2.2.1 sigh, env-paths 3.0.0 uses `import x from 'node:os'` which webpack isn't happy with (yet) https://github.com/webpack/webpack/issues/14166 — committed to guidebooks/madwizard by starpit 5 years ago
- Whitewash webpack issues with "node:" scheme/prefix in imports and also, top-level `await` for dynamic `import`s See: https://github.com/webpack/webpack/issues/14166 — committed to mirismaili/smart-color by mirismaili 4 years ago
- Whitewash webpack issues with "node:" scheme/prefix in imports and also, top-level `await` for dynamic `import`s See: https://github.com/webpack/webpack/issues/14166 — committed to mirismaili/smart-color by mirismaili 4 years ago
bump
on
webpack@6board…as I understand it should work this way
I checked it works with configuration above
@alexander-akait can we close this?
@vankop Like we do with
require('fs')forwebtarget and allow to ignoreimport("node:fs")usingresolve.alias/resolve.fallbackoptions@vankop is additional esoteric configuration really the solution here? Can this be handled internally? Does that match the expected result of
"node:fs": false?browser doesn’t have
node:schema (i.e. Node.js modules), so for web target it is not possibleSince this isn’t already supported, wouldn’t it be easier to support
node:also fortarget: "web"? From what I understand webpack already supports it fortarget: "node"