File tree 3 files changed +19
-13
lines changed
3 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 11
11
12
12
var path = require ( 'path' ) ;
13
13
14
- // We support resolving modules according to NODE_PATH.
14
+ // We support resolving modules according to ` NODE_PATH` .
15
15
// This lets you use absolute paths in imports inside large monorepos:
16
16
// https://github.com/facebookincubator/create-react-app/issues/253.
17
- // It works just like NODE_PATH in Node:
17
+
18
+ // It works similar to `NODE_PATH` in Node itself:
18
19
// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
20
+
19
21
// We will export `nodePaths` as an array of absolute paths.
20
- // It will then be used by Webpack (and potentially other tools).
22
+ // It will then be used by Webpack configs.
23
+ // Jest doesn’t need this because it already handles `NODE_PATH` out of the box.
24
+
21
25
var nodePaths = ( process . env . NODE_PATH || '' )
22
26
. split ( process . platform === 'win32' ? ';' : ':' )
23
27
. filter ( Boolean )
Original file line number Diff line number Diff line change @@ -67,11 +67,12 @@ module.exports = {
67
67
publicPath : '/'
68
68
} ,
69
69
resolve : {
70
- // This allows you to set a root for where Webpack should look for modules.
71
- // It must be an absolute path or an array of absolute paths.
72
- // This lets you use absolute paths in imports inside large monorepos:
73
- // https://github.com/facebookincubator/create-react-app/issues/253.
74
- root : paths . nodePaths ,
70
+ // This allows you to set a fallback for where Webpack should look for modules.
71
+ // We read `NODE_PATH` environment variable in `paths.js` and pass paths here.
72
+ // We use `fallback` instead of `root` because we want `node_modules` to "win"
73
+ // if there any conflicts. This matches Node resolution mechanism.
74
+ // https://github.com/facebookincubator/create-react-app/issues/253
75
+ fallback : paths . nodePaths ,
75
76
// These are the reasonable defaults supported by the Node ecosystem.
76
77
extensions : [ '.js' , '.json' , '' ] ,
77
78
alias : {
Original file line number Diff line number Diff line change @@ -62,11 +62,12 @@ module.exports = {
62
62
publicPath : publicPath
63
63
} ,
64
64
resolve : {
65
- // This allows you to set a root for where Webpack should look for modules.
66
- // It must be an absolute path or an array of absolute paths.
67
- // This lets you use absolute paths in imports inside large monorepos:
68
- // https://github.com/facebookincubator/create-react-app/issues/253.
69
- root : paths . nodePaths ,
65
+ // This allows you to set a fallback for where Webpack should look for modules.
66
+ // We read `NODE_PATH` environment variable in `paths.js` and pass paths here.
67
+ // We use `fallback` instead of `root` because we want `node_modules` to "win"
68
+ // if there any conflicts. This matches Node resolution mechanism.
69
+ // https://github.com/facebookincubator/create-react-app/issues/253
70
+ fallback : paths . nodePaths ,
70
71
// These are the reasonable defaults supported by the Node ecosystem.
71
72
extensions : [ '.js' , '.json' , '' ] ,
72
73
alias : {
You can’t perform that action at this time.
0 commit comments