diff --git a/packages/zone.js/BUILD.bazel b/packages/zone.js/BUILD.bazel index e93eab0e55..6edfc81a37 100644 --- a/packages/zone.js/BUILD.bazel +++ b/packages/zone.js/BUILD.bazel @@ -6,8 +6,7 @@ package(default_visibility = ["//visibility:public"]) exports_files([ "tsconfig.json", - "rollup-es5.config.js", - "rollup-es5_global-es2015.config.js", + "rollup.config.js", ]) genrule( diff --git a/packages/zone.js/bundles.bzl b/packages/zone.js/bundles.bzl index 6e2c1d3746..90fec738b9 100644 --- a/packages/zone.js/bundles.bzl +++ b/packages/zone.js/bundles.bzl @@ -9,139 +9,105 @@ BUNDLES_ENTRY_POINTS = { "zone": { "es5": _DIR + "browser/rollup-legacy-main", "es2015": _DIR + "browser/rollup-main", - "rollup": "global-es2015", }, "zone-mix": { "entrypoint": _DIR + "mix/rollup-mix", - "rollup": "global-es2015", }, "zone-node": { "entrypoint": _DIR + "node/rollup-main", - "rollup": "global-es2015", }, "async-test": { "entrypoint": _DIR + "testing/async-testing", - "rollup": "es5", }, "fake-async-test": { "entrypoint": _DIR + "testing/fake-async", - "rollup": "es5", }, "long-stack-trace-zone": { "entrypoint": _DIR + "zone-spec/long-stack-trace", - "rollup": "es5", }, "proxy": { "entrypoint": _DIR + "zone-spec/proxy", - "rollup": "es5", }, "zone-patch-rxjs-fake-async": { "entrypoint": _DIR + "zone-spec/proxy", - "rollup": "es5", }, "sync-test": { "entrypoint": _DIR + "zone-spec/sync-test", - "rollup": "es5", }, "task-tracking": { "entrypoint": _DIR + "zone-spec/task-tracking", - "rollup": "es5", }, "wtf": { "entrypoint": _DIR + "zone-spec/wtf", - "rollup": "es5", }, "zone-error": { "entrypoint": _DIR + "common/error-rewrite", - "rollup": "es5", }, "zone-legacy": { "entrypoint": _DIR + "browser/browser-legacy", - "rollup": "es5", }, "zone-bluebird": { "entrypoint": _DIR + "extra/bluebird", - "rollup": "es5", }, "zone-patch-canvas": { "entrypoint": _DIR + "browser/canvas", - "rollup": "es5", }, "zone-patch-cordova": { "entrypoint": _DIR + "extra/cordova", - "rollup": "es5", }, "zone-patch-electron": { "entrypoint": _DIR + "extra/electron", - "rollup": "es5", }, "zone-patch-fetch": { "entrypoint": _DIR + "common/fetch", - "rollup": "es5", }, "jasmine-patch": { "entrypoint": _DIR + "jasmine/jasmine", - "rollup": "es5", }, "zone-patch-jsonp": { "entrypoint": _DIR + "extra/jsonp", - "rollup": "es5", }, "webapis-media-query": { "entrypoint": _DIR + "browser/webapis-media-query", - "rollup": "es5", }, "mocha-patch": { "entrypoint": _DIR + "mocha/mocha", - "rollup": "es5", }, "webapis-notification": { "entrypoint": _DIR + "browser/webapis-notification", - "rollup": "es5", }, "zone-patch-promise-test": { "entrypoint": _DIR + "testing/promise-testing", - "rollup": "es5", }, "zone-patch-resize-observer": { "entrypoint": _DIR + "browser/webapis-resize-observer", - "rollup": "es5", }, "webapis-rtc-peer-connection": { "entrypoint": _DIR + "browser/webapis-rtc-peer-connection", - "rollup": "es5", }, "zone-patch-rxjs": { "entrypoint": _DIR + "rxjs/rxjs", - "rollup": "es5", }, "webapis-shadydom": { "entrypoint": _DIR + "browser/shadydom", - "rollup": "es5", }, "zone-patch-socket-io": { "entrypoint": _DIR + "extra/socket-io", - "rollup": "es5", }, "zone-patch-message-port": { "entrypoint": _DIR + "browser/message-port", - "rollup": "es5", }, "zone-patch-user-media": { "entrypoint": _DIR + "browser/webapis-user-media", - "rollup": "es5", }, "zone-testing": { "entrypoint": _DIR + "testing/zone-testing", - "rollup": "es5", }, "zone-testing-bundle": { "es5": _DIR + "browser/rollup-legacy-test-main", "es2015": _DIR + "browser/rollup-test-main", - "rollup": "global-es2015", }, "zone-testing-node-bundle": { "entrypoint": _DIR + "node/rollup-test-main", - "rollup": "global-es2015", }, } diff --git a/packages/zone.js/rollup-es5_global-es2015.config.js b/packages/zone.js/rollup-es5_global-es2015.config.js deleted file mode 100644 index 583820b58b..0000000000 --- a/packages/zone.js/rollup-es5_global-es2015.config.js +++ /dev/null @@ -1,40 +0,0 @@ -const node = require('rollup-plugin-node-resolve'); -const commonjs = require('rollup-plugin-commonjs'); - -// Parse the stamp file produced by Bazel from the version control system -let version = ''; -if (bazel_stamp_file) { - const versionTag = require('fs') - .readFileSync(bazel_stamp_file, {encoding: 'utf-8'}) - .split('\n') - .find(s => s.startsWith('BUILD_SCM_VERSION')); - // Don't assume BUILD_SCM_VERSION exists - if (versionTag) { - version = versionTag.split(' ')[1].trim(); - } -} - -// Add 'use strict' to the bundle, https://github.com/angular/angular/pull/40456 -// When rollup build esm bundle of zone.js, there will be no 'use strict' -// since all esm bundles are `strict`, but when webpack load the esm bundle, -// because zone.js is a module without export and import, webpack is unable -// to determine the bundle is `esm` module or not, so it doesn't add the 'use strict' -// which webpack does to all other `esm` modules which has export or import. -// And it causes issues such as https://github.com/angular/angular/issues/40215 -// `this` should be `undefined` but is assigned with `Window` instead. -const banner = `'use strict'; -/** - * @license Angular v${version} - * (c) 2010-2020 Google LLC. https://angular.io/ - * License: MIT -*/`; - -module.exports = { - plugins: [ - node({ - mainFields: ['es2015', 'module', 'jsnext:main', 'main'], - }), - commonjs(), - ], - output: {name: 'Zone', banner}, -} diff --git a/packages/zone.js/rollup-es5.config.js b/packages/zone.js/rollup.config.js similarity index 99% rename from packages/zone.js/rollup-es5.config.js rename to packages/zone.js/rollup.config.js index 09f9360901..9e7ba9e80d 100644 --- a/packages/zone.js/rollup-es5.config.js +++ b/packages/zone.js/rollup.config.js @@ -27,7 +27,7 @@ const banner = `'use strict'; * @license Angular v${version} * (c) 2010-2020 Google LLC. https://angular.io/ * License: MIT -*/`; + */`; module.exports = { plugins: [ diff --git a/packages/zone.js/test/karma_test.bzl b/packages/zone.js/test/karma_test.bzl index e7220daff5..3cee54a72c 100644 --- a/packages/zone.js/test/karma_test.bzl +++ b/packages/zone.js/test/karma_test.bzl @@ -32,7 +32,7 @@ def karma_test_prepare(name, env_srcs, env_deps, env_entry_point, test_srcs, tes silent = True, sourcemap = "false", entry_point = test_entry_point, - config_file = "//packages/zone.js:rollup-es5.config.js", + config_file = "//packages/zone.js:rollup.config.js", deps = [ ":" + name + "_test", "@npm//rollup-plugin-commonjs", diff --git a/packages/zone.js/tools.bzl b/packages/zone.js/tools.bzl index 11058c72bb..b46dd9ed9e 100644 --- a/packages/zone.js/tools.bzl +++ b/packages/zone.js/tools.bzl @@ -3,11 +3,7 @@ load("//tools:defaults.bzl", "rollup_bundle") def zone_rollup_bundle(module_name, entry_point, rollup_config): - config_file = "" - if rollup_config["rollup"] == "global-es2015": - config_file = "//packages/zone.js:rollup-es5_global-es2015.config.js" - if rollup_config["rollup"] == "es5": - config_file = "//packages/zone.js:rollup-es5.config.js" + config_file = "//packages/zone.js:rollup.config.js" rollup_bundle( name = module_name + "-rollup", config_file = config_file,