Skip to content

Commit 51e4eaa

Browse files
committed
fix(@angular-devkit/build-angular): downlevel with non-loose ECMA compliance
This ensures that the ES5 bundles operate consistently with the ES2015+ bundles. Fixes angular#15673
1 parent 6cb9f4d commit 51e4eaa

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

packages/angular_devkit/build_angular/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@angular-devkit/build-webpack": "0.0.0",
1313
"@angular-devkit/core": "0.0.0",
1414
"@babel/core": "7.6.2",
15+
"@babel/plugin-proposal-class-properties": "7.5.5",
1516
"@babel/preset-env": "7.6.2",
1617
"@ngtools/webpack": "0.0.0",
1718
"ajv": "6.10.2",

packages/angular_devkit/build_angular/src/utils/process-bundle.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,16 @@ async function processWorker(options: ProcessBundleOptions): Promise<void> {
6464
filename: options.filename,
6565
inputSourceMap: !manualSourceMaps && options.map !== undefined && JSON.parse(options.map),
6666
babelrc: false,
67+
// Note: plugins are executed before presets
68+
plugins: [
69+
// `loose` mode uses assignment instead of definition for class properties
70+
// This is technically not spec compliant but results in smaller (potentially faster) code
71+
// Further details: https://2ality.com/2012/08/property-definition-assignment.html
72+
['@babel/plugin-proposal-class-properties', { loose: true }],
73+
],
6774
// modules aren't needed since the bundles use webpacks custom module loading
68-
// loose generates more ES5-like code but does not strictly adhere to the ES2015 spec (Typescript is loose)
6975
// 'transform-typeof-symbol' generates slower code
70-
presets: [
71-
['@babel/preset-env', { modules: false, loose: true, exclude: ['transform-typeof-symbol'] }],
72-
],
76+
presets: [['@babel/preset-env', { modules: false, exclude: ['transform-typeof-symbol'] }]],
7377
minified: true,
7478
sourceMaps: options.sourceMaps,
7579
});

yarn.lock

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,18 @@
183183
"@babel/traverse" "^7.4.4"
184184
"@babel/types" "^7.4.4"
185185

186+
"@babel/helper-create-class-features-plugin@^7.5.5":
187+
version "7.6.0"
188+
resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.6.0.tgz#769711acca889be371e9bc2eb68641d55218021f"
189+
integrity sha512-O1QWBko4fzGju6VoVvrZg0RROCVifcLxiApnGP3OWfWzvxRZFCoBD81K5ur5e3bVY2Vf/5rIJm8cqPKn8HUJng==
190+
dependencies:
191+
"@babel/helper-function-name" "^7.1.0"
192+
"@babel/helper-member-expression-to-functions" "^7.5.5"
193+
"@babel/helper-optimise-call-expression" "^7.0.0"
194+
"@babel/helper-plugin-utils" "^7.0.0"
195+
"@babel/helper-replace-supers" "^7.5.5"
196+
"@babel/helper-split-export-declaration" "^7.4.4"
197+
186198
"@babel/helper-define-map@^7.5.5":
187199
version "7.5.5"
188200
resolved "https://registry.yarnpkg.com/@babel/helper-define-map/-/helper-define-map-7.5.5.tgz#3dec32c2046f37e09b28c93eb0b103fd2a25d369"
@@ -351,6 +363,14 @@
351363
"@babel/helper-remap-async-to-generator" "^7.1.0"
352364
"@babel/plugin-syntax-async-generators" "^7.2.0"
353365

366+
367+
version "7.5.5"
368+
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.5.5.tgz#a974cfae1e37c3110e71f3c6a2e48b8e71958cd4"
369+
integrity sha512-AF79FsnWFxjlaosgdi421vmYG6/jg79bVD0dpD44QdgobzHKuLZ6S3vl8la9qIeSwGi8i1fS0O1mfuDAAdo1/A==
370+
dependencies:
371+
"@babel/helper-create-class-features-plugin" "^7.5.5"
372+
"@babel/helper-plugin-utils" "^7.0.0"
373+
354374
"@babel/plugin-proposal-dynamic-import@^7.5.0":
355375
version "7.5.0"
356376
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.5.0.tgz#e532202db4838723691b10a67b8ce509e397c506"
@@ -8886,7 +8906,6 @@ sauce-connect-launcher@^1.2.4:
88868906

88878907
"sauce-connect-proxy@https://saucelabs.com/downloads/sc-4.5.4-linux.tar.gz":
88888908
version "0.0.0"
8889-
uid dc5efcd2be24ddb099a85b923d6e754754651fa8
88908909
resolved "https://saucelabs.com/downloads/sc-4.5.4-linux.tar.gz#dc5efcd2be24ddb099a85b923d6e754754651fa8"
88918910

88928911
saucelabs@^1.5.0:

0 commit comments

Comments
 (0)