Skip to content

Commit

Permalink
fix(core): disable tsickle pass when producing APF packages
Browse files Browse the repository at this point in the history
As of TypeScript 3.9, the tsc emit is not compatible with Closure
Compiler due to
microsoft/TypeScript#32011.

There is some hope that this will be fixed by a solution like the one
proposed in
microsoft/TypeScript#38374 but currently it's
unclear if / when that will
happen.

Since the Closure support has been somewhat already broken, and the
tsickle pass has been a source
of headaches for some time for Angular packages, we are removing it for
now while we rethink our
strategy to make Angular Closure compatible outside of Google.

This change has no affect on our Closure compatibility within Google
which work well because all the
code is compiled from sources and passed through tsickle.

This change only disables the tsickle pass but doesn't remove it.

A follow up PR should either remove all the traces of tscikle or
re-enable the fixed version.

BREAKING CHANGE: Angular npm packages no longer contain jsdoc comments
to support Closure Compiler's advanced optimizations

The support for Closure compiler in Angular packages has been
experimental and broken for quite some
time.

As of TS3.9 Closure is unusable with the JavaScript emit. Please follow
microsoft/TypeScript#38374 for more
information and updates.

If you used Closure compiler with Angular in the past, you will likely
be better off consuming
Angular packages built from sources directly rather than consuming the
version we publish on npm
which is primarily optimized for Webpack/Rollup + Terser build pipeline.

As a temporary workaround you might consider using your current build
pipeline with Closure flag
`--compilation_level=SIMPLE`. This flag will ensure that your build
pipeline produces buildable and
runnable artifacts, at the cost of increased payload size due to
advanced optimizations being
disabled.
  • Loading branch information
IgorMinar committed May 21, 2020
1 parent 6ca3fb1 commit 3f7c5c4
Show file tree
Hide file tree
Showing 28 changed files with 1,019 additions and 2,371 deletions.
2 changes: 1 addition & 1 deletion goldens/size-tracking/aio-payloads.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"master": {
"uncompressed": {
"runtime-es2015": 3097,
"main-es2015": 430367,
"main-es2015": 429710,
"polyfills-es2015": 52195
}
}
Expand Down
15 changes: 8 additions & 7 deletions goldens/size-tracking/integration-payloads.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 143315,
"polyfills-es2015": 36657
"main-es2015": 142590,
"polyfills-es2015": 36963
}
}
},
Expand All @@ -21,17 +21,17 @@
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 149436,
"polyfills-es2015": 36657
"main-es2015": 148510,
"polyfills-es2015": 36963
}
}
},
"cli-hello-world-ivy-i18n": {
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 138866,
"polyfills-es2015": 37334
"main-es2015": 138196,
"polyfills-es2015": 37640
}
}
},
Expand Down Expand Up @@ -61,7 +61,8 @@
"bundle": "TODO(i): temporarily increase the payload size limit from 105779 - this is due to a closure issue related to ESM reexports that still needs to be investigated",
"bundle": "TODO(i): we should define ngDevMode to false in Closure, but --define only works in the global scope.",
"bundle": "TODO(i): (FW-2164) TS 3.9 new class shape seems to have broken Closure in big ways. The size went from 169991 to 252338",
"bundle": 252338
"bundle": "TODO(i): after removal of tsickle from ngc-wrapped / ng_package, we had to switch to SIMPLE optimizations which increased the size from 252338 to 1218969, see PR#37221 for more info",
"bundle": 1218969
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion integration/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load(":angular_integration_test.bzl", "angular_integration_test")
#
# Where `ng e2e` is used we pass `ng e2e --port 0` which prompts the cli
# to select a random free port for the the e2e test. The protractor.conf is
# automaticaly updated to use this port.
# automatically updated to use this port.
#
# Karma automatically finds a free port so no effort is needed there.
#
Expand Down
1 change: 1 addition & 0 deletions integration/angular_integration_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ load("//tools/npm_integration_test:npm_integration_test.bzl", "npm_integration_t
NPM_PACKAGE_ARCHIVES = [
"check-side-effects",
"core-js",
"google-closure-compiler",
"jasmine",
"typescript",
"rxjs",
Expand Down
26 changes: 11 additions & 15 deletions integration/hello_world__closure/closure.conf
Original file line number Diff line number Diff line change
@@ -1,40 +1,36 @@
--compilation_level=ADVANCED_OPTIMIZATIONS
--language_out=ES5
--compilation_level=SIMPLE
--language_in=ECMASCRIPT_2015
--language_out=ECMASCRIPT_2015
--js_output_file=dist/bundle.js
--output_manifest=dist/manifest.MF
--variable_renaming_report=dist/variable_renaming_report
--property_renaming_report=dist/property_renaming_report
--create_source_map=%outname%.map

--warning_level=QUIET
--dependency_mode=STRICT
--dependency_mode=PRUNE
--rewrite_polyfills=false
--jscomp_off=checkVars

--module_resolution=node
--package_json_entry_names es2015,module

node_modules/zone.js/dist/zone_externs.js

--js node_modules/tslib/package.json
--js node_modules/tslib/**.js

--js node_modules/rxjs/package.json
--js node_modules/rxjs/_esm2015/index.js
--js node_modules/rxjs/_esm2015/internal/**.js
--js node_modules/rxjs/operators/package.json
--js node_modules/rxjs/_esm2015/operators/index.js

--js node_modules/@angular/compiler/package.json
--js node_modules/@angular/compiler/fesm2015/compiler.js
--js node_modules/rxjs/**.js

--js node_modules/@angular/core/package.json
--js node_modules/@angular/core/fesm2015/core.js
--js node_modules/@angular/core/src/testability/testability.externs.js

--js node_modules/@angular/common/package.json
--js node_modules/@angular/common/fesm2015/common.js

--js node_modules/@angular/platform-browser/package.json
--js node_modules/@angular/platform-browser/fesm2015/platform-browser.js

--module_resolution=node
--package_json_entry_names es2015
--process_common_js_modules

--js built/**.js
--entry_point=built/src/main
8 changes: 4 additions & 4 deletions integration/hello_world__closure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
"version": "0.0.0",
"license": "MIT",
"dependencies": {
"@angular/animations": "file:../../dist/packages-dist/animations",
"@angular/common": "file:../../dist/packages-dist/common",
"@angular/compiler": "file:../../dist/packages-dist/compiler",
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli",
"@angular/core": "file:../../dist/packages-dist/core",
"@angular/elements": "file:../../dist/packages-dist/elements",
"@angular/platform-browser": "file:../../dist/packages-dist/platform-browser",
"@angular/platform-server": "file:../../dist/packages-dist/platform-server",
"google-closure-compiler": "20180716.0.0",
"rxjs": "file:../../node_modules/rxjs",
"typescript": "file:../../node_modules/typescript",
"tslib": "file:../../node_modules/tslib",
"zone.js": "file:../../dist/zone.js-dist/zone.js"
},
"devDependencies": {
"@types/jasmine": "file:../../node_modules/@types/jasmine",
"@types/jasminewd2": "file:../../node_modules/@types/jasminewd2",
"concurrently": "3.4.0",
"google-closure-compiler": "file:../../node_modules/google-closure-compiler",
"lite-server": "2.2.2",
"protractor": "file:../../node_modules/protractor",
"puppeteer": "file:../../node_modules/puppeteer",
Expand All @@ -29,7 +29,7 @@
"**/webdriver-manager": "file:../../node_modules/webdriver-manager"
},
"scripts": {
"closure": "java -jar node_modules/google-closure-compiler/compiler.jar --flagfile closure.conf",
"closure": "google-closure-compiler --flagfile closure.conf",
"build": "cd .",
"test": "ngc && yarn run closure && concurrently \"yarn run serve\" \"yarn run protractor\" --kill-others --success first",
"serve": "lite-server -c e2e/browser.config.json",
Expand Down
Loading

0 comments on commit 3f7c5c4

Please sign in to comment.