Skip to content

Commit

Permalink
Upgrade webpack to 4.35.0 to fix dynamic import issue (#7257)
Browse files Browse the repository at this point in the history
* Upgrade webpack to 4.35.0 to fix dynamic import issue

* Add a test maybe?
  • Loading branch information
iansu authored Jun 24, 2019
1 parent bfee606 commit a88a4c3
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/react-error-overlay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"settle-promise": "1.0.0",
"source-map": "0.5.6",
"terser-webpack-plugin": "1.2.3",
"webpack": "^4.29.6"
"webpack": "^4.35.0"
},
"jest": {
"setupFiles": [
Expand Down
7 changes: 6 additions & 1 deletion packages/react-scripts/fixtures/kitchensink/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class App extends Component {
// This works around an issue of a duplicate hash in the href
// Ex: http://localhost:3001/#array-destructuring#array-destructuring
// This seems like a jsdom bug as the URL in initDom.js appears to be correct
const feature = url.slice(url.lastIndexOf("#") + 1);
const feature = url.slice(url.lastIndexOf('#') + 1);

switch (feature) {
case 'array-destructuring':
Expand Down Expand Up @@ -241,6 +241,11 @@ class App extends Component {
this.setFeature(f.default)
);
break;
case 'dynamic-import':
import('./features/webpack/DynamicImport').then(f =>
this.setFeature(f.default)
);
break;
default:
this.setState({ error: `Missing feature "${feature}"` });
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';

export default () => {
return <>Hello World!</>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import ReactDOM from 'react-dom';

describe('dynamic import', () => {
it('renders without crashing', async () => {
import('./DynamicImport').then(DynamicImport => {
const div = document.createElement('div');
ReactDOM.render(<DynamicImport />, div);
expect(div.textContent).toBe('Hello World!');
});
});
});
2 changes: 1 addition & 1 deletion packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"terser-webpack-plugin": "1.2.3",
"ts-pnp": "1.1.2",
"url-loader": "1.1.2",
"webpack": "4.29.6",
"webpack": "4.35.0",
"webpack-dev-server": "3.2.1",
"webpack-manifest-plugin": "2.0.4",
"workbox-webpack-plugin": "4.2.0"
Expand Down

0 comments on commit a88a4c3

Please sign in to comment.