Upgrade webpack to 4.35.0 to fix dynamic import issue (#7257)

* Upgrade webpack to 4.35.0 to fix dynamic import issue

* Add a test maybe?
This commit is contained in:
Ian Sutherland
2019-06-24 12:25:15 -06:00
committed by GitHub
parent bfee6069c9
commit a88a4c3af6
5 changed files with 39 additions and 3 deletions

View File

@@ -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": [

View File

@@ -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':
@@ -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}"` });
}

View File

@@ -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!</>;
};

View File

@@ -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!');
});
});
});

View File

@@ -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"