MCPcopy Index your code
hub / github.com/angular/angular / loadZone

Function loadZone

packages/zone.js/lib/zone.ts:65–84  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

63}
64
65export function loadZone(): ZoneType {
66 // if global['Zone'] already exists (maybe zone.js was already loaded or
67 // some other lib also registered a global object named Zone), we may need
68 // to throw an error, but sometimes user may not want this error.
69 // For example,
70 // we have two web pages, page1 includes zone.js, page2 doesn't.
71 // and the 1st time user load page1 and page2, everything work fine,
72 // but when user load page2 again, error occurs because global['Zone'] already exists.
73 // so we add a flag to let user choose whether to throw this error or not.
74 // By default, if existing Zone is from zone.js, we will not throw the error.
75 const global = globalThis as any;
76 const checkDuplicate = global[__symbol__('forceDuplicateZoneCheck')] === true;
77 if (global['Zone'] && (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function')) {
78 throw new Error('Zone already loaded.');
79 }
80
81 // Initialize global `Zone` constant.
82 global['Zone'] ??= initZone();
83 return global['Zone'];
84}

Callers 5

rollup-main.tsFile · 0.90
rollup-mix.tsFile · 0.90
rollupMainFunction · 0.90

Calls 2

__symbol__Function · 0.90
initZoneFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…