diff --git a/WORKSPACE b/WORKSPACE index cec3c44a63..ecac00d56e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -18,6 +18,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # Fetch rules_nodejs so we can install our npm dependencies http_archive( name = "build_bazel_rules_nodejs", + patch_args = ["-p1"], + # Patch https://github.com/bazelbuild/rules_nodejs/pull/903 + patches = ["//tools:rollup_bundle_commonjs_ignoreGlobal.patch"], sha256 = "6d4edbf28ff6720aedf5f97f9b9a7679401bf7fca9d14a0fff80f644a99992b4", urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.32.2/rules_nodejs-0.32.2.tar.gz"], ) diff --git a/packages/zone.js/lib/jasmine/jasmine.ts b/packages/zone.js/lib/jasmine/jasmine.ts index 2b6ed863f0..964caeefab 100644 --- a/packages/zone.js/lib/jasmine/jasmine.ts +++ b/packages/zone.js/lib/jasmine/jasmine.ts @@ -299,4 +299,4 @@ }; return ZoneQueueRunner; })(QueueRunner); -})(global); +})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); diff --git a/packages/zone.js/lib/mocha/mocha.ts b/packages/zone.js/lib/mocha/mocha.ts index c3c6d13a17..d677d531a1 100644 --- a/packages/zone.js/lib/mocha/mocha.ts +++ b/packages/zone.js/lib/mocha/mocha.ts @@ -158,4 +158,4 @@ return originalRun.call(this, fn); }; })(Mocha.Runner.prototype.runTest, Mocha.Runner.prototype.run); -})(global); +})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); diff --git a/packages/zone.js/lib/zone-spec/async-test.ts b/packages/zone.js/lib/zone-spec/async-test.ts index 071502107d..b0fc4c2b79 100644 --- a/packages/zone.js/lib/zone-spec/async-test.ts +++ b/packages/zone.js/lib/zone-spec/async-test.ts @@ -146,4 +146,4 @@ // Export the class so that new instances can be created with proper // constructor params. (Zone as any)['AsyncTestZoneSpec'] = AsyncTestZoneSpec; -})(global); +})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); diff --git a/packages/zone.js/lib/zone-spec/fake-async-test.ts b/packages/zone.js/lib/zone-spec/fake-async-test.ts index 408dae56ab..9a55158f32 100644 --- a/packages/zone.js/lib/zone-spec/fake-async-test.ts +++ b/packages/zone.js/lib/zone-spec/fake-async-test.ts @@ -557,4 +557,4 @@ // Export the class so that new instances can be created with proper // constructor params. (Zone as any)['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; -})(global); +})(typeof window === 'object' && window || typeof self === 'object' && self || global); diff --git a/packages/zone.js/lib/zone-spec/wtf.ts b/packages/zone.js/lib/zone-spec/wtf.ts index fd46712713..7da91d744d 100644 --- a/packages/zone.js/lib/zone-spec/wtf.ts +++ b/packages/zone.js/lib/zone-spec/wtf.ts @@ -158,4 +158,4 @@ } (Zone as any)['wtfZoneSpec'] = !wtfEnabled ? null : new WtfZoneSpec(); -})(global); +})(typeof window === 'object' && window || typeof self === 'object' && self || global); diff --git a/packages/zone.js/lib/zone.ts b/packages/zone.js/lib/zone.ts index 2ba94f3b8c..69f7a7c1ef 100644 --- a/packages/zone.js/lib/zone.ts +++ b/packages/zone.js/lib/zone.ts @@ -1401,4 +1401,4 @@ const Zone: ZoneType = (function(global: any) { performanceMeasure('Zone', 'Zone'); return global['Zone'] = Zone; -})(global); +})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); diff --git a/tools/rollup_bundle_commonjs_ignoreGlobal.patch b/tools/rollup_bundle_commonjs_ignoreGlobal.patch new file mode 100644 index 0000000000..5a0ebecd8b --- /dev/null +++ b/tools/rollup_bundle_commonjs_ignoreGlobal.patch @@ -0,0 +1,15 @@ +diff --git a/internal/rollup/rollup.config.js b/internal/rollup/rollup.config.js +index 720b5f6..cbfa99c 100644 +--- a/internal/rollup/rollup.config.js ++++ b/internal/rollup/rollup.config.js +@@ -189,7 +189,9 @@ const config = { + // with the amd plugin. + include: /\.ngfactory\.js$/i, + }), +- commonjs(), ++ commonjs({ ++ ignoreGlobal: true, ++ }), + { + name: 'notResolved', + resolveId: notResolved,