fix(hermes): wrap registerOnGlobalContext() in try-catch

This commit is contained in:
shirakaba
2023-12-02 11:47:00 +09:00
parent e04e9b6909
commit 054f63bd3b

View File

@ -15,6 +15,7 @@ interface ExtensionMap {
}
function registerOnGlobalContext(moduleName: string, exportName: string): void {
try {
Object.defineProperty(global, exportName, {
get: function () {
// 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,
});
} catch (_e) {
// TODO: On Hermes, some globals are non-configurable and we cannot override them.
}
}
/**