metro-runtime
Advanced tools
Comparing version 0.76.2 to 0.76.3
{ | ||
"name": "metro-runtime", | ||
"version": "0.76.2", | ||
"version": "0.76.3", | ||
"description": "🚇 Module required for evaluating Metro bundles.", | ||
@@ -5,0 +5,0 @@ "main": "src", |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -7,12 +9,38 @@ * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* | ||
* @format | ||
* | ||
* @oncall react_native | ||
*/ | ||
"use strict"; | ||
// $FlowExpectedError Flow does not know about Metro's require extensions. | ||
const dynamicRequire = require; | ||
module.exports = function (moduleID) { | ||
return Promise.resolve().then(() => dynamicRequire.importAll(moduleID)); | ||
const DEFAULT_OPTIONS = { | ||
isPrefetchOnly: false, | ||
}; | ||
async function asyncRequireImpl(moduleID, paths, options) { | ||
const loadBundle = global[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`]; | ||
if (loadBundle != null) { | ||
const stringModuleID = String(moduleID); | ||
if (paths != null) { | ||
const bundlePath = paths[stringModuleID]; | ||
if (bundlePath != null) { | ||
// NOTE: Errors will be swallowed by asyncRequire.prefetch | ||
await loadBundle(bundlePath); | ||
} | ||
} | ||
} | ||
if (!options.isPrefetchOnly) { | ||
return require.importAll(moduleID); | ||
} | ||
return undefined; | ||
} | ||
async function asyncRequire(moduleID, paths, moduleName) { | ||
return asyncRequireImpl(moduleID, paths, DEFAULT_OPTIONS); | ||
} | ||
asyncRequire.prefetch = function (moduleID, paths, moduleName) { | ||
asyncRequireImpl(moduleID, paths, { | ||
isPrefetchOnly: true, | ||
}).then( | ||
() => {}, | ||
() => {} | ||
); | ||
}; | ||
module.exports = asyncRequire; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
87455
1415