Socket
Socket
Sign inDemoInstall

metro

Package Overview
Dependencies
Maintainers
2
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metro - npm Package Compare versions

Comparing version 0.80.5 to 0.80.6

32

package.json
{
"name": "metro",
"version": "0.80.5",
"version": "0.80.6",
"description": "🚇 The JavaScript bundler for React Native.",

@@ -31,3 +31,3 @@ "main": "src/index.js",

"graceful-fs": "^4.2.4",
"hermes-parser": "0.18.2",
"hermes-parser": "0.19.1",
"image-size": "^1.0.2",

@@ -38,14 +38,14 @@ "invariant": "^2.2.4",

"lodash.throttle": "^4.1.1",
"metro-babel-transformer": "0.80.5",
"metro-cache": "0.80.5",
"metro-cache-key": "0.80.5",
"metro-config": "0.80.5",
"metro-core": "0.80.5",
"metro-file-map": "0.80.5",
"metro-resolver": "0.80.5",
"metro-runtime": "0.80.5",
"metro-source-map": "0.80.5",
"metro-symbolicate": "0.80.5",
"metro-transform-plugins": "0.80.5",
"metro-transform-worker": "0.80.5",
"metro-babel-transformer": "0.80.6",
"metro-cache": "0.80.6",
"metro-cache-key": "0.80.6",
"metro-config": "0.80.6",
"metro-core": "0.80.6",
"metro-file-map": "0.80.6",
"metro-resolver": "0.80.6",
"metro-runtime": "0.80.6",
"metro-source-map": "0.80.6",
"metro-symbolicate": "0.80.6",
"metro-transform-plugins": "0.80.6",
"metro-transform-worker": "0.80.6",
"mime-types": "^2.1.27",

@@ -71,4 +71,4 @@ "node-fetch": "^2.2.0",

"jest-snapshot-serializer-raw": "^1.2.0",
"metro-babel-register": "0.80.5",
"metro-memory-fs": "0.80.5",
"metro-babel-register": "0.80.6",
"metro-memory-fs": "0.80.6",
"mock-req": "^0.2.0",

@@ -75,0 +75,0 @@ "mock-res": "^0.6.0",

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -22,4 +11,2 @@

const readFile = denodeify(fs.readFile);
// Test extension against all types supported by image-size module.
// If it's not one of these, we won't treat it as an image.
function isAssetTypeAnImage(type) {

@@ -159,10 +146,5 @@ return (

) {
// If the path of the asset is outside of the projectRoot, we don't want to
// use `path.join` since this will generate an incorrect URL path. In that
// case we just concatenate the publicPath with the relative path.
let assetUrlPath = localPath.startsWith("..")
? publicPath.replace(/\/$/, "") + "/" + path.dirname(localPath)
: path.join(publicPath, path.dirname(localPath));
// On Windows, change backslashes to slashes to get proper URL path from file path.
if (path.sep === "\\") {

@@ -197,3 +179,2 @@ assetUrlPath = assetUrlPath.replaceAll("\\", "/");

const [currentAssetPlugin, ...remainingAssetPlugins] = assetDataPlugins;
// $FlowFixMe: impossible to type a dynamic require.
const assetPluginFunction = require(currentAssetPlugin);

@@ -203,6 +184,2 @@ const resultAssetData = await assetPluginFunction(assetData);

}
/**
* Returns all the associated files (for different resolutions) of an asset.
**/
async function getAssetFiles(assetPath, platform = null) {

@@ -212,14 +189,2 @@ const assetData = await getAbsoluteAssetRecord(assetPath, platform);

}
/**
* Return a buffer with the actual image given a request for an image by path.
* The relativePath can contain a resolution postfix, in this case we need to
* find that image (or the closest one to it's resolution) in one of the
* project roots:
*
* 1. We first parse the directory of the asset
* 2. We then build a map of all assets and their scales in this directory
* 3. Then try to pick platform-specific asset records
* 4. Then pick the closest resolution (rounding up) to the requested one
*/
async function getAsset(

@@ -226,0 +191,0 @@ relativePath,

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -52,9 +41,3 @@

}
async transformFile(
filePath,
transformOptions /** Optionally provide the file contents, this can be used to provide virtual contents for a file. */,
fileBuffer
) {
// We need to be sure that the DependencyGraph has been initialized.
// TODO: Remove this ugly hack!
async transformFile(filePath, transformOptions, fileBuffer) {
await this._depGraph.ready();

@@ -67,4 +50,2 @@ return this._transformer.transformFile(

}
// Waits for the bundler to become ready.
async ready() {

@@ -71,0 +52,0 @@ await this._readyPromise;

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -23,4 +12,2 @@

);
// {...}
const descriptorAst = babylon.parseExpression(

@@ -30,4 +17,2 @@ JSON.stringify(properDescriptor)

const t = babelTypes;
// require('AssetRegistry').registerAsset({...})
const buildRequire = template.statement(`

@@ -50,3 +35,2 @@ module.exports = require(ASSET_REGISTRY_PATH).registerAsset(DESCRIPTOR_AST)

for (const key of blockList) {
// $FlowFixMe[prop-missing]
delete copied[key];

@@ -57,4 +41,2 @@ }

function createRamBundleGroups(ramGroups, groupableModules, subtree) {
// build two maps that allow to lookup module data
// by path or (numeric) module id;
const byPath = new Map();

@@ -66,4 +48,2 @@ const byId = new Map();

});
// build a map of group root IDs to an array of module IDs in the group
const result = new Map(

@@ -75,11 +55,6 @@ ramGroups.map((modulePath) => {

}
return [
root.id,
// `subtree` yields the IDs of all transitive dependencies of a module
new Set(subtree(root, byPath)),
];
return [root.id, new Set(subtree(root, byPath))];
})
);
if (ramGroups.length > 1) {
// build a map of all grouped module IDs to an array of group root IDs
const all = new ArrayMap();

@@ -91,7 +66,4 @@ for (const [parent, children] of result) {

}
// find all module IDs that are part of more than one group
const doubles = filter(all, ([, parents]) => parents.length > 1);
for (const [moduleId, parents] of doubles) {
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
const parentNames = parents.map(byId.get, byId);

@@ -98,0 +70,0 @@ const lastName = parentNames.pop();

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

#!/usr/bin/env node
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";
try {
// $FlowFixMe[untyped-import]
require("metro-babel-register").unstable_registerForMetroMonorepo();

@@ -20,4 +9,2 @@ } catch {}

const yargs = require("yargs");
// $FlowFixMe[unused-promise]
attachMetroCli(yargs.demandCommand(1)).argv;

@@ -11,13 +11,2 @@ "use strict";

}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
function coerceKeyValueArray(keyValueArray) {

@@ -24,0 +13,0 @@ const result = Object.create(null);

@@ -9,13 +9,2 @@ "use strict";

}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
const { makeAsyncCommand } = require("../cli-utils");

@@ -89,4 +78,2 @@ const TerminalReporter = require("../lib/TerminalReporter");

});
// Deprecated
yargs.option("reset-cache", {

@@ -109,4 +96,2 @@ type: "boolean",

};
// Inline require() to avoid circular dependency with ../index
const MetroApi = require("../index");

@@ -113,0 +98,0 @@ await MetroApi.runBuild(config, {

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -27,4 +16,2 @@

}
// $FlowFixMe[cannot-write]
config.cacheStores = [];

@@ -47,6 +34,2 @@ const relativePath = path.relative(

deps.forEach((modulePath) => {
// Temporary hack to disable listing dependencies not under this directory.
// Long term, we need either
// (a) JS code to not depend on anything outside this directory, or
// (b) Come up with a way to declare this dependency in Buck.
const isInsideProjectRoots =

@@ -61,4 +44,3 @@ config.watchFolders.filter((root) => modulePath.startsWith(root)).length >

return args.output != null
? // $FlowFixMe[method-unbinding]
promisify(outStream.end).bind(outStream)()
? promisify(outStream.end).bind(outStream)()
: Promise.resolve();

@@ -65,0 +47,0 @@ }

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -66,9 +55,5 @@

});
// Deprecated
yargs.option("reset-cache", {
type: "boolean",
});
// Examples
yargs.example(

@@ -89,10 +74,6 @@ "secure-server-options",

if (server) {
// eslint-disable-next-line no-console
console.log("Configuration changed. Restarting the server...");
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
await promisify(server.close).call(server);
}
const config = await loadConfig(argv);
// Inline require() to avoid circular dependency with ../index
const MetroApi = require("../index");

@@ -99,0 +80,0 @@ const {

@@ -1,21 +0,4 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";
const DeltaCalculator = require("./DeltaBundler/DeltaCalculator");
/**
* `DeltaBundler` uses the `DeltaTransformer` to build bundle deltas. This
* module handles all the transformer instances so it can support multiple
* concurrent clients requesting their own deltas. This is done through the
* `clientId` param (which maps a client to a specific delta transformer).
*/
class DeltaBundler {

@@ -44,6 +27,2 @@ _deltaCalculators = new Map();

}
// Note: the graph returned by this function needs to be ended when finished
// so that we don't leak graphs that are not reachable.
// To get just the dependencies, use getDependencies which will not leak graphs.
async buildGraph(entryPoints, options) {

@@ -50,0 +29,0 @@ const deltaCalculator = new DeltaCalculator(

@@ -1,18 +0,4 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @oncall react_native
*/
"use strict";
const fs = require("fs");
/**
* Simple hasteImpl that parses @providesModule annotation from JS modules.
*/
module.exports = {

@@ -19,0 +5,0 @@ getHasteName(filename) {

@@ -12,12 +12,2 @@ "use strict";

}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
function resolveDependencies(parentPath, dependencies, resolve) {

@@ -29,8 +19,4 @@ const maybeResolvedDeps = new Map();

const key = dep.data.key;
// `require.context`
const { contextParams } = dep.data;
if (contextParams) {
// Ensure the filepath has uniqueness applied to ensure multiple `require.context`
// statements can be used to target the same file with different properties.
const from = _path.default.join(parentPath, "..", dep.name);

@@ -62,4 +48,2 @@ const absolutePath = (0, _contextModule.deriveAbsolutePathFromContext)(

} catch (error) {
// Ignore unavailable optional dependencies. They are guarded
// with a try-catch block and will be handled during runtime.
if (dep.data.isOptional !== true) {

@@ -78,7 +62,2 @@ throw error;

const resolvedDeps = new Map();
// Return just the dependencies we successfully resolved.
// FIXME: This has a bad bug affecting all dependencies *after* an unresolved
// optional dependency. We'll need to propagate the nulls all the way to the
// serializer and the require() runtime to keep the dependency map from being
// desynced from the contents of the module.
for (const [key, resolvedDep] of maybeResolvedDeps) {

@@ -108,5 +87,2 @@ if (resolvedDep) {

const transformResult = await transform(absolutePath, requireContext);
// Get the absolute path of all sub-dependencies (some of them could have been
// moved but maintain the same relative path).
const resolutionResult = resolveDependencies(

@@ -113,0 +89,0 @@ absolutePath,

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -21,9 +10,2 @@

const { EventEmitter } = require("events");
/**
* This class is in charge of calculating the delta of changed modules that
* happen between calls. To do so, it subscribes to file changes, so it can
* traverse the files that have been changed between calls and avoid having to
* traverse the whole dependency tree for trivial small changes.
*/
class DeltaCalculator extends EventEmitter {

@@ -44,6 +26,2 @@ _deletedFiles = new Set();

}
/**
* Stops listening for file changes and clears all the caches.
*/
end() {

@@ -55,4 +33,2 @@ this._changeEventSource.removeListener(

this.removeAllListeners();
// Clean up all the cache data structures to deallocate memory.
this._graph = new _Graph.Graph({

@@ -66,18 +42,7 @@ entryPoints: this._graph.entryPoints,

}
/**
* Main method to calculate the delta of modules. It returns a DeltaResult,
* which contain the modified/added modules and the removed modules.
*/
async getDelta({ reset, shallow }) {
debug("Calculating delta (reset: %s, shallow: %s)", reset, shallow);
// If there is already a build in progress, wait until it finish to start
// processing a new one (delta server doesn't support concurrent builds).
if (this._currentBuildPromise) {
await this._currentBuildPromise;
}
// We don't want the modified files Set to be modified while building the
// bundle, so we isolate them by using the current instance for the bundling
// and creating a new instance for the file watcher.
const modifiedFiles = this._modifiedFiles;

@@ -91,6 +56,2 @@ this._modifiedFiles = new Set();

this._requiresReset = false;
// Revisit all files if changes require a graph reset - resolutions may be
// invalidated but we don't yet know which. This should be optimized in the
// future.
if (requiresReset) {

@@ -105,6 +66,2 @@ const markModified = (file) => {

}
// Concurrent requests should reuse the same bundling process. To do so,
// this method stores the promise as an instance variable, and then it's
// removed after it gets resolved.
this._currentBuildPromise = this._getChangedDependencies(

@@ -119,6 +76,2 @@ modifiedFiles,

} catch (error) {
// In case of error, we don't want to mark the modified files as
// processed (since we haven't actually created any delta). If we do not
// do so, asking for a delta after an error will produce an empty Delta,
// which is not correct.
modifiedFiles.forEach((file) => this._modifiedFiles.add(file));

@@ -131,4 +84,2 @@ deletedFiles.forEach((file) => this._deletedFiles.add(file));

}
// Return all the modules if the client requested a reset delta.
if (reset) {

@@ -147,14 +98,5 @@ this._graph.reorderGraph({

}
/**
* Returns the graph with all the dependencies. Each module contains the
* needed information to do the traversing (dependencies, inverseDependencies)
* plus some metadata.
*/
getGraph() {
return this._graph;
}
/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
* LTI update could not be added via codemod */
_handleMultipleFileChanges = (changeEvent) => {

@@ -165,8 +107,2 @@ changeEvent.eventsQueue.forEach((eventInfo) => {

};
/**
* Handles a single file change. To avoid doing any work before it's needed,
* the listener only stores the modified file, which will then be used later
* when the delta needs to be calculated.
*/
_handleFileChange = ({ type, filePath, metadata }, logger) => {

@@ -196,7 +132,4 @@ debug("Handling %s: %s (type: %s)", type, filePath, metadata.type);

} else if (type === "add") {
// A deleted+added file is modified
nextState = state === "deleted" ? "modified" : "added";
} else {
// type === 'change'
// An added+modified file is added
nextState = state === "added" ? "added" : "modified";

@@ -223,5 +156,2 @@ }

}
// Notify users that there is a change in some of the bundle files. This
// way the client can choose to refetch the bundle.
this.emit("change", {

@@ -243,5 +173,2 @@ logger,

}
// If a file has been deleted, we want to invalidate any other file that
// depends on it, so we can process it and correctly return an error.
deletedFiles.forEach((filePath) => {

@@ -251,4 +178,2 @@ for (const modifiedModulePath of this._graph.getModifiedModulesForDeletedPath(

)) {
// Only mark the inverse dependency as modified if it's not already
// marked as deleted (in that case we can just ignore it).
if (!deletedFiles.has(modifiedModulePath)) {

@@ -259,10 +184,3 @@ modifiedFiles.add(modifiedModulePath);

});
// NOTE(EvanBacon): This check adds extra complexity so we feature gate it
// to enable users to opt out.
if (this._options.unstable_allowRequireContext) {
// Check if any added or removed files are matched in a context module.
// We only need to do this for added files because (1) deleted files will have a context
// module as an inverse dependency, (2) modified files don't invalidate the contents
// of the context module.
addedFiles.forEach((filePath) => {

@@ -272,9 +190,5 @@ this._graph.markModifiedContextModules(filePath, modifiedFiles);

}
// We only want to process files that are in the bundle.
const modifiedDependencies = Array.from(modifiedFiles).filter((filePath) =>
this._graph.dependencies.has(filePath)
);
// No changes happened. Return empty delta.
if (modifiedDependencies.length === 0) {

@@ -281,0 +195,0 @@ return {

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -19,4 +8,2 @@

const { transformerPath, transformerConfig } = opts.transformerConfig;
// eslint-disable-next-line no-useless-call
const Transformer = require.call(null, transformerPath);

@@ -23,0 +10,0 @@ const transformerKey = Transformer.getCacheKey

@@ -13,38 +13,4 @@ "use strict";

}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
/**
* Portions of this code are based on the Synchronous Cycle Collection
* algorithm described in:
*
* David F. Bacon and V. T. Rajan. 2001. Concurrent Cycle Collection in
* Reference Counted Systems. In Proceedings of the 15th European Conference on
* Object-Oriented Programming (ECOOP '01). Springer-Verlag, Berlin,
* Heidelberg, 207–235.
*
* Notable differences from the algorithm in the paper:
* 1. Our implementation uses the inverseDependencies set (which we already
* have to maintain) instead of a separate refcount variable. A module's
* reference count is equal to the size of its inverseDependencies set, plus
* 1 if it's an entry point of the graph.
* 2. We keep the "root buffer" (possibleCycleRoots) free of duplicates by
* making it a Set, instead of storing a "buffered" flag on each node.
* 3. On top of tracking edges between nodes, we also count references between
* nodes and entries in the importBundleNodes set.
*/
const invariant = require("invariant");
const nullthrows = require("nullthrows");
// TODO: Convert to a Flow enum
function getInternalOptions({ transform, resolve, onProgress, lazy, shallow }) {

@@ -69,4 +35,2 @@ let numProcessed = 0;

#importBundleNodes = new Map();
/// GC state for nodes in the graph (this.dependencies)
#gc = {

@@ -76,4 +40,2 @@ color: new Map(),

};
/** Resolved context parameters from `require.context`. */
#resolvedContexts = new Map();

@@ -84,14 +46,2 @@ constructor(options) {

}
/**
* Dependency Traversal logic for the Delta Bundler. This method calculates
* the modules that should be included in the bundle by traversing the
* dependency graph.
* Instead of traversing the whole graph each time, it just calculates the
* difference between runs by only traversing the added/removed dependencies.
* To do so, it uses the passed graph dependencies and it mutates it.
* The paths parameter contains the absolute paths of the root files that the
* method should traverse. Normally, these paths should be the modified files
* since the last traversal.
*/
async traverseDependencies(paths, options) {

@@ -106,3 +56,2 @@ const internalOptions = getInternalOptions(options);

internalOptions,
// Traverse new or modified paths
(absolutePath) =>

@@ -112,7 +61,2 @@ !this.dependencies.has(absolutePath) ||

);
// If we have errors we might need to roll back any changes - take
// snapshots of all modified modules at the base state. We'll also snapshot
// unmodified modules that become unreachable as they are released, so that
// we have everything we need to restore the graph to base.
if (delta.errors.size > 0) {

@@ -126,10 +70,3 @@ for (const modified of modifiedPathsInBaseGraph) {

}
// Commit changes in a subtractive pass and then an additive pass - this
// ensures that any errors encountered on the additive pass would also be
// encountered on a fresh build (implying legitimate errors in the graph,
// rather than an error in a module that's no longer reachable).
for (const modified of modifiedPathsInBaseGraph) {
// Skip this module if it has errors. Hopefully it will be removed -
// if not, we'll throw during the additive pass.
if (delta.errors.has(modified)) {

@@ -139,9 +76,5 @@ continue;

const module = this.dependencies.get(modified);
// The module may have already been released from the graph - we'll readd
// it if necessary later.
if (module == null) {
continue;
}
// Process the transform result and dependency removals. This should
// never encounter an error.
this._recursivelyCommitModule(modified, delta, internalOptions, {

@@ -151,14 +84,6 @@ onlyRemove: true,

}
// Ensure we have released any unreachable modules before the additive
// pass.
this._collectCycles(delta, internalOptions);
// Additive pass - any errors we encounter here should be thrown after
// rolling back the commit.
try {
for (const modified of modifiedPathsInBaseGraph) {
const module = this.dependencies.get(modified);
// The module may have already been released from the graph (it may yet
// be readded via another dependency).
if (module == null) {

@@ -170,3 +95,2 @@ continue;

} catch (error) {
// Roll back to base before re-throwing.
const rollbackDelta = {

@@ -182,15 +106,8 @@ added: delta.added,

const module = this.dependencies.get(modified);
// The module may have already been released from the graph (it may yet
// be readded via another dependency).
if (module == null) {
continue;
}
// Set the module and descendants back to base state.
this._recursivelyCommitModule(modified, rollbackDelta, internalOptions);
}
// Collect cycles again after rolling back. There's no need if we're
// not rolling back, because we have not removed any edges.
this._collectCycles(delta, internalOptions);
// Cheap check to validate the rollback.
invariant(

@@ -200,5 +117,2 @@ rollbackDelta.added.size === 0 && rollbackDelta.deleted.size === 0,

);
// Re-throw the transform or resolution error originally seen by
// `buildSubgraph`.
throw error;

@@ -236,3 +150,2 @@ }

for (const path of this.entryPoints) {
// Each entry point implicitly has a refcount of 1, so mark them all black.
this.#gc.color.set(path, "black");

@@ -242,10 +155,5 @@ }

if (delta.errors.size > 0) {
// If we encountered any errors during traversal, throw one of them.
// Since errors are encountered in a non-deterministic order, even on
// fresh builds, it's valid to arbitrarily pick the first.
throw delta.errors.values().next().value;
}
for (const path of this.entryPoints) {
// We have already thrown on userland errors in the delta, so any error
// encountered here would be exceptional and fatal.
this._recursivelyCommitModule(path, delta, internalOptions);

@@ -320,18 +228,10 @@ }

};
// Update the module information.
this.dependencies.set(nextModule.path, nextModule);
if (previousModule == null) {
// If the module is not currently in the graph, it is either new or was
// released earlier in the commit.
if (delta.deleted.has(path)) {
// Mark the addition by clearing a prior deletion.
delta.deleted.delete(path);
} else {
// Mark the addition in the added set.
delta.added.add(path);
}
}
// Diff dependencies (1/3): remove dependencies that have changed or been removed.
let dependenciesRemoved = false;

@@ -348,4 +248,2 @@ for (const [key, prevDependency] of previousDependencies) {

}
// Diff dependencies (2/3): add dependencies that have changed or been added.
let dependenciesAdded = false;

@@ -371,5 +269,2 @@ if (!commitOptions.onlyRemove) {

}
// Diff dependencies (3/3): detect changes in the ordering of dependency
// keys, which must be committed even if no other changes were made.
const previousDependencyKeys = [...previousDependencies.keys()];

@@ -388,4 +283,2 @@ const dependencyKeysChangedOrReordered =

) {
// We have not operated on nextModule, so restore previousModule
// to aid diffing. Don't add this path to delta.touched.
this.dependencies.set(previousModule.path, previousModule);

@@ -395,15 +288,5 @@ return previousModule;

delta.touched.add(path);
// Replace dependencies with the correctly-ordered version, matching the
// transform output. Because this assignment does not add or remove edges,
// it does NOT invalidate any of the garbage collection state.
// A subtractive pass only partially commits modules, so our dependencies
// are not generally complete yet. We'll address ordering in the next pass
// after processing additions.
if (commitOptions.onlyRemove) {
return nextModule;
}
// Catch obvious errors with a cheap assertion.
invariant(

@@ -425,14 +308,6 @@ nextModule.dependencies.size === currentDependencies.size,

const path = dependency.absolutePath;
// The module may already exist, in which case we just need to update some
// bookkeeping instead of adding a new node to the graph.
let module = this.dependencies.get(path);
if (options.shallow) {
// Don't add a node for the module if the graph is shallow (single-module).
} else if (dependency.data.data.asyncType === "weak") {
// Exclude weak dependencies from the bundle.
} else if (options.lazy && dependency.data.data.asyncType != null) {
// Don't add a node for the module if we are traversing async dependencies
// lazily (and this is an async dependency). Instead, record it in
// importBundleNodes.
this._incrementImportBundleReference(dependency, parentModule);

@@ -444,5 +319,2 @@ } else {

} catch (error) {
// If we couldn't add this module but it was added to the graph
// before failing on a sub-dependency, it may be orphaned. Mark it as
// a possible garbage root.
const module = this.dependencies.get(path);

@@ -459,4 +331,2 @@ if (module) {

}
// We either added a new node to the graph, or we're updating an existing one.
module.inverseDependencies.add(parentModule.path);

@@ -468,11 +338,4 @@ this._markModuleInUse(module);

} else {
// This dependency may have existed previously as a require.context -
// clean it up.
this.#resolvedContexts.delete(path);
}
// Update the parent's dependency map unless we failed to add a dependency.
// This means the parent's dependencies can get desynced from
// inverseDependencies and the other fields in the case of lazy edges.
// Not an optimal representation :(
parentModule.dependencies.set(key, dependency);

@@ -484,3 +347,2 @@ }

if (dependency.data.data.asyncType === "weak") {
// Weak dependencies are excluded from the bundle.
return;

@@ -492,4 +354,2 @@ }

} else if (module) {
// Decrement inverseDependencies only if the dependency is not async,
// mirroring the increment conditions in _addDependency.
module.inverseDependencies.delete(parentModule.path);

@@ -504,14 +364,7 @@ }

) {
// The reference count has decreased, but not to zero.
// NOTE: Each entry point implicitly has a refcount of 1.
this._markAsPossibleCycleRoot(module);
} else {
// The reference count has decreased to zero.
this._releaseModule(module, delta, options);
}
}
/**
* Collect a list of context modules which include a given file.
*/
markModifiedContextModules(filePath, modifiedPaths) {

@@ -527,8 +380,2 @@ for (const [absolutePath, context] of this.#resolvedContexts) {

}
/**
* Gets the list of modules affected by the deletion of a given file. The
* caller is expected to mark these modules as modified in the next call to
* traverseDependencies. Note that the list may contain duplicates.
*/
*getModifiedModulesForDeletedPath(filePath) {

@@ -538,7 +385,2 @@ yield* this.dependencies.get(filePath)?.inverseDependencies ?? [];

}
/**
* Re-traverse the dependency graph in DFS order to reorder the modules and
* guarantee the same order between runs. This method mutates the passed graph.
*/
reorderGraph(options) {

@@ -580,6 +422,2 @@ const orderedDependencies = new Map();

}
/** Garbage collection functions */
// Add an entry to importBundleNodes (or record an inverse dependency of an existing one)
_incrementImportBundleReference(dependency, parentModule) {

@@ -593,4 +431,2 @@ const { absolutePath } = dependency;

}
// Decrease the reference count of an entry in importBundleNodes (and delete it if necessary)
_decrementImportBundleReference(dependency, parentModule) {

@@ -610,10 +446,5 @@ const { absolutePath } = dependency;

}
// Mark a module as in use (ref count >= 1)
_markModuleInUse(module) {
this.#gc.color.set(module.path, "black");
}
// Iterate "children" of the given module - i.e. non-weak / async
// dependencies having a corresponding inverse dependency.
*_children(module, options) {

@@ -647,6 +478,2 @@ for (const dependency of module.dependencies.values()) {

}
// Delete an unreachable module (and its outbound edges) from the graph
// immediately.
// Called when the reference count of a module has reached 0.
_releaseModule(module, delta, options) {

@@ -657,6 +484,2 @@ if (

) {
// Before releasing a module, take a snapshot of the data we might need
// to reintroduce it to the graph later in this commit. As it is not
// already present in updatedModuleData we can infer it has not been modified,
// so the transform output and dependencies we copy here are current.
delta.baseModuleData.set(module.path, this._moduleSnapshot(module));

@@ -670,16 +493,8 @@ }

}
// Delete an unreachable module from the graph.
_freeModule(module, delta) {
if (delta.added.has(module.path)) {
// Mark the deletion by clearing a prior addition.
delta.added.delete(module.path);
} else {
// Mark the deletion in the deleted set.
delta.deleted.add(module.path);
}
// This module is not used anywhere else! We can clear it from the bundle.
// Clean up all the state associated with this module in order to correctly
// re-add it if we encounter it again.
this.dependencies.delete(module.path);

@@ -690,4 +505,2 @@ this.#gc.possibleCycleRoots.delete(module.path);

}
// Mark a module as a possible cycle root
_markAsPossibleCycleRoot(module) {

@@ -699,6 +512,3 @@ if (this.#gc.color.get(module.path) !== "purple") {

}
// Collect any unreachable cycles in the graph.
_collectCycles(delta, options) {
// Mark recursively from roots (trial deletion)
for (const path of this.#gc.possibleCycleRoots) {

@@ -720,3 +530,2 @@ const module = nullthrows(this.dependencies.get(path));

}
// Scan recursively from roots (undo unsuccessful trial deletions)
for (const path of this.#gc.possibleCycleRoots) {

@@ -726,3 +535,2 @@ const module = nullthrows(this.dependencies.get(path));

}
// Collect recursively from roots (free unreachable cycles)
for (const path of this.#gc.possibleCycleRoots) {

@@ -739,3 +547,2 @@ this.#gc.possibleCycleRoots.delete(path);

for (const childModule of this._children(module, options)) {
// The inverse dependency will be restored during the scan phase if this module remains live.
childModule.inverseDependencies.delete(module.path);

@@ -765,3 +572,2 @@ this._markGray(childModule, options);

for (const childModule of this._children(module, options)) {
// The inverse dependency must have been deleted during the mark phase.
childModule.inverseDependencies.add(module.path);

@@ -780,3 +586,2 @@ const childColor = nullthrows(this.#gc.color.get(childModule.path));

const childModule = this.dependencies.get(dependency.absolutePath);
// The child may already have been collected.
if (childModule) {

@@ -789,4 +594,2 @@ this._collectWhite(childModule, delta);

}
/** End of garbage collection functions */
}

@@ -793,0 +596,0 @@ exports.Graph = Graph;

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -29,4 +18,2 @@

};
// Do not prepend polyfills or the require runtime when only modules are requested
if (options.modulesOnly) {

@@ -33,0 +20,0 @@ preModules = [];

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -88,6 +77,2 @@

}
/**
* Returns the options needed to create a RAM bundle.
*/
async function _getRamOptions(

@@ -112,5 +97,2 @@ entryFile,

},
/* $FlowFixMe(>=0.99.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.99 was deployed. To see the error, delete this
* comment and run Flow. */
async (x) => Array.from(getDependencies)

@@ -117,0 +99,0 @@ );

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -16,5 +5,2 @@

const dependencies = _getDeps(path, graph, new Set());
// Remove the main entry point, since this method only returns the
// dependencies.
dependencies.delete(path);

@@ -21,0 +7,0 @@ return dependencies;

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -39,8 +28,2 @@

);
// TODO: Only include path if the target is not in the bundle
// Construct a server-relative URL for the split bundle, propagating
// most parameters from the main bundle's URL.
const { searchParams } = new URL(

@@ -59,3 +42,2 @@ jscSafeUrl.toNormalUrl(options.sourceUrl)

path.dirname(bundlePath),
// Strip the file extension
path.basename(bundlePath, path.extname(bundlePath))

@@ -73,3 +55,2 @@ ) +

? {
// $FlowIgnore[not-an-object] Intentionally spreading an array into an object
...dependencyMapArray,

@@ -81,4 +62,2 @@ paths,

if (options.dev) {
// Add the relative path of the module to make debugging easier.
// This is mapped to `module.verboseName` in `require.js`.
params.push(path.relative(options.projectRoot, module.path));

@@ -85,0 +64,0 @@ }

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -23,3 +12,2 @@

if (isJsModule(module)) {
// Construct a bundle URL for this specific module only
const getURL = (extension) => {

@@ -59,7 +47,4 @@ options.clientUrl.pathname = path.relative(

const inverseDependencies = getInverseDependencies(module.path, graph);
// Transform the inverse dependency paths to ids.
const inverseDependenciesById = Object.create(null);
Object.keys(inverseDependencies).forEach((path) => {
// $FlowFixMe[prop-missing]
// $FlowFixMe[invalid-computed-prop]
inverseDependenciesById[options.createModuleId(path)] = inverseDependencies[

@@ -71,11 +56,3 @@ path

}
/**
* Instead of adding the whole inverseDependncies object into each changed
* module (which can be really huge if the dependency graph is big), we only
* add the needed inverseDependencies for each changed module (we do this by
* traversing upwards the dependency graph).
*/
function getInverseDependencies(path, graph, inverseDependencies = {}) {
// Dependency alredy traversed.
if (path in inverseDependencies) {

@@ -82,0 +59,0 @@ return inverseDependencies;

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -46,10 +35,5 @@

if (!isBlocking) {
// Keep the loop running but try to avoid blocking
// for too long because this is not in a worker yet.
const diff = process.hrtime(time);
const NS_IN_MS = 1000000;
if (diff[1] > 50 * NS_IN_MS) {
// We've blocked for more than 50ms.
// This code currently runs on the main thread,
// so let's give Metro an opportunity to handle requests.
setImmediate(workLoop);

@@ -56,0 +40,0 @@ break;

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -30,6 +19,2 @@

this._getSha1 = getSha1Fn;
// Remove the transformer config params that we don't want to pass to the
// transformer. We should change the config object and move them away so we
// can treat the transformer config params as opaque.
const {

@@ -74,3 +59,2 @@ getTransformOptions: _getTransformOptions,

for (const key in extra) {
// $FlowFixMe[cannot-resolve-name]
if (hasOwnProperty.call(extra, key)) {

@@ -84,5 +68,3 @@ throw new Error(

const partialKey = stableHash([
// This is the hash related to the global Bundler config.
this._baseHash,
// Path.
localPath,

@@ -104,3 +86,2 @@ customTransformOptions,

if (fileBuffer) {
// Shortcut for virtual modules which provide the contents with the filename.
sha1 = _crypto.default

@@ -115,5 +96,2 @@ .createHash("sha1")

const result = await cache.get(fullKey);
// A valid result from the cache is used directly; otherwise we call into
// the transformer to computed the corresponding result.
const data = result

@@ -129,11 +107,5 @@ ? {

);
// Only re-compute the full key if the SHA-1 changed. This is because
// references are used by the cache implementation in a weak map to keep
// track of the cache that returned the result.
if (sha1 !== data.sha1) {
fullKey = Buffer.concat([partialKey, Buffer.from(data.sha1, "hex")]);
}
// Fire-and-forget cache set promise.
void cache.set(fullKey, data.result);

@@ -152,3 +124,2 @@ return {

end() {
// $FlowFixMe[unused-promise]
this._workerFarm.kill();

@@ -158,5 +129,4 @@ }

function verifyRootExists(root) {
// Verify that the root exists.
assert(fs.statSync(root).isDirectory(), "Root has to be a valid directory");
}
module.exports = Transformer;

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -18,9 +7,2 @@

const path = require("path");
/**
* When the `Buffer` is sent over the worker thread it gets serialized into a JSON object.
* This helper method will deserialize it if needed.
*
* @returns `Buffer` representation of the JSON object.
* @returns `null` if the given object is nullish or not a serialized `Buffer` object.
*/
function asDeserializedBuffer(value) {

@@ -64,3 +46,2 @@ if (Buffer.isBuffer(value)) {

) {
// eslint-disable-next-line no-useless-call
const Transformer = require.call(null, transformerConfig.transformerPath);

@@ -82,9 +63,2 @@ const transformFileStartLogEntry = {

);
// The babel cache caches scopes and pathes for already traversed AST nodes.
// Clearing the cache here since the nodes of the transformed file are no longer referenced.
// This isn't stritcly necessary since the cache uses a WeakMap. However, WeakMap only permit
// that unreferenced keys are collected but the values still hold references to the Scope and NodePaths.
// Manually clearing the cache allows the GC to collect the Scope and NodePaths without checking if there
// exist any other references to the keys.
traverse.cache.clear();

@@ -91,0 +65,0 @@ const transformFileEndLogEntry = getEndLogEntry(

@@ -1,17 +0,3 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";
/*::
export type * from './Worker.flow';
*/
try {

@@ -18,0 +4,0 @@ require("metro-babel-register").unstable_registerForMetroMonorepo();

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -41,3 +30,2 @@

} else {
// eslint-disable-next-line no-useless-call
this._worker = require.call(null, this._config.transformer.workerPath);

@@ -77,3 +65,2 @@ }

...process.env,
// Force color to print syntax highlighted code frames.
FORCE_COLOR: 1,

@@ -83,5 +70,3 @@ };

computeWorkerKey: this._config.stickyWorkers
? // $FlowFixMe[method-unbinding] added when improving typing for this parameters
// $FlowFixMe[incompatible-call]
this._computeWorkerKey
? this._computeWorkerKey
: undefined,

@@ -97,5 +82,2 @@ exposedMethods,

_computeWorkerKey(method, filename) {
// Only when transforming a file we want to stick to the same worker; and
// we'll shard by file path. If not; we return null, which tells the worker
// to pick the first available one.
if (method === "transform") {

@@ -119,4 +101,2 @@ return filename;

);
// $FlowExpectedError: TODO(t67543470): Change this to properly extend the error.
return Object.assign(error, {

@@ -123,0 +103,0 @@ stack: err.stack,

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -31,12 +21,2 @@

}
/**
* The HmrServer (Hot Module Reloading) implements a lightweight interface
* to communicate easily to the logic in the React Native repository (which
* is the one that handles the Web Socket connections).
*
* This interface allows the HmrServer to hook its own logic to WS clients
* getting connected, disconnected or having errors (through the
* `onClientConnect`, `onClientDisconnect` and `onClientError` methods).
*/
class HmrServer {

@@ -65,7 +45,2 @@ constructor(bundler, createModuleId, config) {

splitBundleOptions(options);
/**
* `entryFile` is relative to projectRoot, we need to use resolution function
* to find the appropriate file with supported extensions.
*/
const resolutionFn = await transformHelpers.getResolveDependencyFn(

@@ -109,3 +84,2 @@ this._bundler.getBundler(),

} else {
// Prepare the clientUrl to be used as sourceUrl in HMR updates.
clientUrl.protocol = "http";

@@ -148,3 +122,2 @@ const {

.getDeltaBundler()
// $FlowFixMe[missing-local-annot]
.listen(graph, async (...args) => {

@@ -231,8 +204,2 @@ latestEventArgs = args;

createActionStartEntry({
// Even when HMR is disabled on the client, this function still
// runs so we can stash updates while it's off and apply them later.
// However, this would mess up our internal analytics because we track
// HMR as being used even for people who have it disabled.
// As a workaround, we use a different event name for clients
// that didn't explicitly opt into HMR.
action_name: optedIntoHMR

@@ -239,0 +206,0 @@ ? "Processing HMR change"

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -40,3 +29,2 @@

this._deltaBundler.end();
// $FlowFixMe[unused-promise]
this._bundler.end();

@@ -166,5 +154,2 @@ }

}
// TODO T34760750 (alexkirsz) Eventually, I'd like to get to a point where
// this class exposes only initializeGraph and updateGraph.
async initializeGraph(

@@ -218,4 +203,2 @@ entryFile,

} catch (err) {
// Evict a bad revision from the cache since otherwise
// we'll keep getting it even after the build is fixed.
this._revisionsById.delete(revisionId);

@@ -240,4 +223,2 @@ this._revisionsByGraphId.delete(graphId);

...revision,
// Generate a new revision id, to be used to verify the next incremental
// request.
id: crypto.randomBytes(8).toString("hex"),

@@ -276,4 +257,2 @@ date: new Date(),

new Promise((resolve, reject) => {
// This should throw an error if the file doesn't exist.
// Using this instead of fs.exists to account for SimLinks.
fs.realpath(entryFile, (err) => {

@@ -291,4 +270,2 @@ if (err) {

}
// Wait for the bundler to become ready.
async ready() {

@@ -295,0 +272,0 @@ await this._bundler.ready();

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -40,4 +29,2 @@

const defaultConfig = await getDefaultConfig(config.projectRoot);
// $FlowFixMe[incompatible-variance]
// $FlowFixMe[incompatible-call]
return mergeConfig(defaultConfig, config);

@@ -85,8 +72,4 @@ }

const createConnectMiddleware = async function (config, options) {
// $FlowFixMe[incompatible-variance]
// $FlowFixMe[incompatible-call]
const metroServer = await runMetro(config, options);
let enhancedMiddleware = metroServer.processRequest;
// Enhance the resulting middleware using the config options
if (config.server.enhanceMiddleware) {

@@ -135,7 +118,4 @@ enhancedMiddleware = config.server.enhanceMiddleware(

secure,
//deprecated
secureCert,
// deprecated
secureKey,
// deprecated
unstable_extraMiddleware,

@@ -149,3 +129,2 @@ waitForBundler = false,

if (secure != null || secureCert != null || secureKey != null) {
// eslint-disable-next-line no-console
console.warn(

@@ -158,3 +137,2 @@ chalk.inverse.yellow.bold(" DEPRECATED "),

}
// Lazy require
const connect = require("connect");

@@ -184,3 +162,2 @@ const serverApp = connect();

}
// $FlowFixMe[incompatible-call] 'http' and 'https' Flow types do not match
httpServer = https.createServer(options, serverApp);

@@ -229,6 +206,2 @@ } else {

});
// Disable any kind of automatic timeout behavior for incoming
// requests in case it takes the packager more than the default
// timeout of 120 seconds to respond to a request.
httpServer.timeout = 0;

@@ -258,4 +231,2 @@ httpServer.on("close", () => {

) => {
// $FlowFixMe[incompatible-variance]
// $FlowFixMe[incompatible-call]
const metroServer = await runMetro(config, {

@@ -294,4 +265,2 @@ watch: false,

};
// eslint-disable-next-line no-console
await output.save(metroBundle, outputOptions, console.log);

@@ -298,0 +267,0 @@ }

@@ -1,17 +0,3 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";
/*::
export type * from './index.flow';
*/
try {

@@ -18,0 +4,0 @@ require("metro-babel-register").unstable_registerForMetroMonorepo();

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -12,0 +2,0 @@

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -12,0 +2,0 @@

@@ -7,16 +7,2 @@ "use strict";

}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
// $FlowExpectedError[cannot-resolve-module]
// $FlowExpectedError[cannot-resolve-module]
global.x = _doesNotExist.default;
"use strict";
var _doesNotExist = require("./does-not'\"-exist");
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
/* eslint-disable no-unused-vars */
// $FlowExpectedError[cannot-resolve-module]
global.x = _doesNotExist.aaaaaaaaaa;
"use strict";
var _doesNotExist = require("./does-not-exist");
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
/* eslint-disable no-unused-vars */
// $FlowExpectedError[cannot-resolve-module]
global.x = _doesNotExist.aaaaaaaaaa;
"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
// $FlowExpectedError[cannot-resolve-module]
// $FlowExpectedError[cannot-resolve-module]
const DoesNotExist = require("./foo" /* ./foo */);
const DoesNotExist = require("./foo");
global.x = DoesNotExist;
"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
// $FlowExpectedError[cannot-resolve-module]
// $FlowExpectedError[cannot-resolve-module]
const DoesNotExist = require("./does-not-exist");
global.x = DoesNotExist;
"use strict";
var _doesNotExist = require("./does-not'\"-exist");
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
/* eslint-disable no-unused-vars */
// $FlowExpectedError[cannot-resolve-module]
// $FlowExpectedError[cannot-resolve-module]
global.x = _doesNotExist.DoesNotExist;

@@ -7,16 +7,2 @@ "use strict";

}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
// $FlowExpectedError[cannot-resolve-module]
// $FlowExpectedError[cannot-resolve-module]
global.x = _doesNotExist.default;
"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
// $FlowExpectedError[cannot-resolve-module]
// $FlowExpectedError[cannot-resolve-module]
const DoesNotExist = require("./does-not-exist");
global.x = DoesNotExist;

@@ -1,17 +0,5 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";
// Add a random require to fill the bundle with some sourcecode.
require("./AssetRegistry");
const calcSum = (value) => {
// some random function
const error = new Error("SOURCEMAP: value: " + value);

@@ -18,0 +6,0 @@ return error;

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -12,0 +2,0 @@

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -12,0 +2,0 @@

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -12,0 +2,0 @@

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -12,0 +2,0 @@

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -12,0 +2,0 @@

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -12,0 +2,0 @@

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -12,0 +2,0 @@

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -12,0 +2,0 @@

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -12,0 +2,0 @@

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -12,0 +2,0 @@

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
"use strict";

@@ -12,0 +2,0 @@

@@ -1,15 +0,3 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @oncall react_native
*/
"use strict";
// Inject something into the global object so we can verify that this file
// is indeed evaluated.
global.POLYFILL_IS_INJECTED = "POLYFILL_IS_INJECTED";
"use strict";
var _utils = require("./utils");
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
const normalModule = require("./subdir-conflict");

@@ -15,0 +5,0 @@ const contextModule = require.context("./subdir-conflict");

"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
const empty = require.context("./no-such-dir");

@@ -14,0 +4,0 @@ function main() {

"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
const ab = require.context("./subdir", false, /\/(a|b)\.js$/);

@@ -14,0 +4,0 @@ const abc = require.context("./subdir", false);

"use strict";
var _utils = require("./utils");
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
function main() {

@@ -15,0 +5,0 @@ return (0, _utils.awaitProperties)(

"use strict";
var _utils = require("./utils");
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
function main() {

@@ -15,0 +5,0 @@ return (0, _utils.awaitProperties)(

"use strict";
var _utils = require("./utils");
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
function main() {

@@ -15,0 +5,0 @@ return (0, _utils.awaitProperties)(

"use strict";
var _utils = require("./utils");
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
function main() {
return (0, _utils.copyContextToObject)(
// $FlowFixMe[underconstrained-implicit-instantiation]
require.context("./subdir", undefined, undefined, "sync")

@@ -18,0 +7,0 @@ );

"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
module.exports = "contents of subdir-conflict/index.js";
"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
module.exports = "a";

@@ -7,12 +7,3 @@ "use strict";

exports.default = void 0;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
var _default = "b";
exports.default = _default;
"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
module.exports = "c";
"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
module.exports = "d";

@@ -8,12 +8,2 @@ "use strict";

exports.copyContextToObject = copyContextToObject;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
function copyContextToObject(ctx) {

@@ -20,0 +10,0 @@ return Object.fromEntries(ctx.keys().map((key) => [key, ctx(key)]));

"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
async function main() {
const moduleId = require.resolveWeak("./subdir/counter-module");
// Require the module statically via its path, spelled slightly differently
(await import("./subdir/counter-module.js")).increment();
const dynamicRequire = require;
// Require the module dynamically via its ID
const timesIncremented = dynamicRequire(moduleId).increment();
return {
moduleId,
// Should be 2, proving there's just one module instance
timesIncremented,

@@ -26,0 +11,0 @@ };

"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
async function main() {

@@ -14,0 +4,0 @@ return {

"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
function main() {

@@ -14,0 +4,0 @@ return {

"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
function main() {
const moduleId = require.resolveWeak("./subdir/counter-module");
const dynamicRequire = require;
// Require the module dynamically via its ID
dynamicRequire(moduleId).increment();
// Require the module statically via its path, spelled slightly differently
const timesIncremented = require("./subdir/counter-module.js").increment();
return {
moduleId,
// Should be 2, proving there's just one module instance
timesIncremented,

@@ -26,0 +11,0 @@ };

"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
let count = 0;

@@ -14,0 +4,0 @@ module.exports = {

"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
throw new Error("This module cannot be evaluated.");

@@ -1,17 +0,5 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";
// $FlowFixMe[signature-verification-failure]
var a = 2n;
// $FlowFixMe[signature-verification-failure]
var b = 3n;
module.exports = a ** b;

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -15,3 +5,2 @@

const Foo = require("./Foo");
// $FlowFixMe: Flow doesn't understand TypeScript
const TypeScript = require("./TypeScript");

@@ -18,0 +7,0 @@ Object.keys({

@@ -1,13 +0,3 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";
module.exports = global.POLYFILL_IS_INJECTED;

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @oncall react_native
*/
"use strict";

@@ -12,0 +2,0 @@

@@ -1,22 +0,4 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";
const invariant = require("invariant");
/**
* We batch items together trying to minimize their processing, for example as
* network queries. For that we wait a small moment before processing a batch.
* We limit also the number of items we try to process in a single batch so that
* if we have many items pending in a short amount of time, we can start
* processing right away.
*/
class BatchProcessor {

@@ -29,3 +11,2 @@ constructor(options, processBatch) {

this._currentProcessCount = 0;
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
this._processQueue = this._processQueue.bind(this);

@@ -57,5 +38,3 @@ }

this._processBatch(jobs.map((job) => job.item)).then(
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
this._onBatchResults.bind(this, jobs),
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
this._onBatchError.bind(this, jobs)

@@ -68,3 +47,2 @@ );

clearTimeout(this._timeoutHandle);
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
process.nextTick(this._processQueue);

@@ -75,3 +53,2 @@ return;

this._timeoutHandle = setTimeout(
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
this._processQueue,

@@ -78,0 +55,0 @@ this._options.maximumDelayMs

@@ -1,25 +0,7 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";
/**
* Serializes a bundle into a plain JS bundle.
*/
function bundleToString(bundle) {
let code = bundle.pre.length > 0 ? bundle.pre + "\n" : "";
const modules = [];
const sortedModules = bundle.modules
.slice()
// The order of the modules needs to be deterministic in order for source
// maps to work properly.
.sort((a, b) => a[0] - b[0]);
const sortedModules = bundle.modules.slice().sort((a, b) => a[0] - b[0]);
for (const [id, moduleCode] of sortedModules) {

@@ -26,0 +8,0 @@ if (moduleCode.length > 0) {

@@ -14,23 +14,6 @@ "use strict";

}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
function toHash(value) {
// Use `hex` to ensure filepath safety.
return _crypto.default.createHash("sha1").update(value).digest("hex");
}
/** Given a fully qualified require context, return a virtual file path that ensures uniqueness between paths with different contexts. */
function deriveAbsolutePathFromContext(from, context) {
// Drop the trailing slash, require.context should always be matched against a folder
// and we want to normalize the folder name as much as possible to prevent duplicates.
// This also makes the files show up in the correct location when debugging in Chrome.
const filePath = from.endsWith(_path.default.sep) ? from.slice(0, -1) : from;

@@ -51,8 +34,3 @@ return (

}
/** Match a file against a require context. */
function fileMatchesContext(testPath, context) {
// NOTE(EvanBacon): Ensure this logic is synchronized with the similar
// functionality in `metro-file-map/src/lib/TreeFS.js` (`matchFiles()`)
const filePath = _path.default.relative(

@@ -64,13 +42,5 @@ (0, _nullthrows.default)(context.from),

if (
// Ignore everything outside of the provided `root`.
!(filePath && !filePath.startsWith("..")) ||
// Prevent searching in child directories during a non-recursive search.
(!context.recursive && filePath.includes(_path.default.sep)) ||
// Test against the filter.
!filter.test(
// NOTE(EvanBacon): Ensure files start with `./` for matching purposes
// this ensures packages work across Metro and Webpack (ex: Storybook for React DOM / React Native).
// `a/b.js` -> `./a/b.js`
"./" + filePath.replace(/\\/g, "/")
)
!filter.test("./" + filePath.replace(/\\/g, "/"))
) {

@@ -77,0 +47,0 @@ return false;

@@ -49,13 +49,2 @@ "use strict";

}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
function createFileMap(modulePath, files, processModule) {

@@ -65,3 +54,2 @@ let mapString = "\n";

.slice()
// Sort for deterministic output
.sort()

@@ -73,8 +61,2 @@ .forEach((file) => {

}
// NOTE(EvanBacon): I'd prefer we prevent the ability for a module to require itself (`require.context('./')`)
// but Webpack allows this, keeping it here provides better parity between bundlers.
// Ensure relative file paths start with `./` so they match the
// patterns (filters) used to include them.
if (!filePath.startsWith(".")) {

@@ -84,8 +66,2 @@ filePath = `./${filePath}`;

const key = JSON.stringify(filePath);
// NOTE(EvanBacon): Webpack uses `require.resolve` in order to load modules on demand,
// Metro doesn't have this functionality so it will use getters instead. Modules need to
// be loaded on demand because if we imported directly then users would get errors from importing
// a file without exports as soon as they create a new file and the context module is updated.
// NOTE: The values are set to `enumerable` so the `context.keys()` method works as expected.
mapString += ` ${key}: { enumerable: true, get() { return ${processModule(

@@ -144,12 +120,2 @@ file

}
/**
* Generate a context module as a virtual file string.
*
* @prop {ContextMode} mode indicates how the modules should be loaded.
* @prop {string} modulePath virtual file path for the virtual module. Example: `require.context('./src')` -> `'/path/to/project/src'`.
* @prop {string[]} files list of absolute file paths that must be exported from the context module. Example: `['/path/to/project/src/index.js']`.
*
* @returns a string representing a context module (virtual file contents).
*/
function getContextModuleTemplate(mode, modulePath, files) {

@@ -164,4 +130,2 @@ if (!files.length) {

files,
// NOTE(EvanBacon): It's unclear if we should use `import` or `require` here so sticking
// with the more stable option (`require`) for now.
"require",

@@ -168,0 +132,0 @@ [

@@ -7,18 +7,2 @@ "use strict";

exports.default = void 0;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
/**
* A Set that only deletes a given item when the number of delete(item) calls
* matches the number of add(item) calls. Iteration and `size` are in terms of
* *unique* items.
*/
class CountingSet {

@@ -63,18 +47,5 @@ #map = new Map();

}
// Iterate over unique entries
// $FlowIssue[unsupported-syntax]
[Symbol.iterator]() {
return this.values();
}
/*::
// For Flow's benefit
@@iterator(): Iterator<T> {
return this.values();
}
*/
// Number of unique entries
// $FlowIssue[unsafe-getters-setters]
get size() {

@@ -94,8 +65,2 @@ return this.#map.size;

}
// For Jest purposes. Ideally a custom serializer would be enough, but in
// practice there is hardcoded magic for Set in toEqual (etc) that we cannot
// extend to custom collection classes. Instead let's assume values are
// sortable ( = strings) and make this look like an array with some stable
// order.
toJSON() {

@@ -102,0 +67,0 @@ return [...this].sort();

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -7,24 +7,2 @@ "use strict";

}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
/**
* Returns a WebSocketServer to be attached to an existing HTTP instance. It forwards
* the received events on the given "websocketServer" parameter. It must be an
* object with the following fields:
*
* - onClientConnect
* - onClientError
* - onClientMessage
* - onClientDisconnect
*/
module.exports = function createWebsocketServer({ websocketServer }) {

@@ -39,3 +17,2 @@ const wss = new _ws.default.Server({

if (connected) {
// $FlowFixMe[incompatible-call]
ws.send(...args);

@@ -50,3 +27,2 @@ }

ws.on("error", (e) => {
// $FlowFixMe[incompatible-call]
websocketServer.onClientError && websocketServer.onClientError(client, e);

@@ -53,0 +29,0 @@ });

@@ -1,16 +0,3 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";
// Debounces calls with the given delay, and queues the next call while the
// previous one hasn't completed so that no two calls can execute concurrently.
function debounceAsyncQueue(fn, delay) {

@@ -17,0 +4,0 @@ let timeout;

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -62,3 +52,2 @@

type: "ResourceNotFoundError",
// $FlowFixMe[incompatible-return]
errors: [],

@@ -70,3 +59,2 @@ message: error.message,

type: "GraphNotFoundError",
// $FlowFixMe[incompatible-return]
errors: [],

@@ -78,3 +66,2 @@ message: error.message,

type: "RevisionNotFoundError",
// $FlowFixMe[incompatible-return]
errors: [],

@@ -91,3 +78,2 @@ message: error.message,

codeFrame = codeFrameColumns(
// If the error was thrown in a node.js builtin module, this call will fail and mask the real error.
fs.readFileSync(fileName, "utf8"),

@@ -94,0 +80,0 @@ {

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -21,4 +10,2 @@

const vars = [
// Ensure these variable names match the ones referenced in metro-runtime
// require.js
"__BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now()",

@@ -31,4 +18,2 @@ `__DEV__=${String(isDev)}`,

if (isDev) {
// Ensure these variable names match the ones referenced in metro-runtime
// require.js
vars.push(

@@ -49,5 +34,2 @@ `${globalPrefix}__requireCycleIgnorePatterns=[${requireCycleIgnorePatterns

if (extraVars.hasOwnProperty(key) && !excluded.has(key)) {
/* $FlowFixMe(>=0.95.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.95 was deployed. To see the error, delete
* this comment and run Flow. */
assignments.push(`${key}=${JSON.stringify(extraVars[key])}`);

@@ -54,0 +36,0 @@ }

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -29,4 +18,2 @@

) {
// Get all the polyfills from the relevant option params (the
// `getPolyfills()` method and the `polyfillModuleNames` variable).
const polyfillModuleNames = config.serializer

@@ -33,0 +20,0 @@ .getPolyfills({

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -18,9 +7,3 @@

}
/**
* There is a special case for errors because they have non-enumerable fields.
* (Perhaps we should switch in favor of plain object?)
*/
update(event) {
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
if (Object.prototype.toString.call(event.error) === "[object Error]") {

@@ -27,0 +10,0 @@ event = Object.assign(event, {

@@ -1,13 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
/* eslint-disable no-console */
"use strict";

@@ -32,3 +20,2 @@

clearTimeout(collapsedGuardTimer);
// Inform users that logs get swallowed if they forget to call `groupEnd`.
collapsedGuardTimer = setTimeout(() => {

@@ -52,3 +39,2 @@ if (groupStack.includes("groupCollapsed")) {

if (!groupStack.includes("groupCollapsed")) {
// Remove excess whitespace at the end of a log message, if possible.
const lastItem = data[data.length - 1];

@@ -63,6 +49,2 @@ if (typeof lastItem === "string") {

"".padEnd(groupStack.length * 2, " "),
// `util.format` actually accepts any arguments.
// If the first argument is a string, it tries to format it.
// Otherwise, it just concatenates all arguments.
// $FlowIssue[incompatible-call] util.format expected the first argument to be a string
util.format(...data)

@@ -69,0 +51,0 @@ );

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -21,3 +10,2 @@

if (key.startsWith(PREFIX)) {
// $FlowFixMe[prop-missing]
customTransformOptions[key.substr(PREFIX.length)] = query[key];

@@ -24,0 +12,0 @@ }

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -32,3 +21,3 @@

module.exports = function parseOptionsFromUrl(normalizedRequestUrl, platforms) {
const parsedURL = nullthrows(url.parse(normalizedRequestUrl, true)); // `true` to parse the query param as an object.
const parsedURL = nullthrows(url.parse(normalizedRequestUrl, true));
const query = nullthrows(parsedURL.query);

@@ -59,7 +48,2 @@ const pathname =

...parsedURL,
// The Chrome Debugger loads bundles via Blob urls, whose
// protocol is blob:http. This breaks loading source maps through
// protocol-relative URLs, which is why we must force the HTTP protocol
// when loading the bundle for either Android or iOS.
// TODO(T167298674): Remove when remote debugging is not needed in React Native
protocol:

@@ -66,0 +50,0 @@ platform != null && platform.match(/^(android|ios|vr|windows|macos)$/)

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -16,12 +6,2 @@

const HEADER_SIZE = 3;
/**
* Implementation of a RAM bundle parser in JS.
*
* It receives a Buffer as an input and implements two main methods, which are
* able to run in constant time no matter the size of the bundle:
*
* getStartupCode(): returns the runtime and the startup code of the bundle.
* getModule(): returns the code for the specified module.
*/
class RamBundleParser {

@@ -35,5 +15,2 @@ constructor(buffer) {

this._startupCodeLength = this._readPosition(2);
// The startup code begins after the table of contents, which contains the
// 3 fields on the header plus 2 entries per module.
this._startOffset = (HEADER_SIZE + this._numModules * 2) * SIZEOF_UINT32;

@@ -40,0 +17,0 @@ }

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -16,3 +5,2 @@

function relativizeSourceMapInline(sourceMap, sourcesRoot) {
// eslint-disable-next-line lint/strictly-null
if (sourceMap.mappings === undefined) {

@@ -19,0 +7,0 @@ for (let i = 0; i < sourceMap.sections.length; i++) {

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -17,8 +6,2 @@

const util = require("util");
/**
* A standard way to log a warning to the terminal. This should not be called
* from some arbitrary Metro logic, only from the reporters. Instead of
* calling this, add a new type of ReportableEvent instead, and implement a
* proper handler in the reporter(s).
*/
function logWarning(terminal, format, ...args) {

@@ -28,6 +11,2 @@ const str = util.format(format, ...args);

}
/**
* Similar to `logWarning`, but for messages that require the user to act.
*/
function logError(terminal, format, ...args) {

@@ -37,14 +16,5 @@ terminal.log(

chalk.red("error"),
// Syntax errors may have colors applied for displaying code frames
// in various places outside of where Metro is currently running.
// If the current terminal does not support color, we'll strip the colors
// here.
util.format(chalk.supportsColor ? format : stripAnsi(format), ...args)
);
}
/**
* A reporter that does nothing. Errors and warnings will be swallowed, that
* is generally not what you want.
*/
const nullReporter = {

@@ -51,0 +21,0 @@ update() {},

@@ -1,17 +0,3 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";
/**
* Splits a BundleOptions object into smaller, more manageable parts.
*/
function splitBundleOptions(options) {

@@ -18,0 +4,0 @@ return {

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -25,14 +14,3 @@

const MAX_PROGRESS_BAR_CHAR_WIDTH = 16;
/**
* We try to print useful information to the terminal for interactive builds.
* This implements the `Reporter` interface from the './reporting' module.
*/
class TerminalReporter {
/**
* The bundle builds for which we are actively maintaining the status on the
* terminal, ie. showing a progress bar. There can be several bundles being
* built at the same time.
*/
constructor(terminal) {

@@ -48,9 +26,2 @@ this._activeBundles = new Map();

}
/**
* Construct a message that represents the progress of a
* single bundle build, for example:
*
* BUNDLE path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)
*/
_getBundleStatusMessage(

@@ -180,7 +151,2 @@ {

}
/**
* This function is only concerned with logging and should not do state
* or terminal status updates.
*/
_log(event) {

@@ -250,8 +216,2 @@ switch (event.type) {

}
/**
* We do not want to log the whole stacktrace for bundling error, because
* these are operational errors, not programming errors, and the stacktrace
* is not actionable to end users.
*/
_logBundlingError(error) {

@@ -273,5 +233,2 @@ if (error instanceof AmbiguousModuleResolutionError) {

let { message } = error;
// Do not log the stack trace for SyntaxError (because it will always be in
// the parser, which is not helpful).
if (!(error instanceof SyntaxError)) {

@@ -283,3 +240,2 @@ if (error.snippet == null && error.stack != null) {

if (error.filename && !message.includes(error.filename)) {
// $FlowFixMe[incompatible-type]
message += ` [${error.filename}]`;

@@ -301,8 +257,2 @@ }

}
/**
* We use Math.pow(ratio, 2) to as a conservative measure of progress because
* we know the `totalCount` is going to progressively increase as well. We
* also prevent the ratio from going backwards.
*/
_updateBundleProgress({ buildID, transformedFileCount, totalFileCount }) {

@@ -322,7 +272,2 @@ const currentProgress = this._activeBundles.get(buildID);

}
/**
* This function is exclusively concerned with updating the internal state.
* No logging or status updates should be done at this point.
*/
_updateState(event) {

@@ -349,8 +294,2 @@ switch (event.type) {

}
/**
* Return a status message that is always consistent with the current state
* of the application. Having this single function ensures we don't have
* different callsites overriding each other status messages.
*/
_getStatusMessage() {

@@ -376,3 +315,2 @@ return Array.from(this._activeBundles.entries())

_logWatcherHealthCheckResult(result) {
// Don't be spammy; only report changes in status.
if (

@@ -389,3 +327,2 @@ !this._prevHealthCheckResult ||

case "success":
// Only report success after a prior failure.
if (this._prevHealthCheckResult) {

@@ -450,7 +387,2 @@ this.terminal.log(

}
/**
* Single entry point for reporting events. That allows us to implement the
* corresponding JSON reporter easily and have a consistent reporting.
*/
update(event) {

@@ -457,0 +389,0 @@ if (event.type === "bundle_transform_progressed") {

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -46,6 +35,2 @@

};
// When we're processing scripts, we don't need to calculate any
// inlineRequires information, since scripts by definition don't have
// requires().
if (options.type === "script") {

@@ -133,7 +118,2 @@ return {

const graph = await bundler.getDependencyGraph();
// TODO: Check delta changes to avoid having to look over all files each time
// this is a massive performance boost.
// Search against all files in a subtree.
const files = Array.from(

@@ -140,0 +120,0 @@ graph.matchFilesWithContext(requireContext.from, {

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @oncall react_native
*/
"use strict";

@@ -64,4 +54,2 @@

}
// See https://superuser.com/questions/380772/removing-ansi-color-codes-from-text-stream
const ANSI_PATTERN = /\x1b\[[0-9;]*m/g;

@@ -71,7 +59,2 @@ function trimANSICodes(input) {

}
/**
* Matches a text that contains ANSI control codes (e.g. [39m^) against a snapshot.
* Usage: Call expect.extend({toMatchCodeFrameSnapshot}) to add the matcher in your test
*/
function toMatchCodeFrameSnapshot(received) {

@@ -78,0 +61,0 @@ return toMatchSnapshot.call(

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -20,11 +10,2 @@

const { isImport } = types;
/**
* Transform all the calls to `require()` and `import()` in a file into ID-
* independent code, and return the list of dependencies. For example, a call
* like `require('Foo')` could be transformed to `require(_depMap[3], 'Foo')`
* where `_depMap` is provided by the outer scope. As such, we don't need to
* know the actual module ID.
*
* The second argument is only provided for debugging purposes.
*/
function collectDependencies(ast, options) {

@@ -63,16 +44,10 @@ const visited = new WeakSet();

}
// Match `require.context`
if (
// Feature gate, defaults to `false`.
state.unstable_allowRequireContext &&
callee.type === "MemberExpression" &&
// `require`
callee.object.type === "Identifier" &&
callee.object.name === "require" &&
// `context`
callee.property.type === "Identifier" &&
callee.property.name === "context" &&
!callee.computed &&
// Ensure `require` refers to the global and not something else.
!path.scope.getBinding("require")

@@ -84,14 +59,9 @@ ) {

}
// Match `require.resolveWeak`
if (
callee.type === "MemberExpression" &&
// `require`
callee.object.type === "Identifier" &&
callee.object.name === "require" &&
// `resolveWeak`
callee.property.type === "Identifier" &&
callee.property.name === "resolveWeak" &&
!callee.computed &&
// Ensure `require` refers to the global and not something else.
!path.scope.getBinding("require")

@@ -132,3 +102,2 @@ ) {

const collectedDependencies = state.dependencyRegistry.getDependencies();
// Compute the list of dependencies.
const dependencies = new Array(collectedDependencies.length);

@@ -147,4 +116,2 @@ for (const { index, name, ...dependencyData } of collectedDependencies) {

}
/** Extract args passed to the `require.context` method. */
function getRequireContextArgs(path) {

@@ -166,4 +133,2 @@ const args = path.get("arguments");

}
// Default to requiring through all directories.
let recursive = true;

@@ -181,4 +146,2 @@ if (args.length > 1) {

}
// Default to all files.
let filter = {

@@ -189,8 +152,5 @@ pattern: ".*",

if (args.length > 2) {
// evaluate() to check for undefined (because it's technically a scope lookup)
// but check the AST for the regex literal, since evaluate() doesn't do regex.
const result = args[2].evaluate();
const argNode = args[2].node;
if (argNode.type === "RegExpLiteral") {
// TODO: Handle `new RegExp(...)` -- `argNode.type === 'NewExpression'`
filter = {

@@ -207,4 +167,2 @@ pattern: argNode.pattern,

}
// Default to `sync`.
let mode = "sync";

@@ -257,5 +215,3 @@ if (args.length > 3) {

{
// We basically want to "import" every file in a folder and then filter them out with the given `filter` RegExp.
name: directory,
// Capture the matching context
contextParams,

@@ -267,4 +223,2 @@ asyncType: null,

);
// require() the generated module representing this context
path.get("callee").replaceWith(types.identifier("require"));

@@ -353,3 +307,2 @@ transformer.transformSyncRequire(path, dep, state);

!current.node.loc &&
// $FlowIgnore[prop-missing] METRO_INLINE_REQUIRES_INIT_LOC is Metro-specific and not typed
!current.node.METRO_INLINE_REQUIRES_INIT_LOC

@@ -359,6 +312,3 @@ ) {

}
return (
// $FlowIgnore[prop-missing] METRO_INLINE_REQUIRES_INIT_LOC is Metro-specific and not typed
current?.node.METRO_INLINE_REQUIRES_INIT_LOC ?? current?.node.loc
);
return current?.node.METRO_INLINE_REQUIRES_INIT_LOC ?? current?.node.loc;
}

@@ -375,4 +325,2 @@ function registerDependency(state, qualifier, path) {

const { allowOptionalDependencies } = state;
// The async require module is a 'built-in'. Resolving should never fail -> treat it as non-optional.
if (name === state.asyncRequireModulePathStringLiteral?.value) {

@@ -387,4 +335,2 @@ return false;

}
// Valid statement stack for single-level try-block: expressionStatement -> blockStatement -> tryStatement
let sCount = 0;

@@ -395,4 +341,2 @@ let p = path;

if (p.node.type === "BlockStatement") {
// A single-level should have the tryStatement immediately followed BlockStatement
// with the key 'block' to distinguish from the finally block, which has key = 'finalizer'
return (

@@ -436,8 +380,2 @@ p.parentPath != null &&

collectDependencies.InvalidRequireCallError = InvalidRequireCallError;
/**
* Produces a Babel template that will throw at runtime when the require call
* is reached. This makes dynamic require errors catchable by libraries that
* want to use them.
*/
const dynamicRequireErrorTemplate = template.expression(`

@@ -450,7 +388,2 @@ (function(line) {

`);
/**
* Produces a Babel template that transforms an "import(...)" call into a
* "require(...)" call to the asyncRequire specified.
*/
const makeAsyncRequireTemplate = template.expression(`

@@ -475,3 +408,2 @@ require(ASYNC_REQUIRE_MODULE_PATH)(MODULE_ID, DEPENDENCY_MAP.paths)

path.node.arguments = [moduleIDExpression];
// Always add the debug name argument last
if (state.keepRequireNames) {

@@ -535,20 +467,2 @@ path.node.arguments.push(types.stringLiteral(dependency.name));

}
/**
* Given an import qualifier, return a key used to register the dependency.
* Generally this return the `ImportQualifier.name` property, but more
* attributes can be appended to distinguish various combinations that would
* otherwise conflict.
*
* For example, the following case would have collision issues if they all utilized the `name` property:
* ```
* require('./foo');
* require.context('./foo');
* require.context('./foo', true, /something/);
* require.context('./foo', false, /something/);
* require.context('./foo', false, /something/, 'lazy');
* ```
*
* This method should be utilized by `registerDependency`.
*/
function getKeyForDependency(qualifier) {

@@ -561,7 +475,3 @@ let key = qualifier.name;

const { contextParams } = qualifier;
// Add extra qualifiers when using `require.context` to prevent collisions.
if (contextParams) {
// NOTE(EvanBacon): Keep this synchronized with `RequireContextParams`, if any other properties are added
// then this key algorithm should be updated to account for those properties.
// Example: `./directory__true__/foobar/m__lazy`
key += [

@@ -574,3 +484,2 @@ "",

contextParams.mode,
// Join together and append to the name:
].join("\0");

@@ -602,4 +511,2 @@ }

if (dependency.isOptional && !qualifier.optional) {
// A previously optionally required dependency was required non-optionally.
// Mark it non optional for the whole module
dependency = {

@@ -606,0 +513,0 @@ ...dependency,

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -15,7 +5,2 @@

const nullthrows = require("nullthrows");
/**
* Select unused names for "metroImportDefault" and "metroImportAll", by
* calling "generateUid".
*/
function generateImportNames(ast) {

@@ -22,0 +7,0 @@ let importDefault;

@@ -1,11 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict";

@@ -60,7 +50,3 @@

}
const WRAP_NAME = "$$_REQUIRE"; // note: babel will prefix this with _
// Check first the `global` variable as the global object. This way serializers
// can create a local variable called global to fake it as a global object
// without having to pollute the window object on web.
const WRAP_NAME = "$$_REQUIRE";
const IIFE_PARAM = _template.default.expression(

@@ -99,3 +85,2 @@ "typeof globalThis !== 'undefined' ? globalThis : typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : this"

function wrapJson(source, globalPrefix) {
// Unused parameters; remember that's wrapping JSON.
const moduleFactoryParameters = buildParameters(

@@ -133,8 +118,2 @@ "_importDefaultUnused",

}
// Renaming requires should ideally only be done when generating for the target
// that expects the custom require name in the optimize step.
// This visitor currently renames all `require` references even if the module
// contains a custom `require` declaration. This should be fixed by only renaming
// if the `require` symbol hasn't been redeclared.
function renameRequires(ast) {

@@ -141,0 +120,0 @@ let newRequireName = WRAP_NAME;

"use strict";
var _metroFileMap = require("metro-file-map");
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
const createFileMap = require("./DependencyGraph/createFileMap");

@@ -53,5 +42,2 @@ const { ModuleResolver } = require("./DependencyGraph/ModuleResolution");

});
// We can have a lot of graphs listening to Haste for changes.
// Bump this up to silence the max listeners EventEmitter warning.
fileMap.setMaxListeners(1000);

@@ -90,11 +76,5 @@ this._haste = fileMap;

}
// Waits for the dependency graph to become ready after initialisation.
// Don't read anything from the graph until this resolves.
async ready() {
await this._readyPromise;
}
// Creates the dependency graph and waits for it to become ready.
// @deprecated Use the constructor + ready() directly.
static async load(config, options) {

@@ -110,4 +90,2 @@ const self = new DependencyGraph(config, options);

do {
// If we've hit a node_modules directory, the closest package was not
// found (`filePath` was likely nonexistent).
if (path.basename(dir) === "node_modules") {

@@ -133,2 +111,6 @@ return null;

_createModuleResolver() {
const getRealPathIfFile = (path) => {
const result = this._fileSystem.lookup(path);
return result.exists && result.type === "f" ? result.realPath : null;
};
this._moduleResolver = new ModuleResolver({

@@ -166,5 +148,3 @@ assetExts: new Set(this._config.resolver.assetExts),

if (this._config.resolver.unstable_enableSymlinks) {
assets = assets
.map((candidate) => this._fileSystem.getRealPath(candidate))
.filter(Boolean);
assets = assets.map(getRealPathIfFile).filter(Boolean);
} else {

@@ -185,3 +165,3 @@ assets = assets.filter((candidate) =>

unstable_getRealPath: this._config.resolver.unstable_enableSymlinks
? (path) => this._fileSystem.getRealPath(path)
? getRealPathIfFile
: null,

@@ -199,11 +179,2 @@ });

getSha1(filename) {
// Prior to unstable_enableSymlinks:
// Calling realpath allows us to get a hash for a given path even when
// it's a symlink to a file, which prevents Metro from crashing in such a
// case. However, it doesn't allow Metro to track changes to the target file
// of the symlink. We should fix this by implementing a symlink map into
// Metro (or maybe by implementing those "extra transformation sources" we've
// been talking about for stuff like CSS or WASM).
//
// This is unnecessary with a symlink-aware fileSystem implementation.
const resolvedPath = this._config.resolver.unstable_enableSymlinks

@@ -225,7 +196,4 @@ ? filename

end() {
// $FlowFixMe[unused-promise]
this._haste.end();
}
/** Given a search context, return a list of file paths matching the query. */
matchFilesWithContext(from, context) {

@@ -245,3 +213,2 @@ return this._fileSystem.matchFiles({

resolverOptions,
// TODO: Fold assumeFlatNodeModules into resolverOptions and add to graphId
{ assumeFlatNodeModules } = {

@@ -253,12 +220,7 @@ assumeFlatNodeModules: false,

const isSensitiveToOriginFolder =
// Resolution is always relative to the origin folder unless we assume a flat node_modules
!assumeFlatNodeModules ||
// Path requests are resolved relative to the origin folder
to.includes("/") ||
to === "." ||
to === ".." ||
// Preserve standard assumptions under node_modules
from.includes(path.sep + "node_modules" + path.sep);
// Compound key for the resolver cache
const resolverOptionsKey =

@@ -269,4 +231,2 @@ JSON.stringify(resolverOptions ?? {}, canonicalize) ?? "";

const platformKey = platform ?? NULL_PLATFORM;
// Traverse the resolver cache, which is a tree of maps
const mapByResolverOptions = this._resolutionCache;

@@ -273,0 +233,0 @@ const mapByOrigin = getOrCreateMap(

@@ -44,20 +44,6 @@ "use strict";

}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
const ci = require("ci-info");
function getIgnorePattern(config) {
// For now we support both options
const { blockList, blacklistRE } = config.resolver;
const ignorePattern = blacklistRE || blockList;
// If neither option has been set, use default pattern
if (!ignorePattern) {

@@ -85,4 +71,2 @@ return / ^/;

);
// If ignorePattern is an array, merge it into one
if (Array.isArray(ignorePattern)) {

@@ -89,0 +73,0 @@ return combine(ignorePattern);

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -22,6 +11,2 @@

class ModuleResolver {
// A module representing the project root, used as the origin when resolving `emptyModulePath`.
// An empty module, the result of resolving `emptyModulePath` from the project root.
constructor(options) {

@@ -57,3 +42,3 @@ this._options = options;

null,
/* resolverOptions */ {
{
dev: false,

@@ -176,6 +161,3 @@ }

return this._options.moduleCache.getPackage(packageJsonPath).read();
} catch (e) {
// Do nothing. The standard module cache does not trigger any error, but
// the ModuleGraph one does, if the module does not exist.
}
} catch (e) {}
return null;

@@ -187,6 +169,3 @@ };

pkg = this._options.moduleCache.getPackageOf(modulePath);
} catch (e) {
// Do nothing. The standard module cache does not trigger any error, but
// the ModuleGraph one does, if the module does not exist.
}
} catch (e) {}
return pkg != null

@@ -199,6 +178,2 @@ ? {

};
/**
* TODO: Return Resolution instead of coercing to BundlerResolution here
*/
_getFileResolvedModule(resolution) {

@@ -209,4 +184,2 @@ switch (resolution.type) {

case "assetFiles":
// FIXME: we should forward ALL the paths/metadata,
// not just an arbitrary item!
const arbitrary = getArrayLowestItem(resolution.filePaths);

@@ -254,15 +227,2 @@ invariant(arbitrary != null, "invalid asset resolution");

class UnableToResolveError extends Error {
/**
* File path of the module that tried to require a module, ex. `/js/foo.js`.
*/
/**
* The name of the module that was required, no necessarily a path,
* ex. `./bar`, or `invariant`.
*/
/**
* Original error that causes this error
*/
constructor(originModulePath, targetModuleName, message, options) {

@@ -288,6 +248,2 @@ super();

if (error.code === "ENOENT" || error.code === "EISDIR") {
// We're probably dealing with a virtualised file system where
// `this.originModulePath` doesn't actually exist on disk.
// We can't show a code frame, but there's no need to let this I/O
// error shadow the original module resolution error.
return null;

@@ -303,4 +259,3 @@ }

)
: // TODO: Ultimately we shouldn't ever have to guess the location.
guessDependencyLocation(file, this.targetModuleName);
: guessDependencyLocation(file, this.targetModuleName);
return codeFrameColumns(

@@ -315,12 +270,4 @@ fs.readFileSync(this.originModulePath, "utf8"),

}
// Given a source location for an import declaration or `require()` call (etc),
// return a location for use with @babel/code-frame in the resolution error.
function refineDependencyLocation(loc, fileContents, targetSpecifier) {
const lines = fileContents.split("\n");
// If we can find the module name in range of the given loc, surrounded by
// matching quotes, that's likely our specifier. Point to the first column of
// the *last* valid occurrence.
// Note that module names may not always be found in the source code verbatim,
// whether because of escaping or because of exotic dependency APIs.
for (let line = loc.end.line - 1; line >= loc.start.line - 1; line--) {

@@ -334,6 +281,3 @@ const maxColumn =

let offset = lineSlice.lastIndexOf(targetSpecifier);
offset !== -1 &&
// leave room for quotes
offset > 0 &&
offset < lineSlice.length - 1;
offset !== -1 && offset > 0 && offset < lineSlice.length - 1;
offset = lineSlice.lastIndexOf(targetSpecifier, offset - 1)

@@ -354,3 +298,2 @@ ) {

}
// Otherwise, if this is a single-line loc, return it exactly, as a range.
if (loc.start.line === loc.end.line) {

@@ -368,4 +311,2 @@ return {

}
// Otherwise, point to the first column of the loc, to avoid including too
// much unnecessary context.
return {

@@ -372,0 +313,0 @@ start: {

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -37,7 +26,2 @@

}
/**
* Return `null` if the `filePath` doesn't have a valid extension, required
* to describe the type of an asset.
*/
function tryParse(filePath, platforms) {

@@ -44,0 +28,0 @@ const result = parsePlatformFilePath(filePath, platforms);

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -16,7 +5,2 @@

const PATH_RE = /^(.+?)(\.([^.]+))?\.([^.]+)$/;
/**
* Extract the components of a file path that can have a platform specifier: Ex.
* `index.ios.js` is specific to the `ios` platform and has the extension `js`.
*/
function parsePlatformFilePath(filePath, platforms) {

@@ -23,0 +7,0 @@ const dirPath = path.dirname(filePath);

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -17,6 +6,2 @@

class ModuleCache {
// Cache for "closest package.json" queries by module path.
// The inverse of _packagePathByModulePath.
constructor(options) {

@@ -72,7 +57,4 @@ this._getClosestPackage = options.getClosestPackage;

if (this._packagePathByModulePath[filePath]) {
// filePath is a module inside a package.
const packagePath = this._packagePathByModulePath[filePath];
delete this._packagePathByModulePath[filePath];
// This change doesn't invalidate any cached "closest package.json"
// queries for the package's other modules. Clean up only this module.
const modulePaths = this._modulePathsByPackagePath[packagePath];

@@ -87,4 +69,2 @@ if (modulePaths) {

if (this._modulePathsByPackagePath[filePath]) {
// filePath is a package. This change invalidates all cached "closest
// package.json" queries for modules inside this package.
const modulePaths = this._modulePathsByPackagePath[filePath];

@@ -91,0 +71,0 @@ for (const modulePath of modulePaths) {

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -75,7 +64,2 @@

this._isEnded = false;
// TODO(T34760917): These two properties should eventually be instantiated
// elsewhere and passed as parameters, since they are also needed by
// the HmrServer.
// The whole bundling/serializing logic should follow as well.
this._createModuleId = config.serializer.createModuleIdFactory();

@@ -259,15 +243,8 @@ this._bundler = new IncrementalBundler(config, {

async getOrderedDependencyPaths(options) {
const {
entryFile,
onProgress,
resolverOptions,
transformOptions,
/* $FlowFixMe(>=0.122.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.122.0 was deployed. To see the error, delete
* this comment and run Flow. */
} = splitBundleOptions({
...Server.DEFAULT_BUNDLE_OPTIONS,
...options,
bundleType: "bundle",
});
const { entryFile, onProgress, resolverOptions, transformOptions } =
splitBundleOptions({
...Server.DEFAULT_BUNDLE_OPTIONS,
...options,
bundleType: "bundle",
});
const { prepend, graph } = await this._bundler.buildGraph(

@@ -286,4 +263,2 @@ entryFile,

parsePlatformFilePath(entryFile, this._platforms).platform;
// $FlowFixMe[incompatible-return]
return await getAllFiles(prepend, graph, {

@@ -345,4 +320,2 @@ platform,

);
// Tell clients to cache this for 1 year.
// This is safe as the asset url contains a hash of the asset.
if (process.env.REACT_NATIVE_ENABLE_ASSET_CACHING === true) {

@@ -402,3 +375,2 @@ res.setHeader("Cache-Control", "max-age=31536000");

} else if (pathname.endsWith(".map")) {
// Chrome dev tools may need to access the source maps.
res.setHeader("Access-Control-Allow-Origin", "devtools://devtools");

@@ -454,7 +426,2 @@ await this._processSourceMapRequest(

} = splitBundleOptions(bundleOptions);
/**
* `entryFile` is relative to projectRoot, we need to use resolution function
* to find the appropriate file with supported extensions.
*/
let resolvedEntryFilePath;

@@ -483,4 +450,2 @@ try {

});
// For resources that support deletion, handle the DELETE method.
if (deleteFn && req.method === "DELETE") {

@@ -513,7 +478,2 @@ const deleteContext = {

);
// We want to throttle the updates so that we only show meaningful
// UI updates slow enough for the client to actually handle them. For
// that, we check the percentage, and only send percentages that are
// actually different and that have increased from the last one we sent.
if (currentProgress > lastProgress || totalFileCount < 10) {

@@ -531,10 +491,2 @@ if (mres instanceof MultipartResponse) {

}
// The `uncork` called internally in Node via `promise.nextTick()` may not fire
// until all of the Promises are resolved because the microtask queue we're
// in could be starving the event loop. This can cause a bug where the progress
// is not actually sent in the response until after bundling is complete. This
// would defeat the purpose of sending progress, so we `uncork` the stream now
// which will force the response to flush to the client immediately.
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
if (res.socket != null && res.socket.uncork != null) {

@@ -626,5 +578,2 @@ res.socket.uncork();

log(
/* $FlowFixMe(>=0.122.0 site=react_native_fb) This comment suppresses
* an error found when Flow v0.122.0 was deployed. To see the error,
* delete this comment and run Flow. */
createActionEndEntry({

@@ -764,5 +713,2 @@ ...logEntry,

if (
// We avoid parsing the dates since the client should never send a more
// recent date than the one returned by the Delta Bundler (if that's the
// case it's fine to return the whole bundle).
req.headers["if-modified-since"] ===

@@ -808,12 +754,7 @@ result.lastModifiedDate.toUTCString()

});
// This function ensures that modules in source maps are sorted in the same
// order as in a plain JS bundle.
_getSortedModules(graph) {
const modules = [...graph.dependencies.values()];
// Assign IDs to modules in a consistent order
for (const module of modules) {
this._createModuleId(module.path);
}
// Sort by IDs
return modules.sort(

@@ -941,4 +882,2 @@ (a, b) => this._createModuleId(a.path) - this._createModuleId(b.path)

{
// Metro returns 0 based columns but codeFrameColumns expects 1-based columns
// $FlowFixMe[unsafe-addition]
start: {

@@ -970,3 +909,2 @@ column: column + 1,

debug("Start symbolication");
/* $FlowFixMe: where is `rawBody` defined? Is it added by the `connect` framework? */
const body = await req.rawBody;

@@ -991,8 +929,5 @@ const parsedBody = JSON.parse(body);

const stack = parsedBody.stack.map(rewriteAndNormalizeStackFrame);
// In case of multiple bundles / HMR, some stack frames can have different URLs from others
const urls = new Set();
stack.forEach((frame) => {
// These urls have been rewritten and normalized above.
const sourceUrl = frame.file;
// Skip `/debuggerWorker.js` which does not need symbolication.
if (

@@ -1051,7 +986,2 @@ sourceUrl != null &&

} = splitBundleOptions(bundleOptions);
/**
* `entryFile` is relative to projectRoot, we need to use resolution function
* to find the appropriate file with supported extensions.
*/
const resolvedEntryFilePath = await this._resolveRelativePath(entryFile, {

@@ -1153,4 +1083,2 @@ relativeTo: "server",

}
// Wait for the server to finish initializing.
async ready() {

@@ -1160,8 +1088,4 @@ await this._bundler.ready();

_shouldAddModuleToIgnoreList(module) {
// TODO: Add flag to Module signifying whether it represents generated code
// and clean up these heuristics.
return (
// Prelude code, see getPrependedScripts.js
module.path === "__prelude__" ||
// Generated require.context() module, see contextModule.js
module.path.includes("?ctx=") ||

@@ -1173,3 +1097,2 @@ this._config.serializer.isThirdPartyModule(module)

function* zip(xs, ys) {
//$FlowIssue #9324959
const ysIter = ys[Symbol.iterator]();

@@ -1176,0 +1099,0 @@ for (const x of xs) {

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -55,4 +44,2 @@

writeHead(status, headers) {
// We can't actually change the response HTTP status code
// because the headers have already been sent
this.setHeader("X-Http-Status", status);

@@ -59,0 +46,0 @@ if (!headers) {

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -27,5 +16,4 @@

},
(name) => name /* no normalization needed */
(name) => name
);
return ({ line1Based, column0Based }) =>

@@ -85,12 +73,7 @@ consumer.functionNameFor({

const mapping = module.map[mappingIndex];
if (
mapping[0] !== generatedPosInModule.line1Based ||
mapping.length < 4 /* no source line/column info */
) {
if (mapping[0] !== generatedPosInModule.line1Based || mapping.length < 4) {
return null;
}
return {
// $FlowFixMe: Length checks do not refine tuple unions.
line1Based: mapping[2],
// $FlowFixMe: Length checks do not refine tuple unions.
column0Based: mapping[3],

@@ -138,11 +121,2 @@ };

}
/**
* `customizeFrame` allows for custom modifications of the symbolicated frame in a stack.
* It can be used to collapse stack frames that are not relevant to users, pointing them
* to more relevant product code instead.
*
* An example usecase is a library throwing an error while sanitizing inputs from product code.
* In some cases, it's more useful to point the developer looking at the error towards the product code directly.
*/
async function customizeFrame(frame) {

@@ -156,10 +130,2 @@ const customizations =

}
/**
* `customizeStack` allows for custom modifications of a symbolicated stack.
* Where `customizeFrame` operates on individual frames, this hook can process the entire stack in context.
*
* Note: `customizeStack` has access to an `extraData` object which can be used to attach metadata
* to the error coming in, to be used by the customizeStack hook.
*/
async function customizeStack(symbolicatedStack) {

@@ -166,0 +132,0 @@ return await config.symbolicator.customizeStack(

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -55,4 +44,2 @@

}
// Wait until everything is written to disk.
await Promise.all(writeFns.map((cb) => cb()));

@@ -59,0 +46,0 @@ }

@@ -1,17 +0,3 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";
/*::
export type * from './bundle.flow';
*/
try {

@@ -18,0 +4,0 @@ require("metro-babel-register").unstable_registerForMetroMonorepo();

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -26,5 +15,2 @@

function save(bundle, options, log) {
// We fork here depending on the platform: while Android is pretty good at
// loading individual assets, iOS has a large overhead when reading hundreds
// of assets from disk.
return options.platform === "android" && !(options.indexedRamBundle === true)

@@ -31,0 +17,0 @@ ? asAssets(bundle, options, log)

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -22,13 +11,4 @@

const path = require("path");
// must not start with a dot, as that won't go into the apk
const MAGIC_RAM_BUNDLE_FILENAME = "UNBUNDLE";
const MODULES_DIR = "js-modules";
/**
* Saves all JS modules of an app as single files
* The startup code (prelude, polyfills etc.) are written to the file
* designated by the `bundleOuput` option.
* All other modules go into a 'js-modules' folder that in the same parent
* directory as the startup file.
*/
function saveAsAssets(bundle, options, log) {

@@ -47,12 +27,9 @@ const {

const modulesDir = path.join(path.dirname(bundleOutput), MODULES_DIR);
const writeUnbundle = createDir(modulesDir).then(
// create the modules directory first
() =>
Promise.all([
writeModules(lazyModules, modulesDir, encoding),
writeFile(bundleOutput, startupCode, encoding),
writeMagicFlagFile(modulesDir),
])
const writeUnbundle = createDir(modulesDir).then(() =>
Promise.all([
writeModules(lazyModules, modulesDir, encoding),
writeFile(bundleOutput, startupCode, encoding),
writeMagicFlagFile(modulesDir),
])
);
// $FlowFixMe[unused-promise]
writeUnbundle.then(() => log("Done writing unbundle output"));

@@ -59,0 +36,0 @@ if (sourcemapOutput) {

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -21,10 +10,2 @@

const SIZEOF_UINT32 = 4;
/**
* Saves all JS modules of an app as a single file, separated with null bytes.
* The file begins with an offset table that contains module ids and their
* lengths/offsets.
* The module id for the startup code (prelude, polyfills etc.) is the
* empty string.
*/
function saveAsIndexedFile(bundle, options, log) {

@@ -88,16 +69,5 @@ const {

function entryOffset(n) {
// 2: num_entries + startup_code_len
// n * 2: each entry consists of two uint32s
return (2 + n * 2) * SIZEOF_UINT32;
}
function buildModuleTable(startupCode, moduleBuffers, moduleGroups) {
// table format:
// - num_entries: uint_32 number of entries
// - startup_code_len: uint_32 length of the startup section
// - entries: entry...
//
// entry:
// - module_offset: uint_32 offset into the modules blob
// - module_length: uint_32 length of the module code in bytes
const moduleIds = [...moduleGroups.modulesById.keys()];

@@ -107,10 +77,4 @@ const maxId = moduleIds.reduce((max, id) => Math.max(max, id));

const table = Buffer.alloc(entryOffset(numEntries)).fill(0);
// num_entries
table.writeUInt32LE(numEntries, 0);
// startup_code_len
table.writeUInt32LE(startupCode.length, SIZEOF_UINT32);
// entries
let codeOffset = startupCode.length;

@@ -122,5 +86,3 @@ moduleBuffers.forEach(({ id, buffer }) => {

const offset = entryOffset(moduleId);
// module_offset
table.writeUInt32LE(codeOffset, offset);
// module_length
table.writeUInt32LE(buffer.length, offset + SIZEOF_UINT32);

@@ -160,8 +122,2 @@ });

function buildTableAndContents(startupCode, modules, moduleGroups, encoding) {
// file contents layout:
// - magic number char[4] 0xE5 0xD1 0x0B 0xFB (0xFB0BD1E5 uint32 LE)
// - offset table table see `buildModuleTables`
// - code blob char[] null-terminated code strings, starting with
// the startup code
const startupCodeBuffer = nullTerminatedBuffer(startupCode, encoding);

@@ -168,0 +124,0 @@ const moduleBuffers = buildModuleBuffers(modules, moduleGroups, encoding);

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -36,4 +25,2 @@

};
// Add map of module id -> source to sourcemap
const module_paths = [];

@@ -40,0 +27,0 @@ startupModules.forEach((m) => {

@@ -1,14 +0,3 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";
module.exports = 0xfb0bd1e5;

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -20,7 +9,3 @@

function lineToLineSourceMap(source, filename = "") {
// The first line mapping in our package is the base64vlq code for zeros (A).
const firstLine = "AAAA;";
// Most other lines in our mappings are all zeros (for module, column etc)
// except for the lineno mapping: curLineno - prevLineno = 1; Which is C.
const line = "AACA;";

@@ -80,3 +65,2 @@ return {

if (moduleGroups && moduleGroups.modulesInGroups.has(id)) {
// this is a module appended to another module
return;

@@ -90,3 +74,3 @@ }

.map((moduleId) => modulesById.get(moduleId))
.filter(Boolean); // needed to appease flow
.filter(Boolean);
otherModules.forEach((m) => {

@@ -93,0 +77,0 @@ groupLines += (0, _countLines.default)(m.code);

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -21,3 +10,2 @@

const writeMap = writeFile(fileName, contents, null);
// $FlowFixMe[unused-promise]
writeMap.then(() => log("Done writing sourcemap output"));

@@ -24,0 +12,0 @@ return writeMap;

@@ -1,16 +0,3 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";
/* This is for retro-compatibility of React Native with older versions of
* Metro. Use the `RamBundle` module directly. */
module.exports = require("./RamBundle");

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -13,0 +2,0 @@

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc