Skip to content

Commit d9fc932

Browse files
authored
Fix importing linked packages (#1884)
Resolves #1661
1 parent a5479de commit d9fc932

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/react-scripts/config/webpack.config.dev.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ module.exports = {
8282
// We use `fallback` instead of `root` because we want `node_modules` to "win"
8383
// if there any conflicts. This matches Node resolution mechanism.
8484
// https://github.com/facebookincubator/create-react-app/issues/253
85-
fallback: paths.nodePaths,
85+
// We also fallback to the app's node_modules to support hoisted modules in a
86+
// linked package workflow.
87+
fallback: [paths.appNodeModules].concat(paths.nodePaths),
8688
// These are the reasonable defaults supported by the Node ecosystem.
8789
// We also include JSX as a common component filename extension to support
8890
// some tools, although we do not recommend using it, see:
@@ -99,6 +101,8 @@ module.exports = {
99101
// directory of `react-scripts` itself rather than the project directory.
100102
resolveLoader: {
101103
root: paths.ownNodeModules,
104+
// Fallback to any hoisted modules when dealing with linked libraries
105+
fallback: paths.appNodeModules,
102106
moduleTemplates: ['*-loader']
103107
},
104108
// @remove-on-eject-end

packages/react-scripts/config/webpack.config.prod.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ module.exports = {
8686
// We use `fallback` instead of `root` because we want `node_modules` to "win"
8787
// if there any conflicts. This matches Node resolution mechanism.
8888
// https://github.com/facebookincubator/create-react-app/issues/253
89-
fallback: paths.nodePaths,
89+
// We also fallback to the app's node_modules to support hoisted modules in a
90+
// linked package workflow.
91+
fallback: [paths.appNodeModules].concat(paths.nodePaths),
9092
// These are the reasonable defaults supported by the Node ecosystem.
9193
// We also include JSX as a common component filename extension to support
9294
// some tools, although we do not recommend using it, see:
@@ -103,6 +105,8 @@ module.exports = {
103105
// directory of `react-scripts` itself rather than the project directory.
104106
resolveLoader: {
105107
root: paths.ownNodeModules,
108+
// Fallback to any hoisted modules when dealing with linked libraries
109+
fallback: paths.appNodeModules,
106110
moduleTemplates: ['*-loader']
107111
},
108112
// @remove-on-eject-end

0 commit comments

Comments
 (0)