问题
Is there any options to prevent new feature of angular 8 to divide bundles for old browsers? Because it takes double time for build which is very long.
回答1:
Check out the docs on differential build/loading:
The Angular CLI handles differential loading for you as part of the build process for deployment. The ng build command produces the necessary bundles used for differential loading, based on your browser support requirements and compilation target.
The Angular CLI uses two configurations for differential loading:
Browsers list The browserslist configuration file is included in your application project structure and provides the minimum browsers your application supports. See the Browserslist spec for complete configuration options.
TypeScript configuration In the TypeScript configuration file, tsconfig.json, the target in the compilerOptions section determines the ECMAScript target version that the code is compiled to. Modern browsers support ES2015 natively, while ES5 is more commonly used to support legacy browsers.
By default, legacy browsers such as IE 9-11 are ignored, and the compilation target is ES2015. As a result, this produces two builds, and differential loading is enabled. If you ignore browsers without ES2015 support, a single build is produced.
There is also a section to opt out:
Opting out of differential loading
Differential loading can be explicitly disabled if it causes unexpected issues or you need to target ES5 specifically for legacy browser support.
To explicitly disable differential loading:
Enable the dead or IE browsers in the browserslist config file by removing the not keyword in front of them. Set the target in the compilerOptions to es5.
回答2:
You can simply Switch back to es5 from es2015 as compilation target in your tsconfig.json.
"compilerOptions": {
...
"target":"es5",
...
}
来源:https://stackoverflow.com/questions/56736447/how-to-stop-differential-build-in-angular-8