diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 2ed9697fdb7..985a1e9b5dd 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -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": [ diff --git a/packages/react-scripts/fixtures/kitchensink/src/App.js b/packages/react-scripts/fixtures/kitchensink/src/App.js index 457b552601d..50fd8932341 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/App.js +++ b/packages/react-scripts/fixtures/kitchensink/src/App.js @@ -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}"` }); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/DynamicImport.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/DynamicImport.js new file mode 100644 index 00000000000..e0c629159b4 --- /dev/null +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/DynamicImport.js @@ -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!; +}; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/DynamicImport.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/DynamicImport.test.js new file mode 100644 index 00000000000..21e90154a9a --- /dev/null +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/DynamicImport.test.js @@ -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(, div); + expect(div.textContent).toBe('Hello World!'); + }); + }); +}); diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index a15c92d03f4..af92d8ab28b 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -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"