Skip to content

Commit e4375f8

Browse files
committed
Avoid relying on Node’s internals
`process.binding()` is not a public API, and should not be used. Luckily, Node recently introduced an API that does exactly what Webpack needs: https://nodejs.org/api/modules.html#modules_module_builtinmodules So use that instead and keep the old path as a fallback.
1 parent 33f518b commit e4375f8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/node/NodeTargetPlugin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
const ExternalsPlugin = require("../ExternalsPlugin");
88

9+
const builtins = require("module").builtinModules || Object.keys(process.binding("natives"));
10+
911
class NodeTargetPlugin {
1012
apply(compiler) {
11-
new ExternalsPlugin("commonjs", Object.keys(process.binding("natives"))).apply(compiler);
13+
new ExternalsPlugin("commonjs", builtins).apply(compiler);
1214
}
1315
}
1416

0 commit comments

Comments
 (0)