mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
fix(hermes): wrap registerOnGlobalContext() in try-catch
This commit is contained in:
@ -15,6 +15,7 @@ interface ExtensionMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function registerOnGlobalContext(moduleName: string, exportName: string): void {
|
function registerOnGlobalContext(moduleName: string, exportName: string): void {
|
||||||
|
try {
|
||||||
Object.defineProperty(global, exportName, {
|
Object.defineProperty(global, exportName, {
|
||||||
get: function () {
|
get: function () {
|
||||||
// We do not need to cache require() call since it is already cached in the runtime.
|
// We do not need to cache require() call since it is already cached in the runtime.
|
||||||
@ -32,6 +33,9 @@ function registerOnGlobalContext(moduleName: string, exportName: string): void {
|
|||||||
},
|
},
|
||||||
configurable: true,
|
configurable: true,
|
||||||
});
|
});
|
||||||
|
} catch (_e) {
|
||||||
|
// TODO: On Hermes, some globals are non-configurable and we cannot override them.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user