Skip to content

Commit a88a4c3

Browse files
authored
Upgrade webpack to 4.35.0 to fix dynamic import issue (facebook#7257)
* Upgrade webpack to 4.35.0 to fix dynamic import issue * Add a test maybe?
1 parent bfee606 commit a88a4c3

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

packages/react-error-overlay/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"settle-promise": "1.0.0",
6565
"source-map": "0.5.6",
6666
"terser-webpack-plugin": "1.2.3",
67-
"webpack": "^4.29.6"
67+
"webpack": "^4.35.0"
6868
},
6969
"jest": {
7070
"setupFiles": [

packages/react-scripts/fixtures/kitchensink/src/App.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class App extends Component {
6868
// This works around an issue of a duplicate hash in the href
6969
// Ex: http://localhost:3001/#array-destructuring#array-destructuring
7070
// This seems like a jsdom bug as the URL in initDom.js appears to be correct
71-
const feature = url.slice(url.lastIndexOf("#") + 1);
71+
const feature = url.slice(url.lastIndexOf('#') + 1);
7272

7373
switch (feature) {
7474
case 'array-destructuring':
@@ -241,6 +241,11 @@ class App extends Component {
241241
this.setFeature(f.default)
242242
);
243243
break;
244+
case 'dynamic-import':
245+
import('./features/webpack/DynamicImport').then(f =>
246+
this.setFeature(f.default)
247+
);
248+
break;
244249
default:
245250
this.setState({ error: `Missing feature "${feature}"` });
246251
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import React from 'react';
9+
10+
export default () => {
11+
return <>Hello World!</>;
12+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import React from 'react';
9+
import ReactDOM from 'react-dom';
10+
11+
describe('dynamic import', () => {
12+
it('renders without crashing', async () => {
13+
import('./DynamicImport').then(DynamicImport => {
14+
const div = document.createElement('div');
15+
ReactDOM.render(<DynamicImport />, div);
16+
expect(div.textContent).toBe('Hello World!');
17+
});
18+
});
19+
});

packages/react-scripts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"terser-webpack-plugin": "1.2.3",
7777
"ts-pnp": "1.1.2",
7878
"url-loader": "1.1.2",
79-
"webpack": "4.29.6",
79+
"webpack": "4.35.0",
8080
"webpack-dev-server": "3.2.1",
8181
"webpack-manifest-plugin": "2.0.4",
8282
"workbox-webpack-plugin": "4.2.0"

0 commit comments

Comments
 (0)