-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MMM + SES: TypeError (0, _getPrototypeOf2.default) is not a function #24
Comments
the current solution is to disable // node_modules/metro-react-native-babel-preset/src/configs/main.js
// ...
if (!options || options.enableBabelRuntime !== false) {
// Allows configuring a specific runtime version to optimize output
const isVersion =
typeof (options === null || options === void 0
? void 0
: options.enableBabelRuntime) === "string";
extraPlugins.push([
require("@babel/plugin-transform-runtime"),
{
helpers: false, // default: true
regenerator: !isHermes,
...(isVersion && {
version: options.enableBabelRuntime,
}),
},
]);
}
// ... which in turn skips (per file/module) // node_modules/@babel/plugin-transform-runtime/lib/index.js
// ...
pre(file) {
if (!useRuntimeHelpers) return; // early return when false skips the below
file.set("helperGenerator", name => {
if (file.availableHelper && !file.availableHelper(name, runtimeVersion)) {
return;
}
const isInteropHelper = HEADER_HELPERS.indexOf(name) !== -1;
const blockHoist = isInteropHelper && !(0, _helperModuleImports.isModule)(file.path) ? 4 : undefined;
const helpersDir = esModules && file.path.node.sourceType === "module" ? "helpers/esm" : "helpers";
return addDefaultImport(`${modulePath}/${helpersDir}/${name}`, name, blockHoist, true);
});
const cache = new Map();
function addDefaultImport(source, nameHint, blockHoist, isHelper = false) {
const cacheKey = (0, _helperModuleImports.isModule)(file.path);
const key = `${source}:${nameHint}:${cacheKey || ""}`;
let cached = cache.get(key);
if (cached) {
cached = _core.types.cloneNode(cached);
} else {
cached = (0, _helperModuleImports.addDefault)(file.path, source, {
importedInterop: isHelper && supportsCJSDefault ? "compiled" : "uncompiled",
nameHint,
blockHoist
});
cache.set(key, cached);
}
return cached;
}
}
// ... @babel/plugin-transform-runtime is
where the
so with the side effect of increasing codesize (not a big issue) enter vetted shims |
…) and hardenIntrinsics Including eslint exceptions Note with this simple SES vetted implementation (unbaked into RN core), our high priority issue persists (requiring better solution) - LavaMoat/docs#24
- remove SES vetted shims implementation from entry file - bake lockdown into RN - import [email protected] - import reflect-metadata (prior lockdown) - call lockdown (prior polyfillPromise, setUpXHR and setUpTimers) - (preserve polyfillPromise) - update prev doc comments - add detailed doc comments Fix LavaMoat/docs#24 (Fix LavaMoat/docs#25) Fix LavaMoat/docs#26 Next we can improve this implementation further with unreleased [email protected] allowing for reflect-metadata as a vetted shim, rather than called prior lockdown
- remove SES vetted shims implementation from entry file - bake lockdown into RN - import [email protected] - import reflect-metadata (prior lockdown) - call lockdown (prior polyfillPromise, setUpXHR and setUpTimers) - (preserve polyfillPromise) - update prev doc comments - add detailed doc comments Fix LavaMoat/docs#24 (Fix LavaMoat/docs#25) Partially fix LavaMoat/docs#26 (Unreleased) [email protected] is required for the full fix Allowing for reflect-metadata as a vetted shim, rather than called prior lockdown
fixed in MetaMask/metamask-mobile@310defe |
MediaDevices.ts
) leads to otherswhere
runtime.js
is:node_modules/regenerator-runtime/runtime.js
and
asyncToGenerator.js
is:node_modules/@babel/runtime/helpers/asyncToGenerator.js
the cause remains ambiguous, with stack traces pointing to RN error logging internals and after examining the bundle
from the original error msg, the offending babel helper is:
but disabling the babel helper isn't sufficient
nor removing custom: polyfills, babel transforms, metro transforms
The text was updated successfully, but these errors were encountered: