File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 77
88const DefinePlugin = require ( "./DefinePlugin" ) ;
99
10+ const needsEnvVarFix = [ "8" , "9" ] . indexOf ( process . versions . node . split ( "." ) [ 0 ] ) >= 0 &&
11+ process . platform === "win32" ;
12+
1013class EnvironmentPlugin {
1114 constructor ( keys ) {
1215 if ( Array . isArray ( keys ) ) {
@@ -23,6 +26,13 @@ class EnvironmentPlugin {
2326
2427 apply ( compiler ) {
2528 const definitions = this . keys . reduce ( ( defs , key ) => {
29+ // TODO remove once the fix has made its way into Node 8.
30+ // Work around https://github.com/nodejs/node/pull/18463,
31+ // affecting Node 8 & 9 by performing an OS-level
32+ // operation that always succeeds before reading
33+ // environment variables:
34+ if ( needsEnvVarFix ) require ( "os" ) . cpus ( ) ;
35+
2636 const value = process . env [ key ] !== undefined ? process . env [ key ] : this . defaultValues [ key ] ;
2737
2838 if ( value === undefined ) {
Original file line number Diff line number Diff line change 66
77const ExternalsPlugin = require ( "../ExternalsPlugin" ) ;
88
9+ const builtins = require ( "module" ) . builtinModules || Object . keys ( process . binding ( "natives" ) ) ;
10+
911class 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
You can’t perform that action at this time.
0 commit comments