From 853d88f3f65257fd3247eb306874c150afc3e1b4 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Wed, 22 Mar 2017 20:45:39 -0400 Subject: [PATCH] Fix importing linked packages (#1884) Resolves #1661 --- packages/react-scripts/config/webpack.config.dev.js | 6 +++++- packages/react-scripts/config/webpack.config.prod.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index c00301b49c7..48e8a7f5c8a 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -82,7 +82,9 @@ module.exports = { // We use `fallback` instead of `root` because we want `node_modules` to "win" // if there any conflicts. This matches Node resolution mechanism. // https://github.com/facebookincubator/create-react-app/issues/253 - fallback: paths.nodePaths, + // We also fallback to the app's node_modules to support hoisted modules in a + // linked package workflow. + fallback: [paths.appNodeModules].concat(paths.nodePaths), // These are the reasonable defaults supported by the Node ecosystem. // We also include JSX as a common component filename extension to support // some tools, although we do not recommend using it, see: @@ -99,6 +101,8 @@ module.exports = { // directory of `react-scripts` itself rather than the project directory. resolveLoader: { root: paths.ownNodeModules, + // Fallback to any hoisted modules when dealing with linked libraries + fallback: paths.appNodeModules, moduleTemplates: ['*-loader'] }, // @remove-on-eject-end diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 8e3d8e187ca..158ac80ea4f 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -86,7 +86,9 @@ module.exports = { // We use `fallback` instead of `root` because we want `node_modules` to "win" // if there any conflicts. This matches Node resolution mechanism. // https://github.com/facebookincubator/create-react-app/issues/253 - fallback: paths.nodePaths, + // We also fallback to the app's node_modules to support hoisted modules in a + // linked package workflow. + fallback: [paths.appNodeModules].concat(paths.nodePaths), // These are the reasonable defaults supported by the Node ecosystem. // We also include JSX as a common component filename extension to support // some tools, although we do not recommend using it, see: @@ -103,6 +105,8 @@ module.exports = { // directory of `react-scripts` itself rather than the project directory. resolveLoader: { root: paths.ownNodeModules, + // Fallback to any hoisted modules when dealing with linked libraries + fallback: paths.appNodeModules, moduleTemplates: ['*-loader'] }, // @remove-on-eject-end