feat(bazel): simplify ng_package by dropping esm5 and fesm5 (#36944)
esm5 and fesm5 are no longer needed and have been deprecated in the past. https://v9.angular.io/guide/deprecations#esm5-and-fesm5-code-formats-in-angular-npm-packages This commit modifies ng_package to no longer distribute these two formats in npm packages built by ng_package (e.g. @angular/core). This commit intentionally doesn't fully clean up the ng_package rule to remove all traces of esm5 and fems5 build artifacts as that is a bigger cleanup and currently we are narrowing down the scope of this change to the MVP needed for v10, which in this case is 'do not put esm5 and fesm5' into the npm packages. More cleanup to follow: https://angular-team.atlassian.net/browse/FW-2143 BREAKING CHANGE: esm5 and fesm5 format is no longer distributed in Angular's npm packages e.g. @angular/core If you are not using Angular CLI to build your application or library, and you need to be able to build es5 artifacts, then you will need to downlevel the distributed Angular code to es5 on your own. Angular CLI will automatically downlevel the code to es5 if differential loading is enabled in the Angular project, so no action is required from Angular CLI users. PR Close #36944
This commit is contained in:

committed by
Alex Rickabaugh

parent
fafa50d97f
commit
9dbb30f884
@ -5,8 +5,8 @@ const Terser = require('terser');
|
||||
const GLOBAL_DEFS_FOR_TERSER = require('@angular/compiler-cli').GLOBAL_DEFS_FOR_TERSER;
|
||||
|
||||
const outputPath = resolve(__dirname, './core.min.js');
|
||||
const pathToCoreFesm5 = resolve(__dirname, './node_modules/@angular/core/fesm5/core.js');
|
||||
const coreFesm5Content = readFileSync(pathToCoreFesm5, 'utf8');
|
||||
const pathToCoreFesm2015 = resolve(__dirname, './node_modules/@angular/core/fesm2015/core.js');
|
||||
const coreFesm2015Content = readFileSync(pathToCoreFesm2015, 'utf8');
|
||||
// Ensure that Terser global_defs exported by compiler-cli work.
|
||||
const terserOpts = {
|
||||
compress: {
|
||||
@ -14,7 +14,7 @@ const terserOpts = {
|
||||
global_defs: GLOBAL_DEFS_FOR_TERSER
|
||||
}
|
||||
};
|
||||
const result = Terser.minify(coreFesm5Content, terserOpts);
|
||||
const result = Terser.minify(coreFesm2015Content, terserOpts);
|
||||
writeFileSync(outputPath, result.code);
|
||||
|
||||
for (const def of Object.keys(GLOBAL_DEFS_FOR_TERSER)) {
|
||||
@ -22,4 +22,4 @@ for (const def of Object.keys(GLOBAL_DEFS_FOR_TERSER)) {
|
||||
throw `'${def}' should have been removed from core bundle, but was still there.\n` +
|
||||
`See output at ${outputPath}.`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user