protobufjs v8 reads TextDecoder at import time, and Hermes does not provide it. The polyfill assignment in index.js ran after hoisted imports, so the app crashed on launch with 'Property TextDecoder doesn't exist'. Move the polyfills into their own module imported first so they are installed before any other module executes.
14 lines
598 B
JavaScript
14 lines
598 B
JavaScript
// Global polyfills that must be installed before any other module loads.
|
|
// Hermes has no TextEncoder/TextDecoder, and protobufjs v8+ reads
|
|
// TextDecoder at import time, so this module must be the first import
|
|
// in index.js — imports are hoisted, so assigning these globals from
|
|
// index.js's own body runs too late.
|
|
const TextEncodingPolyfill = require('text-encoding');
|
|
|
|
if (typeof global.TextEncoder === 'undefined') {
|
|
global.TextEncoder = TextEncodingPolyfill.TextEncoder;
|
|
}
|
|
if (typeof global.TextDecoder === 'undefined') {
|
|
global.TextDecoder = TextEncodingPolyfill.TextDecoder;
|
|
}
|