Skip to content

Commit

Permalink
fix(zone.js): restore definition of global (#31453)
Browse files Browse the repository at this point in the history
This partially reverts some changes from angular/zone.js@71b9371#diff-dd469785fca8680a5b33b1e81c5cfd91R1420
These broke the g3sync of zone.js because we use the output of the TypeScript compiler directly, rather than rely on the rollup commonjs plugin to define the global symbol

PR Close #31453
  • Loading branch information
alexeagle authored and jasonaden committed Jul 9, 2019
1 parent 6aaca21 commit e6f1b04
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 6 deletions.
3 changes: 3 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
Expand Down
2 changes: 1 addition & 1 deletion packages/zone.js/lib/jasmine/jasmine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,4 @@
};
return ZoneQueueRunner;
})(QueueRunner);
})(global);
})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);
2 changes: 1 addition & 1 deletion packages/zone.js/lib/mocha/mocha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 1 addition & 1 deletion packages/zone.js/lib/zone-spec/async-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 1 addition & 1 deletion packages/zone.js/lib/zone-spec/fake-async-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 1 addition & 1 deletion packages/zone.js/lib/zone-spec/wtf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@
}

(Zone as any)['wtfZoneSpec'] = !wtfEnabled ? null : new WtfZoneSpec();
})(global);
})(typeof window === 'object' && window || typeof self === 'object' && self || global);
2 changes: 1 addition & 1 deletion packages/zone.js/lib/zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
15 changes: 15 additions & 0 deletions tools/rollup_bundle_commonjs_ignoreGlobal.patch
Original file line number Diff line number Diff line change
@@ -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,

0 comments on commit e6f1b04

Please sign in to comment.