Skip to content

Commit c27d765

Browse files
authored
Test module scoping (#2198)
* Correct readme * Add tests * Update README.md
1 parent ee850f5 commit c27d765

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

packages/react-dev-utils/README.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var publicUrl = '/my-custom-url';
3434
module.exports = {
3535
output: {
3636
// ...
37-
publicPath: publicUrl + '/'
37+
publicPath: publicUrl + '/'
3838
},
3939
// ...
4040
plugins: [
@@ -68,10 +68,14 @@ var ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
6868

6969
module.exports = {
7070
// ...
71-
plugins: [
72-
new ModuleScopePlugin(paths.appSrc),
71+
resolve: {
7372
// ...
74-
],
73+
plugins: [
74+
new ModuleScopePlugin(paths.appSrc),
75+
// ...
76+
],
77+
// ...
78+
},
7579
// ...
7680
}
7781
```
@@ -132,7 +136,7 @@ console.log('Just cleared the screen!');
132136

133137
#### `eslintFormatter(results: Object): string`
134138

135-
This is our custom ESLint formatter that integrates well with Create React App console output.
139+
This is our custom ESLint formatter that integrates well with Create React App console output.<br>
136140
You can use the default one instead if you prefer so.
137141

138142
```js

tasks/e2e-simple.sh

+25
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,25 @@ function verify_env_url {
228228
mv package.json.orig package.json
229229
}
230230

231+
function verify_module_scope {
232+
# Create stub json file
233+
echo "{}" >> sample.json
234+
235+
# Save App.js, we're going to modify it
236+
cp src/App.js src/App.js.bak
237+
238+
# Add an out of scope import
239+
echo "import sampleJson from '../sample'" | cat - src/App.js > src/App.js.temp && mv src/App.js.temp src/App.js
240+
241+
# Make sure the build fails
242+
npm run build; test $? -eq 1 || exit 1
243+
# TODO: check for error message
244+
245+
# Restore App.js
246+
rm src/App.js
247+
mv src/App.js.bak src/App.js
248+
}
249+
231250
# Enter the app directory
232251
cd test-app
233252

@@ -251,6 +270,9 @@ npm start -- --smoke-test
251270
# Test environment handling
252271
verify_env_url
253272

273+
# Test reliance on webpack internals
274+
verify_module_scope
275+
254276
# ******************************************************************************
255277
# Finally, let's check that everything still works after ejecting.
256278
# ******************************************************************************
@@ -287,5 +309,8 @@ npm start -- --smoke-test
287309
# Test environment handling
288310
verify_env_url
289311

312+
# Test reliance on webpack internals
313+
verify_module_scope
314+
290315
# Cleanup
291316
cleanup

0 commit comments

Comments
 (0)