diff --git a/package.json b/package.json index dcbb506b3..ed905ee40 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "flow-typed": "^2.4.0", "google-translate-api": "^2.3.0", "html-loader": "^0.5.5", - "html-webpack-plugin": "^3.2.0", + "html-webpack-plugin": "^4.0.0-alpha", "intl": "^1.2.5", "intl-locales-supported": "^1.0.0", "js-yaml": "^3.12.0", diff --git a/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/Home.js b/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/Home.js index e03c5a411..4ef02d9ed 100644 --- a/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/Home.js +++ b/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/Home.js @@ -1,20 +1,29 @@ /* @flow */ - -import Simulateur from 'Components/Simu' -import { ScrollToTop } from 'Components/utils/Scroll' import { compose } from 'ramda' import React, { Component } from 'react' import { connect } from 'react-redux' import * as Animate from 'Ui/animate' +import type Simulateur from 'Components/Simu' type Props = { hideText: boolean } -class SocialSecurity extends Component { +type State = { + simulateur: ?Simulateur +} +class SocialSecurity extends Component { + state = { + simulateur: null + } + componentDidMount() { + import('Components/Simu').then(Simulateur => + this.setState({ simulateur: Simulateur.default }) + ) + } render() { + const Simulateur = this.state.simulateur return ( <> - {!this.props.hideText && ( <> @@ -51,7 +60,7 @@ class SocialSecurity extends Component {

How much does it cost ?

)} - + {Simulateur && }
) diff --git a/source/webpack.common.js b/source/webpack.common.js index d194fd186..b48c7d012 100644 --- a/source/webpack.common.js +++ b/source/webpack.common.js @@ -27,6 +27,13 @@ module.exports = { filename: ({ chunk }) => chunk.name === 'dist/simulateur' ? '[name].js' : '[name].[hash].js' }, + optimization: { + splitChunks: { + // include all types of chunks + chunks: 'all', + name: false + } + }, module: { rules: [ { diff --git a/yarn.lock b/yarn.lock index 0396675e2..f863245bd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -738,6 +738,10 @@ version "10.5.2" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.5.2.tgz#f19f05314d5421fe37e74153254201a7bf00a707" +"@types/tapable@1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.2.tgz#e13182e1b69871a422d7863e11a4a6f5b814a4bd" + "@webassemblyjs/ast@1.5.13": version "1.5.13" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.5.13.tgz#81155a570bd5803a30ec31436bc2c9c0ede38f25" @@ -3930,16 +3934,16 @@ html-parse-stringify2@2.0.1: dependencies: void-elements "^2.0.1" -html-webpack-plugin@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz#b01abbd723acaaa7b37b6af4492ebda03d9dd37b" +html-webpack-plugin@^4.0.0-alpha: + version "4.0.0-alpha" + resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-4.0.0-alpha.tgz#b2c7b6d4885a209c999dfce3ffb9866e2c8c0eaa" dependencies: + "@types/tapable" "1.0.2" html-minifier "^3.2.3" - loader-utils "^0.2.16" - lodash "^4.17.3" + loader-utils "^1.1.0" + lodash "^4.17.10" pretty-error "^2.0.2" tapable "^1.0.0" - toposort "^1.0.0" util.promisify "1.0.0" htmlparser2@^3.9.1: @@ -4863,15 +4867,6 @@ loader-runner@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.3.0.tgz#f482aea82d543e07921700d5a46ef26fdac6b8a2" -loader-utils@^0.2.16: - version "0.2.17" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348" - dependencies: - big.js "^3.1.3" - emojis-list "^2.0.0" - json5 "^0.5.0" - object-assign "^4.0.1" - loader-utils@^1.0.2, loader-utils@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.1.0.tgz#c98aef488bcceda2ffb5e2de646d6a754429f5cd" @@ -4952,7 +4947,7 @@ lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" -lodash@^4.0.1, lodash@^4.13.1, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0: +lodash@^4.0.1, lodash@^4.13.1, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0: version "4.17.10" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"