mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-01-12 22:46:30 +08:00
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:
@@ -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": [
|
||||
|
||||
@@ -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}"` });
|
||||
}
|
||||
|
||||
12
packages/react-scripts/fixtures/kitchensink/src/features/webpack/DynamicImport.js
vendored
Normal file
12
packages/react-scripts/fixtures/kitchensink/src/features/webpack/DynamicImport.js
vendored
Normal 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!</>;
|
||||
};
|
||||
@@ -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!');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user