MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / registerOnGlobalContext

Function registerOnGlobalContext

packages/core/globals/index.ts:271–293  ·  view source on GitHub ↗
(moduleName: string, exportName: string)

Source from the content-addressed store, hash-verified

269 return null;
270};
271function registerOnGlobalContext(moduleName: string, exportName: string): void {
272 if (global[exportName]) {
273 // already registered
274 return;
275 }
276 Object.defineProperty(global, exportName, {
277 get: function () {
278 // We do not need to cache require() call since it is already cached in the runtime.
279 const m = global.loadModule(moduleName);
280
281 // Redefine the property to make sure the above code is executed only once.
282 const resolvedValue = m[exportName];
283 Object.defineProperty(global, exportName, {
284 value: resolvedValue,
285 configurable: true,
286 writable: true,
287 });
288
289 return resolvedValue;
290 },
291 configurable: true,
292 });
293}
294
295export function installPolyfills(moduleName: string, exportNames: string[]) {
296 const shouldInstallEagerly = global.__snapshot || !__COMMONJS__;

Callers 1

installPolyfillsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected