Skip to content

Commit 9bea75e

Browse files
authored
Merge pull request #4 from andersinno/revert-3-remove_module_scope_restriction
Revert "Remove moduleScopePlugin that restricted the relative imports"
2 parents c94bb95 + 477cc65 commit 9bea75e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
1717
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
1818
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
1919
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
20+
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
2021
const getClientEnvironment = require('./env');
2122
const paths = require('./paths');
2223

@@ -117,6 +118,14 @@ module.exports = {
117118
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
118119
'react-native': 'react-native-web',
119120
},
121+
plugins: [
122+
// Prevents users from importing files from outside of src/ (or node_modules/).
123+
// This often causes confusion because we only process files within src/ with babel.
124+
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
125+
// please link the files into your node_modules/ and let module-resolution kick in.
126+
// Make sure your source files are compiled, as they will not be processed in any way.
127+
new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
128+
],
120129
},
121130
module: {
122131
strictExportPresence: true,

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const ExtractTextPlugin = require('extract-text-webpack-plugin');
1818
const ManifestPlugin = require('webpack-manifest-plugin');
1919
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
2020
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
21+
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
2122
const paths = require('./paths');
2223
const getClientEnvironment = require('./env');
2324

@@ -121,6 +122,14 @@ module.exports = {
121122
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
122123
'react-native': 'react-native-web',
123124
},
125+
plugins: [
126+
// Prevents users from importing files from outside of src/ (or node_modules/).
127+
// This often causes confusion because we only process files within src/ with babel.
128+
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
129+
// please link the files into your node_modules/ and let module-resolution kick in.
130+
// Make sure your source files are compiled, as they will not be processed in any way.
131+
new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
132+
],
124133
},
125134
module: {
126135
strictExportPresence: true,

0 commit comments

Comments
 (0)