Socket
Socket
Sign inDemoInstall

@expo/metro-config

Package Overview
Dependencies
Maintainers
26
Versions
211
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expo/metro-config - npm Package Compare versions

Comparing version 0.17.7 to 0.18.0

18

build/babel-transformer.js

@@ -7,10 +7,4 @@ "use strict";

const node_assert_1 = __importDefault(require("node:assert"));
const node_crypto_1 = __importDefault(require("node:crypto"));
const node_fs_1 = __importDefault(require("node:fs"));
const loadBabelConfig_1 = require("./loadBabelConfig");
const transformSync_1 = require("./transformSync");
const cacheKeyParts = [
node_fs_1.default.readFileSync(__filename),
require('babel-preset-fbjs/package.json').version,
];
function isCustomTruthy(value) {

@@ -36,3 +30,5 @@ return value === true || value === 'true';

const isNodeModule = filename.includes('node_modules');
const isServer = options.customTransformOptions?.environment === 'node';
const isReactServer = options.customTransformOptions?.environment === 'react-server';
const isGenericServer = options.customTransformOptions?.environment === 'node';
const isServer = isReactServer || isGenericServer;
const routerRoot = typeof options.customTransformOptions?.routerRoot === 'string'

@@ -51,2 +47,4 @@ ? decodeURI(options.customTransformOptions.routerRoot)

isServer,
// Enable React Server Component rules for AST.
isReactServer,
// The base url to make requests from, used for hosting from non-standard locations.

@@ -127,12 +125,6 @@ baseUrl: typeof options.customTransformOptions?.baseUrl === 'string'

};
function getCacheKey() {
const key = node_crypto_1.default.createHash('md5');
cacheKeyParts.forEach((part) => key.update(part));
return key.digest('hex');
}
const babelTransformer = {
transform,
getCacheKey,
};
module.exports = babelTransformer;
//# sourceMappingURL=babel-transformer.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDefaultCustomizeFrame = exports.INTERNAL_CALLSITES_REGEX = void 0;
exports.INTERNAL_CALLSITES_REGEX = void 0;
exports.getDefaultCustomizeFrame = getDefaultCustomizeFrame;
const url_1 = require("url");

@@ -96,3 +97,2 @@ // Import only the types here, the values will be imported from the project, at runtime.

}
exports.getDefaultCustomizeFrame = getDefaultCustomizeFrame;
//# sourceMappingURL=customizeFrame.js.map

@@ -29,3 +29,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.EXPO_DEBUG = exports.INTERNAL_CALLSITES_REGEX = exports.getDefaultConfig = void 0;
exports.EXPO_DEBUG = exports.INTERNAL_CALLSITES_REGEX = void 0;
exports.getDefaultConfig = getDefaultConfig;
// Copyright 2023-present 650 Industries (Expo). All rights reserved.

@@ -96,15 +97,5 @@ const config_1 = require("@expo/config");

hasWarnedAboutExotic = true;
console.log(chalk_1.default.gray(`\u203A Feature ${chalk_1.default.bold `EXPO_USE_EXOTIC`} is no longer supported.`));
console.log(chalk_1.default.gray(`\u203A Feature ${chalk_1.default.bold `EXPO_USE_EXOTIC`} has been removed in favor of the default transformer.`));
}
const reactNativePath = path_1.default.dirname((0, resolve_from_1.default)(projectRoot, 'react-native/package.json'));
try {
// Set the `EXPO_METRO_CACHE_KEY_VERSION` variable for use in the custom babel transformer.
// This hack is used because there doesn't appear to be anyway to resolve
// `babel-preset-fbjs` relative to the project root later (in `metro-expo-babel-transformer`).
const babelPresetFbjsPath = (0, resolve_from_1.default)(projectRoot, 'babel-preset-fbjs/package.json');
process.env.EXPO_METRO_CACHE_KEY_VERSION = String(require(babelPresetFbjsPath).version);
}
catch {
// noop -- falls back to a hardcoded value.
}
const sourceExtsConfig = { isTS: true, isReact: true, isModern: true };

@@ -235,3 +226,2 @@ const sourceExts = (0, paths_1.getBareExtensions)([], sourceExtsConfig);

}
exports.getDefaultConfig = getDefaultConfig;
// re-export for legacy cases.

@@ -238,0 +228,0 @@ exports.EXPO_DEBUG = env_1.env.EXPO_DEBUG;

@@ -1,2 +0,1 @@

/// <reference types="node" />
import UpstreamFileStore from 'metro-cache/src/stores/FileStore';

@@ -3,0 +2,0 @@ export declare class FileStore<T> extends UpstreamFileStore<T> {

@@ -6,3 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getServerRoot = exports.getModulesPaths = exports.getWorkspaceRoot = void 0;
exports.getWorkspaceRoot = getWorkspaceRoot;
exports.getModulesPaths = getModulesPaths;
exports.getServerRoot = getServerRoot;
const find_yarn_workspace_root_1 = __importDefault(require("find-yarn-workspace-root"));

@@ -23,3 +25,2 @@ const path_1 = __importDefault(require("path"));

}
exports.getWorkspaceRoot = getWorkspaceRoot;
function getModulesPaths(projectRoot) {

@@ -36,3 +37,2 @@ const paths = [];

}
exports.getModulesPaths = getModulesPaths;
function getServerRoot(projectRoot) {

@@ -43,3 +43,2 @@ return env_1.env.EXPO_USE_METRO_WORKSPACE_ROOT

}
exports.getServerRoot = getServerRoot;
//# sourceMappingURL=getModulesPaths.js.map

@@ -6,3 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getWatchFolders = exports.resolveAllWorkspacePackageJsonPaths = exports.globAllPackageJsonPaths = void 0;
exports.globAllPackageJsonPaths = globAllPackageJsonPaths;
exports.resolveAllWorkspacePackageJsonPaths = resolveAllWorkspacePackageJsonPaths;
exports.getWatchFolders = getWatchFolders;
const assert_1 = __importDefault(require("assert"));

@@ -49,3 +51,2 @@ const fs_1 = __importDefault(require("fs"));

}
exports.globAllPackageJsonPaths = globAllPackageJsonPaths;
function getWorkspacePackagesArray({ workspaces }) {

@@ -76,3 +77,2 @@ if (Array.isArray(workspaces)) {

}
exports.resolveAllWorkspacePackageJsonPaths = resolveAllWorkspacePackageJsonPaths;
/**

@@ -97,3 +97,2 @@ * @param projectRoot file path to app's project root

}
exports.getWatchFolders = getWatchFolders;
function uniqueItems(items) {

@@ -100,0 +99,0 @@ return [...new Set(items)];

@@ -1,2 +0,2 @@

import { TransformOptions } from './babel-core';
import type { TransformOptions } from './babel-core';
/**

@@ -3,0 +3,0 @@ * Returns a memoized function that checks for the existence of a

@@ -6,3 +6,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getRewriteRequestUrl = exports.getRouterDirectory = void 0;
exports.getRouterDirectory = getRouterDirectory;
exports.getRewriteRequestUrl = getRewriteRequestUrl;
// Copyright 2023-present 650 Industries (Expo). All rights reserved.

@@ -48,3 +49,2 @@ const config_1 = require("@expo/config");

}
exports.getRouterDirectory = getRouterDirectory;
function getRewriteRequestUrl(projectRoot) {

@@ -100,3 +100,2 @@ function rewriteExpoRequestUrl(url) {

}
exports.getRewriteRequestUrl = getRewriteRequestUrl;
//# sourceMappingURL=rewriteRequestUrl.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.stringToUUID = void 0;
exports.stringToUUID = stringToUUID;
const node_crypto_1 = __importDefault(require("node:crypto"));

@@ -38,3 +38,2 @@ /**

}
exports.stringToUUID = stringToUUID;
//# sourceMappingURL=debugId.js.map

@@ -6,3 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.environmentVariableSerializerPlugin = exports.serverPreludeSerializerPlugin = exports.getTransformEnvironment = void 0;
exports.getTransformEnvironment = getTransformEnvironment;
exports.serverPreludeSerializerPlugin = serverPreludeSerializerPlugin;
exports.environmentVariableSerializerPlugin = environmentVariableSerializerPlugin;
const CountingSet_1 = __importDefault(require("metro/src/lib/CountingSet"));

@@ -15,3 +17,2 @@ const countLines_1 = __importDefault(require("metro/src/lib/countLines"));

}
exports.getTransformEnvironment = getTransformEnvironment;
function getAllExpoPublicEnvVars() {

@@ -33,3 +34,3 @@ // Create an object containing all environment variables that start with EXPO_PUBLIC_

const env = getTransformEnvironment(options.sourceUrl);
return env === 'node';
return env === 'node' || env === 'react-server';
}

@@ -39,3 +40,4 @@ return false;

// Other requests will use customTransformOptions.environment.
return graph.transformOptions.customTransformOptions.environment === 'node';
const env = graph.transformOptions.customTransformOptions.environment;
return env === 'node' || env === 'react-server';
}

@@ -55,3 +57,2 @@ /** Strips the process.env polyfill in server environments to allow for accessing environment variables off the global. */

}
exports.serverPreludeSerializerPlugin = serverPreludeSerializerPlugin;
function environmentVariableSerializerPlugin(entryPoint, preModules, graph, options) {

@@ -91,3 +92,2 @@ // Skip replacement in Node.js environments.

}
exports.environmentVariableSerializerPlugin = environmentVariableSerializerPlugin;
function getEnvPrelude(contents) {

@@ -94,0 +94,0 @@ const code = '// HMR env vars from Expo CLI (dev-only)\n' + contents;

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.buildHermesBundleAsync = void 0;
exports.buildHermesBundleAsync = buildHermesBundleAsync;
const spawn_async_1 = __importDefault(require("@expo/spawn-async"));

@@ -60,3 +60,2 @@ const chalk_1 = __importDefault(require("chalk"));

}
exports.buildHermesBundleAsync = buildHermesBundleAsync;
async function directlyBuildHermesBundleAsync({ code, map, minify = false, filename, }) {

@@ -63,0 +62,0 @@ const tempDir = path_1.default.join(os_1.default.tmpdir(), `expo-bundler-${Math.random()}-${Date.now()}`);

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getExportPathForDependencyWithOptions = void 0;
exports.getExportPathForDependencyWithOptions = getExportPathForDependencyWithOptions;
/**

@@ -27,3 +27,2 @@ * Copyright © 2023 650 Industries.

}
exports.getExportPathForDependencyWithOptions = getExportPathForDependencyWithOptions;
//# sourceMappingURL=exportPath.js.map

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.baseJSBundleWithDependencies = exports.baseJSBundle = exports.getBaseUrlOption = exports.getSplitChunksOption = exports.getPlatformOption = void 0;
exports.getPlatformOption = getPlatformOption;
exports.getSplitChunksOption = getSplitChunksOption;
exports.getBaseUrlOption = getBaseUrlOption;
exports.baseJSBundle = baseJSBundle;
exports.baseJSBundleWithDependencies = baseJSBundleWithDependencies;
const jsc_safe_url_1 = require("jsc-safe-url");

@@ -36,3 +40,2 @@ const CountingSet_1 = __importDefault(require("metro/src/lib/CountingSet"));

}
exports.getPlatformOption = getPlatformOption;
function getSplitChunksOption(graph, options) {

@@ -42,3 +45,2 @@ // Only enable when the entire bundle is being split, and only run on web.

}
exports.getSplitChunksOption = getSplitChunksOption;
function getBaseUrlOption(graph, options) {

@@ -54,3 +56,2 @@ const baseUrl = graph.transformOptions?.customTransformOptions?.baseUrl;

}
exports.getBaseUrlOption = getBaseUrlOption;
function baseJSBundle(entryPoint, preModules, graph, options) {

@@ -70,3 +71,2 @@ const platform = getPlatformOption(graph, options);

}
exports.baseJSBundle = baseJSBundle;
function baseJSBundleWithDependencies(entryPoint, preModules, dependencies, options) {

@@ -151,3 +151,2 @@ for (const module of dependencies) {

}
exports.baseJSBundleWithDependencies = baseJSBundleWithDependencies;
//# sourceMappingURL=baseJSBundle.js.map

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.isJsOutput = exports.isJsModule = exports.getJsOutput = exports.getModuleParams = exports.wrapModule = void 0;
exports.wrapModule = wrapModule;
exports.getModuleParams = getModuleParams;
exports.getJsOutput = getJsOutput;
exports.isJsModule = isJsModule;
exports.isJsOutput = isJsOutput;
const assert_1 = __importDefault(require("assert"));

@@ -34,3 +38,2 @@ const jsc_safe_url_1 = __importDefault(require("jsc-safe-url"));

}
exports.wrapModule = wrapModule;
function getModuleParams(module, options) {

@@ -90,3 +93,2 @@ const moduleId = options.createModuleId(module.path);

}
exports.getModuleParams = getModuleParams;
function getJsOutput(module) {

@@ -99,11 +101,8 @@ const jsModules = module.output.filter(({ type }) => type.startsWith('js/'));

}
exports.getJsOutput = getJsOutput;
function isJsModule(module) {
return module.output.filter(isJsOutput).length > 0;
}
exports.isJsModule = isJsModule;
function isJsOutput(output) {
return output.type.startsWith('js/');
}
exports.isJsOutput = isJsOutput;
//# sourceMappingURL=js.js.map

@@ -10,3 +10,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.processModules = void 0;
exports.processModules = processModules;
const js_1 = require("./js");

@@ -32,3 +32,2 @@ function processModules(modules, { filter = () => true, createModuleId, dev, includeAsyncPaths, projectRoot, serverRoot, sourceUrl, splitChunks, skipWrapping, computedAsyncModulePaths, }) {

}
exports.processModules = processModules;
//# sourceMappingURL=processModules.js.map

@@ -6,3 +6,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getFileName = exports.fileNameFromContents = exports.getCssSerialAssets = exports.filterJsModules = void 0;
exports.filterJsModules = filterJsModules;
exports.getCssSerialAssets = getCssSerialAssets;
exports.fileNameFromContents = fileNameFromContents;
exports.getFileName = getFileName;
const js_1 = require("metro/src/DeltaBundler/Serializers/helpers/js");

@@ -26,3 +29,2 @@ const path_1 = __importDefault(require("path"));

}
exports.filterJsModules = filterJsModules;
function getCssSerialAssets(dependencies, { processModuleFilter, projectRoot }) {

@@ -60,3 +62,2 @@ const assets = [];

}
exports.getCssSerialAssets = getCssSerialAssets;
function getCssMetadata(module) {

@@ -77,7 +78,5 @@ const data = module.output[0]?.data;

}
exports.fileNameFromContents = fileNameFromContents;
function getFileName(module) {
return path_1.default.basename(module).replace(/\.[^.]+$/, '');
}
exports.getFileName = getFileName;
//# sourceMappingURL=getCssDeps.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isTransformOptionTruthy = exports.isExpoJsOutput = void 0;
exports.isExpoJsOutput = isExpoJsOutput;
exports.isTransformOptionTruthy = isTransformOptionTruthy;
function isExpoJsOutput(output) {
return 'data' in output && typeof output.data === 'object';
}
exports.isExpoJsOutput = isExpoJsOutput;
// Because transform options can be passed directly during export, or through a query parameter

@@ -13,3 +13,2 @@ // during a request, we need to normalize the options.

}
exports.isTransformOptionTruthy = isTransformOptionTruthy;
//# sourceMappingURL=jsOutput.js.map

@@ -6,3 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getSortedModules = exports.Chunk = exports.graphToSerialAssetsAsync = void 0;
exports.Chunk = void 0;
exports.graphToSerialAssetsAsync = graphToSerialAssetsAsync;
exports.getSortedModules = getSortedModules;
/**

@@ -120,3 +122,3 @@ * Copyright © 2023 650 Industries.

platform: (0, baseJSBundle_1.getPlatformOption)(graph, options) ?? 'web',
projectRoot: options.projectRoot,
projectRoot: options.projectRoot, // this._getServerRootDir(),
publicPath,

@@ -126,3 +128,2 @@ }));

}
exports.graphToSerialAssetsAsync = graphToSerialAssetsAsync;
class Chunk {

@@ -209,7 +210,13 @@ name;

module.dependencies.forEach((dependency) => {
if (dependency.data.data.asyncType === 'async') {
if (dependency.data.data.asyncType) {
const chunkContainingModule = chunks.find((chunk) => chunk.hasAbsolutePath(dependency.absolutePath));
(0, assert_1.default)(chunkContainingModule, 'Chunk containing module not found: ' + dependency.absolutePath);
const moduleIdName = chunkContainingModule.getFilenameForConfig(serializerConfig);
computedAsyncModulePaths[dependency.absolutePath] = (baseUrl ?? '/') + moduleIdName;
// NOTE(kitten): We shouldn't have any async imports on non-async chunks
// However, due to how chunks merge, some async imports may now be pointing
// at entrypoint (or vendor) chunks. We omit the path so that the async import
// helper doesn't reload and reevaluate the entrypoint.
if (chunkContainingModule.isAsync) {
const moduleIdName = chunkContainingModule.getFilenameForConfig(serializerConfig);
computedAsyncModulePaths[dependency.absolutePath] = (baseUrl ?? '/') + moduleIdName;
}
}

@@ -419,3 +426,3 @@ });

for (const dependency of entryModule.dependencies.values()) {
if (dependency.data.data.asyncType === 'async' &&
if (dependency.data.data.asyncType &&
// Support disabling multiple chunks.

@@ -458,3 +465,2 @@ splitChunks) {

}
exports.getSortedModules = getSortedModules;
//# sourceMappingURL=serializeChunks.js.map

@@ -6,3 +6,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createSerializerFromSerialProcessors = exports.createDefaultExportCustomSerializer = exports.withSerializerPlugins = exports.withExpoSerializers = void 0;
exports.withExpoSerializers = withExpoSerializers;
exports.withSerializerPlugins = withSerializerPlugins;
exports.createDefaultExportCustomSerializer = createDefaultExportCustomSerializer;
exports.createSerializerFromSerialProcessors = createSerializerFromSerialProcessors;
/**

@@ -30,3 +33,2 @@ * Copyright © 2022 650 Industries.

}
exports.withExpoSerializers = withExpoSerializers;
// There can only be one custom serializer as the input doesn't match the output.

@@ -44,3 +46,2 @@ // Here we simply run

}
exports.withSerializerPlugins = withSerializerPlugins;
function createDefaultExportCustomSerializer(config, configOptions = {}) {

@@ -130,3 +131,2 @@ return async (entryPoint, preModules, graph, options) => {

}
exports.createDefaultExportCustomSerializer = createDefaultExportCustomSerializer;
function getDefaultSerializer(config, fallbackSerializer, configOptions = {}) {

@@ -189,3 +189,2 @@ const defaultSerializer = fallbackSerializer ?? createDefaultExportCustomSerializer(config, configOptions);

}
exports.createSerializerFromSerialProcessors = createSerializerFromSerialProcessors;
//# sourceMappingURL=withExpoSerializers.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.transform = void 0;
exports.transform = transform;
/**

@@ -34,3 +34,2 @@ * Copyright 2023-present 650 Industries (Expo). All rights reserved.

}
exports.transform = transform;
//# sourceMappingURL=asset-transformer.js.map

@@ -1,2 +0,1 @@

/// <reference types="node" />
export declare function transformCssModuleWeb(props: {

@@ -3,0 +2,0 @@ filename: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.matchCssModule = exports.convertLightningCssToReactNativeWebStyleSheet = exports.transformCssModuleWeb = void 0;
exports.transformCssModuleWeb = transformCssModuleWeb;
exports.convertLightningCssToReactNativeWebStyleSheet = convertLightningCssToReactNativeWebStyleSheet;
exports.matchCssModule = matchCssModule;
const css_1 = require("./css");

@@ -39,3 +41,2 @@ const RNW_CSS_CLASS_ID = '_';

}
exports.transformCssModuleWeb = transformCssModuleWeb;
function convertLightningCssToReactNativeWebStyleSheet(input) {

@@ -64,7 +65,5 @@ const styles = {};

}
exports.convertLightningCssToReactNativeWebStyleSheet = convertLightningCssToReactNativeWebStyleSheet;
function matchCssModule(filePath) {
return !!/\.module(\.(native|ios|android|web))?\.(css|s[ac]ss)$/.test(filePath);
}
exports.matchCssModule = matchCssModule;
//# sourceMappingURL=css-modules.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.escapeBackticksAndOctals = exports.wrapDevelopmentCSS = exports.getHotReplaceTemplate = exports.pathToHtmlSafeName = void 0;
exports.pathToHtmlSafeName = pathToHtmlSafeName;
exports.getHotReplaceTemplate = getHotReplaceTemplate;
exports.wrapDevelopmentCSS = wrapDevelopmentCSS;
exports.escapeBackticksAndOctals = escapeBackticksAndOctals;
function pathToHtmlSafeName(path) {
return path.replace(/[^a-zA-Z0-9_]/g, '_');
}
exports.pathToHtmlSafeName = pathToHtmlSafeName;
function getHotReplaceTemplate(id) {

@@ -19,7 +21,6 @@ // In dev mode, we need to replace the style tag instead of appending it

}
exports.getHotReplaceTemplate = getHotReplaceTemplate;
function wrapDevelopmentCSS(props) {
const withBackTicksEscaped = escapeBackticksAndOctals(props.src);
return `(() => {
if (typeof document === 'undefined') {
if (typeof window === 'undefined') {
return

@@ -40,3 +41,2 @@ }

}
exports.wrapDevelopmentCSS = wrapDevelopmentCSS;
function escapeBackticksAndOctals(str) {

@@ -51,3 +51,2 @@ if (typeof str !== 'string') {

}
exports.escapeBackticksAndOctals = escapeBackticksAndOctals;
//# sourceMappingURL=css.js.map

@@ -6,3 +6,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getUniversalAssetData = void 0;
exports.getUniversalAssetData = getUniversalAssetData;
exports.default = getAssets;
const Assets_1 = require("metro/src/Assets");

@@ -35,3 +36,2 @@ const js_1 = require("metro/src/DeltaBundler/Serializers/helpers/js");

}
exports.getUniversalAssetData = getUniversalAssetData;
async function getAssets(dependencies, options) {

@@ -50,3 +50,2 @@ const promises = [];

}
exports.default = getAssets;
//# sourceMappingURL=getAssets.js.map

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

/// <reference types="node" />
/// <reference types="metro" />
import type { TransformResultDependency } from 'metro/src/DeltaBundler';

@@ -4,0 +2,0 @@ import { JsOutput, JsTransformerConfig, JsTransformOptions } from 'metro-transform-worker';

@@ -29,3 +29,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getCacheKey = exports.transform = void 0;
exports.transform = transform;
exports.getCacheKey = getCacheKey;
/**

@@ -163,23 +164,39 @@ * Copyright 2023-present 650 Industries (Expo). All rights reserved.

// TODO: This MUST be run even though no plugins are added, otherwise the babel runtime generators are broken.
// if (plugins.length) {
ast = nullthrows(
// @ts-expect-error
(0, core_1.transformFromAstSync)(ast, '', {
ast: true,
babelrc: false,
code: false,
configFile: false,
comments: true,
filename: file.filename,
plugins,
sourceMaps: false,
// Not-Cloning the input AST here should be safe because other code paths above this call
// are mutating the AST as well and no code is depending on the original AST.
// However, switching the flag to false caused issues with ES Modules if `experimentalImportSupport` isn't used https://github.com/facebook/metro/issues/641
// either because one of the plugins is doing something funky or Babel messes up some caches.
// Make sure to test the above mentioned case before flipping the flag back to false.
cloneInputAst: true,
}).ast);
// }
if (plugins.length) {
ast = nullthrows(
// @ts-expect-error
(0, core_1.transformFromAstSync)(ast, '', {
ast: true,
babelrc: false,
code: false,
configFile: false,
comments: true,
filename: file.filename,
plugins,
sourceMaps: false,
// NOTE(kitten): This was done to wipe the paths/scope caches, which the `constantFoldingPlugin` needs to work,
// but has been replaced with `programPath.scope.crawl()`.
// Old Note from Metro:
// > Not-Cloning the input AST here should be safe because other code paths above this call
// > are mutating the AST as well and no code is depending on the original AST.
// > However, switching the flag to false caused issues with ES Modules if `experimentalImportSupport` isn't used https://github.com/facebook/metro/issues/641
// > either because one of the plugins is doing something funky or Babel messes up some caches.
// > Make sure to test the above mentioned case before flipping the flag back to false.
cloneInputAst: false,
}).ast);
}
if (!options.dev) {
// NOTE(kitten): Any Babel helpers that have been added (`path.hub.addHelper(...)`) will usually not have any
// references, and hence the `constantFoldingPlugin` below will remove them.
// To fix the references we add an explicit `programPath.scope.crawl()`. Alternatively, we could also wipe the
// Babel traversal cache (`traverse.cache.clear()`)
const clearProgramScopePlugin = {
visitor: {
Program: {
enter(path) {
path.scope.crawl();
},
},
},
};
// Run the constant folding plugin in its own pass, avoiding race conditions

@@ -197,4 +214,10 @@ // with other plugins that have exit() visitors on Program (e.g. the ESM

filename: file.filename,
plugins: [[metro_transform_plugins_1.default.constantFoldingPlugin, babelPluginOpts]],
plugins: [
clearProgramScopePlugin,
[metro_transform_plugins_1.default.constantFoldingPlugin, babelPluginOpts],
],
sourceMaps: false,
// NOTE(kitten): In Metro, this is also false, but only works because the prior run of `transformFromAstSync` was always
// running with `cloneInputAst: true`.
// This isn't needed anymore since `clearProgramScopePlugin` re-crawls the AST’s scope instead.
cloneInputAst: false,

@@ -412,3 +435,2 @@ }).ast);

}
exports.transform = transform;
function getCacheKey(config) {

@@ -432,3 +454,2 @@ const { babelTransformerPath, minifierPath, ...remainingConfig } = config;

}
exports.getCacheKey = getCacheKey;
//# sourceMappingURL=metro-transform-worker.js.map

@@ -6,3 +6,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getPostcssConfigHash = exports.resolvePostcssConfig = exports.pluginFactory = exports.transformPostCssModule = void 0;
exports.transformPostCssModule = transformPostCssModule;
exports.pluginFactory = pluginFactory;
exports.resolvePostcssConfig = resolvePostcssConfig;
exports.getPostcssConfigHash = getPostcssConfigHash;
/**

@@ -35,3 +38,2 @@ * Copyright © 2023 650 Industries.

}
exports.transformPostCssModule = transformPostCssModule;
async function processWithPostcssInputConfigAsync(projectRoot, { src, filename, inputConfig }) {

@@ -179,3 +181,2 @@ const { plugins, processOptions } = await parsePostcssConfigAsync(projectRoot, {

}
exports.pluginFactory = pluginFactory;
function resolvePostcssConfig(projectRoot) {

@@ -195,3 +196,2 @@ // TODO: Maybe support platform-specific postcss config files in the future.

}
exports.resolvePostcssConfig = resolvePostcssConfig;
function getPostcssConfigHash(projectRoot) {

@@ -210,3 +210,2 @@ // TODO: Maybe recurse plugins and add versions to the hash in the future.

}
exports.getPostcssConfigHash = getPostcssConfigHash;
//# sourceMappingURL=postcss.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.shouldMinify = void 0;
exports.shouldMinify = shouldMinify;
function isHermesEngine(options) {

@@ -20,3 +20,2 @@ // NOTE: This has multiple inputs since we also use the `customTransformOptions.engine` option to indicate the Hermes engine.

}
exports.shouldMinify = shouldMinify;
//# sourceMappingURL=resolveOptions.js.map

@@ -1,2 +0,1 @@

/// <reference types="source-map-js" />
export declare function matchSass(filename: string): import('sass').Syntax | null;

@@ -3,0 +2,0 @@ export declare function compileSass(projectRoot: string, { filename, src }: {

@@ -6,3 +6,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.compileSass = exports.matchSass = void 0;
exports.matchSass = matchSass;
exports.compileSass = compileSass;
const resolve_from_1 = __importDefault(require("resolve-from"));

@@ -29,3 +30,2 @@ let sassInstance = null;

}
exports.matchSass = matchSass;
function compileSass(projectRoot, { filename, src },

@@ -42,3 +42,2 @@ // TODO: Expose to users somehow...

}
exports.compileSass = compileSass;
//# sourceMappingURL=sass.js.map

@@ -1,3 +0,2 @@

/// <reference types="node" />
import type { JsTransformerConfig, JsTransformOptions, TransformResponse } from 'metro-transform-worker';
export declare function transform(config: JsTransformerConfig, projectRoot: string, filename: string, data: Buffer, options: JsTransformOptions): Promise<TransformResponse>;

@@ -29,3 +29,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.transform = void 0;
exports.transform = transform;
/**

@@ -49,3 +49,4 @@ * Copyright 2023-present 650 Industries (Expo). All rights reserved.

const environment = options.customTransformOptions?.environment;
if (environment !== 'node' &&
const isClientEnvironment = environment !== 'node' && environment !== 'react-server';
if (isClientEnvironment &&
// TODO: Ensure this works with windows.

@@ -63,3 +64,3 @@ (filename.match(new RegExp(`^app/\\+html(\\.${options.platform})?\\.([tj]sx?|[cm]js)?$`)) ||

}
if (environment !== 'node' &&
if (isClientEnvironment &&
!filename.match(/\/node_modules\//) &&

@@ -174,3 +175,2 @@ filename.match(/\+api(\.(native|ios|android|web))?\.[tj]sx?$/)) {

}
exports.transform = transform;
/**

@@ -177,0 +177,0 @@ * A custom Metro transformer that adds support for processing Expo-specific bundler features.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.requireUncachedFile = exports.tryRequireThenImport = void 0;
exports.tryRequireThenImport = tryRequireThenImport;
exports.requireUncachedFile = requireUncachedFile;
async function tryRequireThenImport(moduleId) {

@@ -23,3 +24,2 @@ try {

}
exports.tryRequireThenImport = tryRequireThenImport;
function requireUncachedFile(moduleId) {

@@ -40,3 +40,2 @@ try {

}
exports.requireUncachedFile = requireUncachedFile;
//# sourceMappingURL=require.js.map

@@ -26,3 +26,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.transformSync = void 0;
exports.transformSync = transformSync;
/**

@@ -49,3 +49,2 @@ * Copyright (c) 650 Industries (Expo). All rights reserved.

}
exports.transformSync = transformSync;
function parseWithHermes(src, babelConfig) {

@@ -52,0 +51,0 @@ const sourceAst = require('hermes-parser').parse(src, {

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.importMetroConfig = void 0;
exports.importMetroConfig = importMetroConfig;
const resolve_from_1 = __importDefault(require("resolve-from"));

@@ -18,3 +18,2 @@ // ensure that Metro can bundle the project's assets (see: `watchFolders`).

}
exports.importMetroConfig = importMetroConfig;
//# sourceMappingURL=metro-config.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.hashString = void 0;
exports.hashString = hashString;
const crypto_1 = __importDefault(require("crypto"));

@@ -12,3 +12,2 @@ function hashString(str) {

}
exports.hashString = hashString;
//# sourceMappingURL=hash.js.map
{
"name": "@expo/metro-config",
"version": "0.17.7",
"version": "0.18.0",
"description": "A Metro config for running React Native projects with the Metro bundler",

@@ -32,3 +32,2 @@ "main": "build/ExpoMetroConfig.js",

"build",
"transformer",
"file-store",

@@ -42,7 +41,6 @@ "babel-transformer"

"@babel/types": "^7.20.0",
"@expo/config": "~8.5.0",
"@expo/env": "~0.2.2",
"@expo/config": "~9.0.0-beta.0",
"@expo/env": "~0.3.0",
"@expo/json-file": "~8.3.0",
"@expo/spawn-async": "^1.7.2",
"babel-preset-fbjs": "^3.4.0",
"chalk": "^4.1.0",

@@ -57,8 +55,4 @@ "debug": "^4.3.2",

"postcss": "~8.4.32",
"resolve-from": "^5.0.0",
"sucrase": "3.34.0"
"resolve-from": "^5.0.0"
},
"peerDependencies": {
"@react-native/babel-preset": "*"
},
"devDependencies": {

@@ -72,3 +66,3 @@ "@jridgewell/trace-mapping": "^0.3.20",

},
"gitHead": "8be4417d2f8566f65b85bc135e145b0234b6a8aa"
"gitHead": "4165b8d72e1b9a1889c2767534cc619e21468110"
}
# `@expo/metro-config`
This package contains the default Metro config that is required for bundling Expo apps.
This package contains the default Metro config that is required for bundling apps with Expo CLI. Refer to the [Expo `metro.config.js` docs](https://docs.expo.dev/versions/latest/config/metro/) to learn more.

@@ -19,48 +19,6 @@ `metro.config.js`

> As of SDK 51, the exotic transformer has been fully removed in favor of the default `@expo/metro-config` transformer. The export `@expo/metro-config/transformer` no longer exists.
Most of the [Exotic mode](https://blog.expo.dev/drastically-faster-bundling-in-react-native-a54f268e0ed1) performance benefits have been integrated in the default Expo CLI bundling pipeline (e.g. [less AST cloning](https://github.com/facebook/metro/pull/854), [faster worker creation](https://github.com/facebook/metro/pull/856)), and as such, the feature no longer needs to be enabled/disabled. Setting `mode: "exotic"` will no longer have any additional effects over the default.
If you'd like to use different transformers (e.g. Sucrase) for different files, you can still create a custom transformer and refine it for your project needs.
### Custom transformers
> Caution: This is an advanced feature for developers who need to speed up the bundling of very large apps.
You can use `@expo/metro-config/transformer` to create a custom multi-rule transformer. This is useful for running fewer transformations on node modules and speeding up bundling.
`metro.transformer.js`
```js
const { createExoticTransformer } = require('@expo/metro-config/transformer');
module.exports = createExoticTransformer({
transpileModules: ['@stripe/stripe-react-native'],
// You can uncomment the following lines to add any extra node_modules paths in a monorepo:
// nodeModulesPaths: [
// 'node_modules',
// // Generally you'll add this when your config is in `apps/my-app/metro.config.js`
// '../../node_modules',
// // If you have custom packages in a `packages/` folder
// '../../packages',
// ],
});
```
Then use it in your project:
`metro.config.js`
```js
const { getDefaultConfig } = require('@expo/metro-config');
const config = getDefaultConfig(__dirname);
// Use the new transformer
config.transformer.babelTransformerPath = require.resolve('./metro.transformer');
// Optionally, you can add support for the `react-native` resolver field back
// doing this will increase bundling time and size as many community packages ship untransformed code using this feature.
// Other packages like `nanoid` use the field to support `react-native` so you may need to enable it regardless.
// defaultConfig.resolver.resolverMainFields.unshift('react-native');
module.exports = config;
```
Ensure you extend the `@expo/metro-config/babel-transformer` when customizing babel. Learn more: [Extending the Babel transformer](https://docs.expo.dev/versions/latest/config/metro/#extending-the-babel-transformer).

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

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

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

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

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

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

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

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