Skip to content

Commit e6f1b04

Browse files
alexeaglejasonaden
authored andcommitted
fix(zone.js): restore definition of global (#31453)
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
1 parent 6aaca21 commit e6f1b04

8 files changed

Lines changed: 24 additions & 6 deletions

File tree

WORKSPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1818
# Fetch rules_nodejs so we can install our npm dependencies
1919
http_archive(
2020
name = "build_bazel_rules_nodejs",
21+
patch_args = ["-p1"],
22+
# Patch https://github.com/bazelbuild/rules_nodejs/pull/903
23+
patches = ["//tools:rollup_bundle_commonjs_ignoreGlobal.patch"],
2124
sha256 = "6d4edbf28ff6720aedf5f97f9b9a7679401bf7fca9d14a0fff80f644a99992b4",
2225
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.32.2/rules_nodejs-0.32.2.tar.gz"],
2326
)

packages/zone.js/lib/jasmine/jasmine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,4 +299,4 @@
299299
};
300300
return ZoneQueueRunner;
301301
})(QueueRunner);
302-
})(global);
302+
})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);

packages/zone.js/lib/mocha/mocha.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,4 @@
158158
return originalRun.call(this, fn);
159159
};
160160
})(Mocha.Runner.prototype.runTest, Mocha.Runner.prototype.run);
161-
})(global);
161+
})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);

packages/zone.js/lib/zone-spec/async-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,4 @@
146146
// Export the class so that new instances can be created with proper
147147
// constructor params.
148148
(Zone as any)['AsyncTestZoneSpec'] = AsyncTestZoneSpec;
149-
})(global);
149+
})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);

packages/zone.js/lib/zone-spec/fake-async-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,4 +557,4 @@
557557
// Export the class so that new instances can be created with proper
558558
// constructor params.
559559
(Zone as any)['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec;
560-
})(global);
560+
})(typeof window === 'object' && window || typeof self === 'object' && self || global);

packages/zone.js/lib/zone-spec/wtf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,4 @@
158158
}
159159

160160
(Zone as any)['wtfZoneSpec'] = !wtfEnabled ? null : new WtfZoneSpec();
161-
})(global);
161+
})(typeof window === 'object' && window || typeof self === 'object' && self || global);

packages/zone.js/lib/zone.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,4 +1401,4 @@ const Zone: ZoneType = (function(global: any) {
14011401

14021402
performanceMeasure('Zone', 'Zone');
14031403
return global['Zone'] = Zone;
1404-
})(global);
1404+
})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/internal/rollup/rollup.config.js b/internal/rollup/rollup.config.js
2+
index 720b5f6..cbfa99c 100644
3+
--- a/internal/rollup/rollup.config.js
4+
+++ b/internal/rollup/rollup.config.js
5+
@@ -189,7 +189,9 @@ const config = {
6+
// with the amd plugin.
7+
include: /\.ngfactory\.js$/i,
8+
}),
9+
- commonjs(),
10+
+ commonjs({
11+
+ ignoreGlobal: true,
12+
+ }),
13+
{
14+
name: 'notResolved',
15+
resolveId: notResolved,

0 commit comments

Comments
 (0)