/** * Copyright 2023-present 650 Industries (Expo). All rights reserved. * 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. * * Fork of the Metro transformer worker, but with additional transforms moved to `babel-preset-expo` and modifications made for web support. * https://github.com/facebook/metro/blob/412771475c540b6f85d75d9dcd5a39a6e0753582/packages/metro-transform-worker/src/index.js#L1 */ import { types as t } from '@babel/core'; import type { JsTransformerConfig, JsTransformOptions } from '@expo/metro/metro-transform-worker'; import type { ExpoJsOutput } from '../serializer/jsOutput'; import { type BabelSourceMapSegment, type EncodedMappings, type EncodedTransformerSourceMap } from '../serializer/sourceMap'; import type { CollectedDependencies, Options as CollectDependenciesOptions } from './collect-dependencies'; import { InvalidRequireCallError as InternalInvalidRequireCallError } from './collect-dependencies'; import type { ExpoJsTransformerConfig } from './types'; export { JsTransformOptions }; interface TransformResponse { readonly dependencies: CollectedDependencies['dependencies']; readonly output: readonly ExpoJsOutput[]; } export declare class InvalidRequireCallError extends Error { innerError: InternalInvalidRequireCallError; filename: string; constructor(innerError: InternalInvalidRequireCallError, filename: string); } export declare const minifyCode: (config: Pick, filename: string, code: string, source: string, rawMappings: readonly BabelSourceMapSegment[], reserved?: string[], inputSourceMap?: EncodedTransformerSourceMap) => Promise<{ code: string; map: EncodedMappings; }>; export declare function applyImportSupport(ast: TFile, { filename, options, importDefault, importAll, collectLocations, performConstantFolding, }: { filename: string; options: Pick; importDefault: string; importAll: string; collectLocations?: boolean; performConstantFolding?: boolean; }): { ast: TFile; metadata?: any; }; export declare function transform(config: ExpoJsTransformerConfig, projectRoot: string, filename: string, data: Buffer, options: JsTransformOptions): Promise; export declare function getCacheKey(config: ExpoJsTransformerConfig, opts?: Readonly<{ projectRoot: string; }>): string; export declare function collectDependenciesForShaking(ast: t.File, options: CollectDependenciesOptions): Readonly<{ ast: t.File; dependencyMapName: string; dependencies: readonly Readonly<{ data: import("./collect-dependencies").DependencyData; name: string; }>[]; }>;