@expo/metro-config 0.11.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -65,7 +65,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
65
65
  * LICENSE file in the root directory of this source tree.
66
66
  */
67
67
  // A fork of the upstream babel-transformer that uses Expo-specific babel defaults
68
- // and adds support for web and Node.js environments via `metroTarget` on the Babel caller.
68
+ // and adds support for web and Node.js environments via `isServer` on the Babel caller.
69
69
 
70
70
  // @ts-expect-error
71
71
 
@@ -243,8 +243,7 @@ const transform = ({
243
243
  platform: options.platform,
244
244
  // Empower the babel preset to know the env it's bundling for.
245
245
  // Metro automatically updates the cache to account for the custom transform options.
246
- // client | node | undefined
247
- metroTarget: (_options$customTransf = options.customTransformOptions) === null || _options$customTransf === void 0 ? void 0 : _options$customTransf.environment
246
+ isServer: ((_options$customTransf = options.customTransformOptions) === null || _options$customTransf === void 0 ? void 0 : _options$customTransf.environment) === 'node'
248
247
  },
249
248
  ast: true,
250
249
  // NOTE(EvanBacon): We split the parse/transform steps up to accommodate
@@ -1 +1 @@
1
- {"version":3,"file":"babel-transformer.js","names":["_inlineRequires","data","_interopRequireDefault","require","_hmr","_nodeAssert","_nodeCrypto","_nodeFs","_nodePath","_resolveFrom","_babelCore","obj","__esModule","default","cacheKeyParts","fs","readFileSync","__filename","version","isTypeScriptSource","fileName","endsWith","isTSXSource","babelPresetExpo","getBabelPresetExpo","projectRoot","_resolveFrom$silent","undefined","resolveFrom","silent","getBabelRC","babelRC","_getBabelRC","extendsBabelConfigPath","options","plugins","extends","projectBabelRCPath","path","resolve","existsSync","experimentalImportSupport","presetOptions","platformOptions","unstable_transformProfile","withDevTools","disableImportExportTransform","dev","enableBabelRuntime","presets","web","native","buildBabelConfig","filename","extraConfig","babelrc","enableBabelRCLookup","code","cwd","highlightCode","config","extraPlugins","inlineRequires","push","inlineRequiresPlugin","concat","withExtraPlugins","hot","mayContainEditableReactComponents","includes","hmrConfig","makeHMRConfig","transform","src","_getBabelPresetExpo","OLD_BABEL_ENV","process","env","BABEL_ENV","_options$customTransf","babelConfig","sourceType","caller","name","bundler","platform","metroTarget","customTransformOptions","environment","ast","cloneInputAst","sourceAst","hermesParser","parseSync","parse","babel","result","transformFromAstSync","assert","metadata","getCacheKey","key","crypto","createHash","forEach","part","update","digest","babelTransformer","module","exports"],"sources":["../src/babel-transformer.ts"],"sourcesContent":["/**\n * Copyright (c) 650 Industries (Expo). All rights reserved.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n// A fork of the upstream babel-transformer that uses Expo-specific babel defaults\n// and adds support for web and Node.js environments via `metroTarget` on the Babel caller.\n\n// @ts-expect-error\nimport inlineRequiresPlugin from 'babel-preset-fbjs/plugins/inline-requires';\nimport type { BabelTransformer, BabelTransformerArgs } from 'metro-babel-transformer';\n// @ts-expect-error\nimport makeHMRConfig from 'metro-react-native-babel-preset/src/configs/hmr';\nimport assert from 'node:assert';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport resolveFrom from 'resolve-from';\n\nimport {\n parseSync,\n type PluginItem,\n type TransformOptions,\n transformFromAstSync,\n} from './babel-core';\n\nconst cacheKeyParts = [\n fs.readFileSync(__filename),\n require('babel-preset-fbjs/package.json').version,\n];\n\n// TS detection conditions copied from metro-react-native-babel-preset\nfunction isTypeScriptSource(fileName: string): boolean {\n return !!fileName && fileName.endsWith('.ts');\n}\n\nfunction isTSXSource(fileName: string): boolean {\n return !!fileName && fileName.endsWith('.tsx');\n}\n\nlet babelPresetExpo: string | null | undefined = null;\n\nfunction getBabelPresetExpo(projectRoot: string): string | null {\n if (babelPresetExpo !== undefined) {\n return babelPresetExpo;\n }\n\n babelPresetExpo = resolveFrom.silent(projectRoot, 'babel-preset-expo') ?? null;\n return babelPresetExpo;\n}\n\n/**\n * Return a memoized function that checks for the existence of a\n * project level .babelrc file, and if it doesn't exist, reads the\n * default RN babelrc file and uses that.\n */\nconst getBabelRC = (function () {\n let babelRC: TransformOptions | null /*: ?BabelCoreOptions */ = null;\n\n /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's\n * LTI update could not be added via codemod */\n return function _getBabelRC({\n projectRoot,\n extendsBabelConfigPath,\n ...options\n }: BabelTransformerArgs['options']) {\n if (babelRC != null) {\n return babelRC;\n }\n\n babelRC = {\n plugins: [],\n extends: extendsBabelConfigPath,\n };\n\n if (extendsBabelConfigPath) {\n return babelRC;\n }\n\n // Let's look for a babel config file in the project root.\n let projectBabelRCPath;\n\n // .babelrc\n if (projectRoot) {\n projectBabelRCPath = path.resolve(projectRoot, '.babelrc');\n }\n\n if (projectBabelRCPath) {\n // .babelrc.js\n if (!fs.existsSync(projectBabelRCPath)) {\n projectBabelRCPath = path.resolve(projectRoot, '.babelrc.js');\n }\n\n // babel.config.js\n if (!fs.existsSync(projectBabelRCPath)) {\n projectBabelRCPath = path.resolve(projectRoot, 'babel.config.js');\n }\n\n // If we found a babel config file, extend our config off of it\n // otherwise the default config will be used\n if (fs.existsSync(projectBabelRCPath)) {\n babelRC.extends = projectBabelRCPath;\n }\n }\n\n // If a babel config file doesn't exist in the project then\n // the default preset for react-native will be used instead.\n if (!babelRC.extends) {\n const { experimentalImportSupport, ...presetOptions } = options;\n\n // Convert the options into the format expected by the Expo preset.\n const platformOptions = {\n // @ts-expect-error: This is how Metro works by default\n unstable_transformProfile: presetOptions.unstable_transformProfile,\n // @ts-expect-error: This is how Metro works by default\n withDevTools: presetOptions.withDevTools,\n disableImportExportTransform: experimentalImportSupport,\n dev: presetOptions.dev,\n enableBabelRuntime: presetOptions.enableBabelRuntime,\n };\n\n babelRC.presets = [\n [\n // NOTE(EvanBacon): Here we use the Expo babel wrapper instead of the default react-native preset.\n require('babel-preset-expo'),\n {\n web: platformOptions,\n native: platformOptions,\n // lazyImports: presetOptions.lazyImportExportTransform,\n },\n ],\n ];\n }\n\n return babelRC;\n };\n})();\n\n/**\n * Given a filename and options, build a Babel\n * config object with the appropriate plugins.\n */\nfunction buildBabelConfig(\n filename: string,\n options: BabelTransformerArgs['options'],\n plugins: PluginItem[] = []\n): TransformOptions {\n const babelRC = getBabelRC(options);\n\n const extraConfig: TransformOptions = {\n babelrc: typeof options.enableBabelRCLookup === 'boolean' ? options.enableBabelRCLookup : true,\n code: false,\n cwd: options.projectRoot,\n filename,\n highlightCode: true,\n };\n\n let config: TransformOptions = {\n ...babelRC,\n ...extraConfig,\n };\n\n // Add extra plugins\n const extraPlugins = [];\n\n if (options.inlineRequires) {\n extraPlugins.push(inlineRequiresPlugin);\n }\n\n config.plugins = extraPlugins.concat(config.plugins, plugins);\n\n const withExtraPlugins = config.plugins;\n\n if (options.dev && options.hot) {\n // Note: this intentionally doesn't include the path separator because\n // I'm not sure which one it should use on Windows, and false positives\n // are unlikely anyway. If you later decide to include the separator,\n // don't forget that the string usually *starts* with \"node_modules\" so\n // the first one often won't be there.\n const mayContainEditableReactComponents = !filename.includes('node_modules');\n\n if (mayContainEditableReactComponents) {\n const hmrConfig = makeHMRConfig();\n hmrConfig.plugins = withExtraPlugins.concat(hmrConfig.plugins);\n config = { ...config, ...hmrConfig };\n }\n }\n\n return {\n ...babelRC,\n ...config,\n };\n}\n\nconst transform: BabelTransformer['transform'] = ({\n filename,\n options,\n src,\n plugins,\n}: BabelTransformerArgs): ReturnType<BabelTransformer['transform']> => {\n const OLD_BABEL_ENV = process.env.BABEL_ENV;\n process.env.BABEL_ENV = options.dev ? 'development' : process.env.BABEL_ENV || 'production';\n\n // Ensure the default babel preset is Expo.\n options.extendsBabelConfigPath = getBabelPresetExpo(options.projectRoot) ?? undefined;\n\n try {\n const babelConfig: TransformOptions = {\n // ES modules require sourceType='module' but OSS may not always want that\n sourceType: 'unambiguous',\n ...buildBabelConfig(filename, options, plugins),\n caller: {\n name: 'metro',\n // @ts-expect-error: Custom values passed to the caller.\n bundler: 'metro',\n platform: options.platform,\n // Empower the babel preset to know the env it's bundling for.\n // Metro automatically updates the cache to account for the custom transform options.\n // client | node | undefined\n metroTarget: options.customTransformOptions?.environment,\n },\n ast: true,\n\n // NOTE(EvanBacon): We split the parse/transform steps up to accommodate\n // Hermes parsing, but this defaults to cloning the AST which increases\n // the transformation time by a fair amount.\n // You get this behavior by default when using Babel's `transform` method directly.\n cloneInputAst: false,\n };\n const sourceAst =\n isTypeScriptSource(filename) || isTSXSource(filename) || !options.hermesParser\n ? parseSync(src, babelConfig)\n : require('hermes-parser').parse(src, {\n babel: true,\n sourceType: babelConfig.sourceType,\n });\n\n const result = transformFromAstSync(sourceAst, src, babelConfig);\n\n // The result from `transformFromAstSync` can be null (if the file is ignored)\n if (!result) {\n // BabelTransformer specifies that the `ast` can never be null but\n // the function returns here. Discovered when typing `BabelNode`.\n return { ast: null };\n }\n\n assert(result.ast);\n return { ast: result.ast, metadata: result.metadata };\n } finally {\n if (OLD_BABEL_ENV) {\n process.env.BABEL_ENV = OLD_BABEL_ENV;\n }\n }\n};\n\nfunction getCacheKey() {\n const key = crypto.createHash('md5');\n cacheKeyParts.forEach((part) => key.update(part));\n return key.digest('hex');\n}\n\nconst babelTransformer: BabelTransformer = {\n transform,\n getCacheKey,\n};\n\nmodule.exports = babelTransformer;\n"],"mappings":";;AAWA,SAAAA,gBAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,eAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;E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CAAEC,IAAI,IAAKJ,GAAG,CAACK,MAAM,CAACD,IAAI,CAAC,CAAC;EACjD,OAAOJ,GAAG,CAACM,MAAM,CAAC,KAAK,CAAC;AAC1B;AAEA,MAAMC,gBAAkC,GAAG;EACzCpC,SAAS;EACT4B;AACF,CAAC;AAEDS,MAAM,CAACC,OAAO,GAAGF,gBAAgB"}
1
+ {"version":3,"file":"babel-transformer.js","names":["_inlineRequires","data","_interopRequireDefault","require","_hmr","_nodeAssert","_nodeCrypto","_nodeFs","_nodePath","_resolveFrom","_babelCore","obj","__esModule","default","cacheKeyParts","fs","readFileSync","__filename","version","isTypeScriptSource","fileName","endsWith","isTSXSource","babelPresetExpo","getBabelPresetExpo","projectRoot","_resolveFrom$silent","undefined","resolveFrom","silent","getBabelRC","babelRC","_getBabelRC","extendsBabelConfigPath","options","plugins","extends","projectBabelRCPath","path","resolve","existsSync","experimentalImportSupport","presetOptions","platformOptions","unstable_transformProfile","withDevTools","disableImportExportTransform","dev","enableBabelRuntime","presets","web","native","buildBabelConfig","filename","extraConfig","babelrc","enableBabelRCLookup","code","cwd","highlightCode","config","extraPlugins","inlineRequires","push","inlineRequiresPlugin","concat","withExtraPlugins","hot","mayContainEditableReactComponents","includes","hmrConfig","makeHMRConfig","transform","src","_getBabelPresetExpo","OLD_BABEL_ENV","process","env","BABEL_ENV","_options$customTransf","babelConfig","sourceType","caller","name","bundler","platform","isServer","customTransformOptions","environment","ast","cloneInputAst","sourceAst","hermesParser","parseSync","parse","babel","result","transformFromAstSync","assert","metadata","getCacheKey","key","crypto","createHash","forEach","part","update","digest","babelTransformer","module","exports"],"sources":["../src/babel-transformer.ts"],"sourcesContent":["/**\n * Copyright (c) 650 Industries (Expo). All rights reserved.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n// A fork of the upstream babel-transformer that uses Expo-specific babel defaults\n// and adds support for web and Node.js environments via `isServer` on the Babel caller.\n\n// @ts-expect-error\nimport inlineRequiresPlugin from 'babel-preset-fbjs/plugins/inline-requires';\nimport type { BabelTransformer, BabelTransformerArgs } from 'metro-babel-transformer';\n// @ts-expect-error\nimport makeHMRConfig from 'metro-react-native-babel-preset/src/configs/hmr';\nimport assert from 'node:assert';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport resolveFrom from 'resolve-from';\n\nimport {\n parseSync,\n type PluginItem,\n type TransformOptions,\n transformFromAstSync,\n} from './babel-core';\n\nconst cacheKeyParts = [\n fs.readFileSync(__filename),\n require('babel-preset-fbjs/package.json').version,\n];\n\n// TS detection conditions copied from metro-react-native-babel-preset\nfunction isTypeScriptSource(fileName: string): boolean {\n return !!fileName && fileName.endsWith('.ts');\n}\n\nfunction isTSXSource(fileName: string): boolean {\n return !!fileName && fileName.endsWith('.tsx');\n}\n\nlet babelPresetExpo: string | null | undefined = null;\n\nfunction getBabelPresetExpo(projectRoot: string): string | null {\n if (babelPresetExpo !== undefined) {\n return babelPresetExpo;\n }\n\n babelPresetExpo = resolveFrom.silent(projectRoot, 'babel-preset-expo') ?? null;\n return babelPresetExpo;\n}\n\n/**\n * Return a memoized function that checks for the existence of a\n * project level .babelrc file, and if it doesn't exist, reads the\n * default RN babelrc file and uses that.\n */\nconst getBabelRC = (function () {\n let babelRC: TransformOptions | null /*: ?BabelCoreOptions */ = null;\n\n /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's\n * LTI update could not be added via codemod */\n return function _getBabelRC({\n projectRoot,\n extendsBabelConfigPath,\n ...options\n }: BabelTransformerArgs['options']) {\n if (babelRC != null) {\n return babelRC;\n }\n\n babelRC = {\n plugins: [],\n extends: extendsBabelConfigPath,\n };\n\n if (extendsBabelConfigPath) {\n return babelRC;\n }\n\n // Let's look for a babel config file in the project root.\n let projectBabelRCPath;\n\n // .babelrc\n if (projectRoot) {\n projectBabelRCPath = path.resolve(projectRoot, '.babelrc');\n }\n\n if (projectBabelRCPath) {\n // .babelrc.js\n if (!fs.existsSync(projectBabelRCPath)) {\n projectBabelRCPath = path.resolve(projectRoot, '.babelrc.js');\n }\n\n // babel.config.js\n if (!fs.existsSync(projectBabelRCPath)) {\n projectBabelRCPath = path.resolve(projectRoot, 'babel.config.js');\n }\n\n // If we found a babel config file, extend our config off of it\n // otherwise the default config will be used\n if (fs.existsSync(projectBabelRCPath)) {\n babelRC.extends = projectBabelRCPath;\n }\n }\n\n // If a babel config file doesn't exist in the project then\n // the default preset for react-native will be used instead.\n if (!babelRC.extends) {\n const { experimentalImportSupport, ...presetOptions } = options;\n\n // Convert the options into the format expected by the Expo preset.\n const platformOptions = {\n // @ts-expect-error: This is how Metro works by default\n unstable_transformProfile: presetOptions.unstable_transformProfile,\n // @ts-expect-error: This is how Metro works by default\n withDevTools: presetOptions.withDevTools,\n disableImportExportTransform: experimentalImportSupport,\n dev: presetOptions.dev,\n enableBabelRuntime: presetOptions.enableBabelRuntime,\n };\n\n babelRC.presets = [\n [\n // NOTE(EvanBacon): Here we use the Expo babel wrapper instead of the default react-native preset.\n require('babel-preset-expo'),\n {\n web: platformOptions,\n native: platformOptions,\n // lazyImports: presetOptions.lazyImportExportTransform,\n },\n ],\n ];\n }\n\n return babelRC;\n };\n})();\n\n/**\n * Given a filename and options, build a Babel\n * config object with the appropriate plugins.\n */\nfunction buildBabelConfig(\n filename: string,\n options: BabelTransformerArgs['options'],\n plugins: PluginItem[] = []\n): TransformOptions {\n const babelRC = getBabelRC(options);\n\n const extraConfig: TransformOptions = {\n babelrc: typeof options.enableBabelRCLookup === 'boolean' ? options.enableBabelRCLookup : true,\n code: false,\n cwd: options.projectRoot,\n filename,\n highlightCode: true,\n };\n\n let config: TransformOptions = {\n ...babelRC,\n ...extraConfig,\n };\n\n // Add extra plugins\n const extraPlugins = [];\n\n if (options.inlineRequires) {\n extraPlugins.push(inlineRequiresPlugin);\n }\n\n config.plugins = extraPlugins.concat(config.plugins, plugins);\n\n const withExtraPlugins = config.plugins;\n\n if (options.dev && options.hot) {\n // Note: this intentionally doesn't include the path separator because\n // I'm not sure which one it should use on Windows, and false positives\n // are unlikely anyway. If you later decide to include the separator,\n // don't forget that the string usually *starts* with \"node_modules\" so\n // the first one often won't be there.\n const mayContainEditableReactComponents = !filename.includes('node_modules');\n\n if (mayContainEditableReactComponents) {\n const hmrConfig = makeHMRConfig();\n hmrConfig.plugins = withExtraPlugins.concat(hmrConfig.plugins);\n config = { ...config, ...hmrConfig };\n }\n }\n\n return {\n ...babelRC,\n ...config,\n };\n}\n\nconst transform: BabelTransformer['transform'] = ({\n filename,\n options,\n src,\n plugins,\n}: BabelTransformerArgs): ReturnType<BabelTransformer['transform']> => {\n const OLD_BABEL_ENV = process.env.BABEL_ENV;\n process.env.BABEL_ENV = options.dev ? 'development' : process.env.BABEL_ENV || 'production';\n\n // Ensure the default babel preset is Expo.\n options.extendsBabelConfigPath = getBabelPresetExpo(options.projectRoot) ?? undefined;\n\n try {\n const babelConfig: TransformOptions = {\n // ES modules require sourceType='module' but OSS may not always want that\n sourceType: 'unambiguous',\n ...buildBabelConfig(filename, options, plugins),\n caller: {\n name: 'metro',\n // @ts-expect-error: Custom values passed to the caller.\n bundler: 'metro',\n platform: options.platform,\n // Empower the babel preset to know the env it's bundling for.\n // Metro automatically updates the cache to account for the custom transform options.\n isServer: options.customTransformOptions?.environment === 'node',\n },\n ast: true,\n\n // NOTE(EvanBacon): We split the parse/transform steps up to accommodate\n // Hermes parsing, but this defaults to cloning the AST which increases\n // the transformation time by a fair amount.\n // You get this behavior by default when using Babel's `transform` method directly.\n cloneInputAst: false,\n };\n const sourceAst =\n isTypeScriptSource(filename) || isTSXSource(filename) || !options.hermesParser\n ? parseSync(src, babelConfig)\n : require('hermes-parser').parse(src, {\n babel: true,\n sourceType: babelConfig.sourceType,\n });\n\n const result = transformFromAstSync(sourceAst, src, babelConfig);\n\n // The result from `transformFromAstSync` can be null (if the file is ignored)\n if (!result) {\n // BabelTransformer specifies that the `ast` can never be null but\n // the function returns here. Discovered when typing `BabelNode`.\n return { ast: null };\n }\n\n assert(result.ast);\n return { ast: result.ast, metadata: result.metadata };\n } finally {\n if (OLD_BABEL_ENV) {\n process.env.BABEL_ENV = OLD_BABEL_ENV;\n }\n }\n};\n\nfunction getCacheKey() {\n const key = crypto.createHash('md5');\n cacheKeyParts.forEach((part) => key.update(part));\n return key.digest('hex');\n}\n\nconst babelTransformer: BabelTransformer = {\n transform,\n getCacheKey,\n};\n\nmodule.exports = babelTransformer;\n"],"mappings":";;AAWA,SAAAA,gBAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,eAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,YAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,QAAA;EAAA,MAAAN,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAI,OAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,UAAA;EAAA,MAAAP,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAK,SAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,aAAA;EAAA,MAAAR,IAAA,GAAAC,sBAAA,CAAA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pB,GAAG,EAAEO,WAAW,CAAC,GAC3B7E,OAAO,CAAC,eAAe,CAAC,CAAC2F,KAAK,CAACrB,GAAG,EAAE;MAClCsB,KAAK,EAAE,IAAI;MACXd,UAAU,EAAED,WAAW,CAACC;IAC1B,CAAC,CAAC;IAER,MAAMe,MAAM,GAAG,IAAAC,iCAAoB,EAACN,SAAS,EAAElB,GAAG,EAAEO,WAAW,CAAC;;IAEhE;IACA,IAAI,CAACgB,MAAM,EAAE;MACX;MACA;MACA,OAAO;QAAEP,GAAG,EAAE;MAAK,CAAC;IACtB;IAEA,IAAAS,qBAAM,EAACF,MAAM,CAACP,GAAG,CAAC;IAClB,OAAO;MAAEA,GAAG,EAAEO,MAAM,CAACP,GAAG;MAAEU,QAAQ,EAAEH,MAAM,CAACG;IAAS,CAAC;EACvD,CAAC,SAAS;IACR,IAAIxB,aAAa,EAAE;MACjBC,OAAO,CAACC,GAAG,CAACC,SAAS,GAAGH,aAAa;IACvC;EACF;AACF,CAAC;AAED,SAASyB,WAAWA,CAAA,EAAG;EACrB,MAAMC,GAAG,GAAGC,qBAAM,CAACC,UAAU,CAAC,KAAK,CAAC;EACpCzF,aAAa,CAAC0F,OAAO,CAAEC,IAAI,IAAKJ,GAAG,CAACK,MAAM,CAACD,IAAI,CAAC,CAAC;EACjD,OAAOJ,GAAG,CAACM,MAAM,CAAC,KAAK,CAAC;AAC1B;AAEA,MAAMC,gBAAkC,GAAG;EACzCpC,SAAS;EACT4B;AACF,CAAC;AAEDS,MAAM,CAACC,OAAO,GAAGF,gBAAgB"}
@@ -37,7 +37,7 @@ const INTERNAL_CALLSITES_REGEX = new RegExp(['/Libraries/Renderer/implementation
37
37
  // Hide react-dom (web)
38
38
  'node_modules/react-dom/.+\\.js$',
39
39
  // Block expo's metro-runtime
40
- '@expo/metro-runtime/build/.+\\.js$',
40
+ '@expo/metro-runtime/.+\\.js$', '@expo/metro-runtime/.+\\.ts',
41
41
  // Block upstream metro-runtime
42
42
  '/metro-runtime/.+\\.js$'].join('|'));
43
43
  exports.INTERNAL_CALLSITES_REGEX = INTERNAL_CALLSITES_REGEX;
@@ -1 +1 @@
1
- {"version":3,"file":"customizeFrame.js","names":["_url","data","require","INTERNAL_CALLSITES_REGEX","RegExp","join","exports","isUrl","value","URL","getDefaultCustomizeFrame","frame","file","lineNumber","column","collapse","Boolean","test","_frame$file","methodName","match"],"sources":["../src/customizeFrame.ts"],"sourcesContent":["// Copyright 2023-present 650 Industries (Expo). All rights reserved.\nimport { SymbolicatorConfigT } from 'metro-config';\nimport { URL } from 'url';\n\ntype CustomizeFrameFunc = SymbolicatorConfigT['customizeFrame'];\n\n// Import only the types here, the values will be imported from the project, at runtime.\nexport const INTERNAL_CALLSITES_REGEX = new RegExp(\n [\n '/Libraries/Renderer/implementations/.+\\\\.js$',\n '/Libraries/BatchedBridge/MessageQueue\\\\.js$',\n '/Libraries/YellowBox/.+\\\\.js$',\n '/Libraries/LogBox/.+\\\\.js$',\n '/Libraries/Core/Timers/.+\\\\.js$',\n 'node_modules/react-devtools-core/.+\\\\.js$',\n 'node_modules/react-refresh/.+\\\\.js$',\n 'node_modules/scheduler/.+\\\\.js$',\n // Metro replaces `require()` with a different method,\n // we want to omit this method from the stack trace.\n // This is akin to most React tooling.\n '/metro/.*/polyfills/require.js$',\n // Hide frames related to a fast refresh.\n '/metro/.*/lib/bundle-modules/.+\\\\.js$',\n 'node_modules/react-native/Libraries/Utilities/HMRClient.js$',\n 'node_modules/eventemitter3/index.js',\n 'node_modules/event-target-shim/dist/.+\\\\.js$',\n // Improve errors thrown by invariant (ex: `Invariant Violation: \"main\" has not been registered`).\n 'node_modules/invariant/.+\\\\.js$',\n // Remove babel runtime additions\n 'node_modules/regenerator-runtime/.+\\\\.js$',\n // Remove react native setImmediate ponyfill\n 'node_modules/promise/setimmediate/.+\\\\.js$',\n // Babel helpers that implement language features\n 'node_modules/@babel/runtime/.+\\\\.js$',\n // Hide Hermes internal bytecode\n '/InternalBytecode/InternalBytecode\\\\.js$',\n // Block native code invocations\n `\\\\[native code\\\\]`,\n // Hide react-dom (web)\n 'node_modules/react-dom/.+\\\\.js$',\n // Block expo's metro-runtime\n '@expo/metro-runtime/build/.+\\\\.js$',\n // Block upstream metro-runtime\n '/metro-runtime/.+\\\\.js$',\n ].join('|')\n);\n\nfunction isUrl(value: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new URL(value);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * The default frame processor. This is used to modify the stack traces.\n * This method attempts to collapse all frames that aren't relevant to\n * the user by default.\n */\nexport function getDefaultCustomizeFrame(): CustomizeFrameFunc {\n return (frame: Parameters<CustomizeFrameFunc>[0]) => {\n if (frame.file && isUrl(frame.file)) {\n return {\n ...frame,\n // HACK: This prevents Metro from attempting to read the invalid file URL it sent us.\n lineNumber: null,\n column: null,\n // This prevents the invalid frame from being shown by default.\n collapse: true,\n };\n }\n let collapse = Boolean(frame.file && INTERNAL_CALLSITES_REGEX.test(frame.file));\n\n if (!collapse) {\n // This represents the first frame of the stacktrace.\n // Often this looks like: `__r(0);`.\n // The URL will also be unactionable in the app and therefore not very useful to the developer.\n if (\n frame.column === 3 &&\n frame.methodName === 'global code' &&\n frame.file?.match(/^https?:\\/\\//g)\n ) {\n collapse = true;\n }\n }\n\n return { ...(frame || {}), collapse };\n };\n}\n"],"mappings":";;;;;;;AAEA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAFA;;AAMA;AACO,MAAME,wBAAwB,GAAG,IAAIC,MAAM,CAChD,CACE,8CAA8C,EAC9C,6CAA6C,EAC7C,+BAA+B,EAC/B,4BAA4B,EAC5B,iCAAiC,EACjC,2CAA2C,EAC3C,qCAAqC,EACrC,iCAAiC;AACjC;AACA;AACA;AACA,iCAAiC;AACjC;AACA,uCAAuC,EACvC,6DAA6D,EAC7D,qCAAqC,EACrC,8CA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":"customizeFrame.js","names":["_url","data","require","INTERNAL_CALLSITES_REGEX","RegExp","join","exports","isUrl","value","URL","getDefaultCustomizeFrame","frame","file","lineNumber","column","collapse","Boolean","test","_frame$file","methodName","match"],"sources":["../src/customizeFrame.ts"],"sourcesContent":["// Copyright 2023-present 650 Industries (Expo). All rights reserved.\nimport { SymbolicatorConfigT } from 'metro-config';\nimport { URL } from 'url';\n\ntype CustomizeFrameFunc = SymbolicatorConfigT['customizeFrame'];\n\n// Import only the types here, the values will be imported from the project, at runtime.\nexport const INTERNAL_CALLSITES_REGEX = new RegExp(\n [\n '/Libraries/Renderer/implementations/.+\\\\.js$',\n '/Libraries/BatchedBridge/MessageQueue\\\\.js$',\n '/Libraries/YellowBox/.+\\\\.js$',\n '/Libraries/LogBox/.+\\\\.js$',\n '/Libraries/Core/Timers/.+\\\\.js$',\n 'node_modules/react-devtools-core/.+\\\\.js$',\n 'node_modules/react-refresh/.+\\\\.js$',\n 'node_modules/scheduler/.+\\\\.js$',\n // Metro replaces `require()` with a different method,\n // we want to omit this method from the stack trace.\n // This is akin to most React tooling.\n '/metro/.*/polyfills/require.js$',\n // Hide frames related to a fast refresh.\n '/metro/.*/lib/bundle-modules/.+\\\\.js$',\n 'node_modules/react-native/Libraries/Utilities/HMRClient.js$',\n 'node_modules/eventemitter3/index.js',\n 'node_modules/event-target-shim/dist/.+\\\\.js$',\n // Improve errors thrown by invariant (ex: `Invariant Violation: \"main\" has not been registered`).\n 'node_modules/invariant/.+\\\\.js$',\n // Remove babel runtime additions\n 'node_modules/regenerator-runtime/.+\\\\.js$',\n // Remove react native setImmediate ponyfill\n 'node_modules/promise/setimmediate/.+\\\\.js$',\n // Babel helpers that implement language features\n 'node_modules/@babel/runtime/.+\\\\.js$',\n // Hide Hermes internal bytecode\n '/InternalBytecode/InternalBytecode\\\\.js$',\n // Block native code invocations\n `\\\\[native code\\\\]`,\n // Hide react-dom (web)\n 'node_modules/react-dom/.+\\\\.js$',\n // Block expo's metro-runtime\n '@expo/metro-runtime/.+\\\\.js$',\n '@expo/metro-runtime/.+\\\\.ts',\n // Block upstream metro-runtime\n '/metro-runtime/.+\\\\.js$',\n ].join('|')\n);\n\nfunction isUrl(value: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new URL(value);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * The default frame processor. This is used to modify the stack traces.\n * This method attempts to collapse all frames that aren't relevant to\n * the user by default.\n */\nexport function getDefaultCustomizeFrame(): CustomizeFrameFunc {\n return (frame: Parameters<CustomizeFrameFunc>[0]) => {\n if (frame.file && isUrl(frame.file)) {\n return {\n ...frame,\n // HACK: This prevents Metro from attempting to read the invalid file URL it sent us.\n lineNumber: null,\n column: null,\n // This prevents the invalid frame from being shown by default.\n collapse: true,\n };\n }\n let collapse = Boolean(frame.file && INTERNAL_CALLSITES_REGEX.test(frame.file));\n\n if (!collapse) {\n // This represents the first frame of the stacktrace.\n // Often this looks like: `__r(0);`.\n // The URL will also be unactionable in the app and therefore not very useful to the developer.\n if (\n frame.column === 3 &&\n frame.methodName === 'global code' &&\n frame.file?.match(/^https?:\\/\\//g)\n ) {\n collapse = true;\n }\n }\n\n return { ...(frame || {}), collapse };\n };\n}\n"],"mappings":";;;;;;;AAEA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAFA;;AAMA;AACO,MAAME,wBAAwB,GAAG,IAAIC,MAAM,CAChD,CACE,8CAA8C,EAC9C,6CAA6C,EAC7C,+BAA+B,EAC/B,4BAA4B,EAC5B,iCAAiC,EACjC,2CAA2C,EAC3C,qCAAqC,EACrC,iCAAiC;AACjC;AACA;AACA;AACA,iCAAiC;AACjC;AACA,uCAAuC,EACvC,6DAA6D,EAC7D,qCAAqC,EACrC,8CAA8C;AAC9C;AACA,iCAAiC;AACjC;AACA,2CAA2C;AAC3C;AACA,4CAA4C;AAC5C;A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import { SerializerParameters } from './withExpoSerializers';
9
9
  export declare function replaceEnvironmentVariables(code: string, env: Record<string, string | undefined>): string;
10
10
  export declare function getTransformEnvironment(url: string): string | null;
11
+ /** Strips the process.env polyfill in server environments to allow for accessing environment variables off the global. */
12
+ export declare function serverPreludeSerializerPlugin(entryPoint: string, preModules: readonly Module<MixedOutput>[], graph: ReadOnlyGraph, options: SerializerOptions): SerializerParameters;
11
13
  export declare function environmentVariableSerializerPlugin(entryPoint: string, preModules: readonly Module<MixedOutput>[], graph: ReadOnlyGraph, options: SerializerOptions): SerializerParameters;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.environmentVariableSerializerPlugin = environmentVariableSerializerPlugin;
7
7
  exports.getTransformEnvironment = getTransformEnvironment;
8
8
  exports.replaceEnvironmentVariables = replaceEnvironmentVariables;
9
+ exports.serverPreludeSerializerPlugin = serverPreludeSerializerPlugin;
9
10
  function _CountingSet() {
10
11
  const data = _interopRequireDefault(require("metro/src/lib/CountingSet"));
11
12
  _CountingSet = function () {
@@ -60,6 +61,18 @@ function getAllExpoPublicEnvVars() {
60
61
  }
61
62
  return env;
62
63
  }
64
+
65
+ /** Strips the process.env polyfill in server environments to allow for accessing environment variables off the global. */
66
+ function serverPreludeSerializerPlugin(entryPoint, preModules, graph, options) {
67
+ if (options.sourceUrl && getTransformEnvironment(options.sourceUrl) === 'node') {
68
+ const prelude = preModules.find(module => module.path === '__prelude__');
69
+ if (prelude) {
70
+ debug('Stripping environment variable polyfill in server environment.');
71
+ prelude.output[0].data.code = prelude.output[0].data.code.replace(/process=this\.process\|\|{},/, '').replace(/process\.env=process\.env\|\|{};process\.env\.NODE_ENV=process\.env\.NODE_ENV\|\|"\w+";/, '');
72
+ }
73
+ }
74
+ return [entryPoint, preModules, graph, options];
75
+ }
63
76
  function environmentVariableSerializerPlugin(entryPoint, preModules, graph, options) {
64
77
  // Skip replacement in Node.js environments.
65
78
  if (options.sourceUrl && getTransformEnvironment(options.sourceUrl) === 'node') {
@@ -1 +1 @@
1
- {"version":3,"file":"environmentVariableSerializerPlugin.js","names":["_CountingSet","data","_interopRequireDefault","require","_countLines","obj","__esModule","default","debug","replaceEnvironmentVariables","code","env","replace","match","_env$name","name","test","value","JSON","stringify","getTransformEnvironment","url","getAllExpoPublicEnvVars","key","process","startsWith","environmentVariableSerializerPlugin","entryPoint","preModules","graph","options","sourceUrl","dev","str","Object","keys","map","join","firstModule","restModules","getEnvPrelude","dependencies","values","path","index","output","contents","lineCount","countLines","Map","getSource","Buffer","from","inverseDependencies","CountingSet","type"],"sources":["../../src/serializer/environmentVariableSerializerPlugin.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { ReadOnlyGraph, MixedOutput, Module, SerializerOptions } from 'metro';\nimport CountingSet from 'metro/src/lib/CountingSet';\nimport countLines from 'metro/src/lib/countLines';\n\nimport { SerializerParameters } from './withExpoSerializers';\n\nconst debug = require('debug')('expo:metro-config:serializer:env-var') as typeof console.log;\n\nexport function replaceEnvironmentVariables(\n code: string,\n env: Record<string, string | undefined>\n): string {\n // match and replace env variables that aren't NODE_ENV or JEST_WORKER_ID\n // return code.match(/process\\.env\\.(EXPO_PUBLIC_[A-Z_]+)/g);\n return code.replace(/process\\.env\\.([a-zA-Z0-9_]+)/gm, (match) => {\n const name = match.replace('process.env.', '');\n if (\n // Must start with EXPO_PUBLIC_ to be replaced\n !/^EXPO_PUBLIC_/.test(name)\n ) {\n return match;\n }\n\n const value = JSON.stringify(env[name] ?? '');\n debug(`Inlining environment variable \"${match}\" with ${value}`);\n return value;\n });\n}\n\nexport function getTransformEnvironment(url: string): string | null {\n const match = url.match(/[&?]transform\\.environment=([^&]+)/);\n return match ? match[1] : null;\n}\n\nfunction getAllExpoPublicEnvVars() {\n // Create an object containing all environment variables that start with EXPO_PUBLIC_\n const env = {};\n for (const key in process.env) {\n if (key.startsWith('EXPO_PUBLIC_')) {\n // @ts-ignore\n env[key] = process.env[key];\n }\n }\n return env;\n}\n\nexport function environmentVariableSerializerPlugin(\n entryPoint: string,\n preModules: readonly Module<MixedOutput>[],\n graph: ReadOnlyGraph,\n options: SerializerOptions\n): SerializerParameters {\n // Skip replacement in Node.js environments.\n if (options.sourceUrl && getTransformEnvironment(options.sourceUrl) === 'node') {\n debug('Skipping environment variable inlining in Node.js environment.');\n return [entryPoint, preModules, graph, options];\n }\n\n // Adds about 5ms on a blank Expo Router app.\n // TODO: We can probably cache the results.\n\n // In development, we need to add the process.env object to ensure it\n // persists between Fast Refresh updates.\n if (options.dev) {\n // Set the process.env object to the current environment variables object\n // ensuring they aren't iterable, settable, or enumerable.\n const str = `process.env=Object.defineProperties(process.env, {${Object.keys(\n getAllExpoPublicEnvVars()\n )\n .map((key) => `${JSON.stringify(key)}: { value: ${JSON.stringify(process.env[key])} }`)\n .join(',')}});`;\n\n const [firstModule, ...restModules] = preModules;\n // const envCode = `var process=this.process||{};${str}`;\n // process.env\n return [\n entryPoint,\n [\n // First module defines the process.env object.\n firstModule,\n // Second module modifies the process.env object.\n getEnvPrelude(str),\n // Now we add the rest\n ...restModules,\n ],\n graph,\n options,\n ];\n }\n\n // In production, inline all process.env variables to ensure they cannot be iterated and read arbitrarily.\n for (const value of graph.dependencies.values()) {\n // Skip node_modules, the feature is a bit too sensitive to allow in arbitrary code.\n if (/node_modules/.test(value.path)) {\n continue;\n }\n\n for (const index in value.output) {\n // TODO: This probably breaks source maps.\n const code = replaceEnvironmentVariables(value.output[index].data.code, process.env);\n value.output[index].data.code = code;\n }\n }\n return [entryPoint, preModules, graph, options];\n}\n\nfunction getEnvPrelude(contents: string): Module<MixedOutput> {\n const code = '// HMR env vars from Expo CLI (dev-only)\\n' + contents;\n const name = '__env__';\n const lineCount = countLines(code);\n\n return {\n dependencies: new Map(),\n getSource: (): Buffer => Buffer.from(code),\n inverseDependencies: new CountingSet(),\n path: name,\n output: [\n {\n type: 'js/script/virtual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EACLC,OAAO,CACR;EACH;;EAEA;EACA,KAAK,MAAMb,KAAK,IAAIY,KAAK,CAACY,YAAY,CAACC,MAAM,EAAE,EAAE;IAC/C;IACA,IAAI,cAAc,CAAC1B,IAAI,CAACC,KAAK,CAAC0B,IAAI,CAAC,EAAE;MACnC;IACF;IAEA,KAAK,MAAMC,KAAK,IAAI3B,KAAK,CAAC4B,MAAM,EAAE;MAChC;MACA,MAAMnC,IAAI,GAAGD,2BAA2B,CAACQ,KAAK,CAAC4B,MAAM,CAACD,KAAK,CAAC,CAAC3C,IAAI,CAACS,IAAI,EAAEc,OAAO,CAACb,GAAG,CAAC;MACpFM,KAAK,CAAC4B,MAAM,CAACD,KAAK,CAAC,CAAC3C,IAAI,CAACS,IAAI,GAAGA,IAAI;IACtC;EACF;EACA,OAAO,CAACiB,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,CAAC;AACjD;AAEA,SAASU,aAAaA,CAACM,QAAgB,EAAuB;EAC5D,MAAMpC,IAAI,GAAG,4CAA4C,GAAGoC,QAAQ;EACpE,MAAM/B,IAAI,GAAG,SAAS;EACtB,MAAMgC,SAAS,GAAG,IAAAC,qBAAU,EAACtC,IAAI,CAAC;EAElC,OAAO;IACL+B,YAAY,EAAE,IAAIQ,GAAG,EAAE;IACvBC,SAAS,EAAEA,CAAA,KAAcC,MAAM,CAACC,IAAI,CAAC1C,IAAI,CAAC;IAC1C2C,mBAAmB,EAAE,KAAIC,sBAAW,GAAE;IACtCX,IAAI,EAAE5B,IAAI;IACV8B,MAAM,EAAE,CACN;MACEU,IAAI,EAAE,mBAAmB;MACzBtD,IAAI,EAAE;QACJS,IAAI;QACJ;QACAqC,SAAS;QACTX,GAAG,EAAE;MACP;IACF,CAAC;EAEL,CAAC;AACH"}
1
+ {"version":3,"file":"environmentVariableSerializerPlugin.js","names":["_CountingSet","data","_interopRequireDefault","require","_countLines","obj","__esModule","default","debug","replaceEnvironmentVariables","code","env","replace","match","_env$name","name","test","value","JSON","stringify","getTransformEnvironment","url","getAllExpoPublicEnvVars","key","process","startsWith","serverPreludeSerializerPlugin","entryPoint","preModules","graph","options","sourceUrl","prelude","find","module","path","output","environmentVariableSerializerPlugin","dev","str","Object","keys","map","join","firstModule","restModules","getEnvPrelude","dependencies","values","index","contents","lineCount","countLines","Map","getSource","Buffer","from","inverseDependencies","CountingSet","type"],"sources":["../../src/serializer/environmentVariableSerializerPlugin.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { ReadOnlyGraph, MixedOutput, Module, SerializerOptions } from 'metro';\nimport CountingSet from 'metro/src/lib/CountingSet';\nimport countLines from 'metro/src/lib/countLines';\n\nimport { SerializerParameters } from './withExpoSerializers';\n\nconst debug = require('debug')('expo:metro-config:serializer:env-var') as typeof console.log;\n\nexport function replaceEnvironmentVariables(\n code: string,\n env: Record<string, string | undefined>\n): string {\n // match and replace env variables that aren't NODE_ENV or JEST_WORKER_ID\n // return code.match(/process\\.env\\.(EXPO_PUBLIC_[A-Z_]+)/g);\n return code.replace(/process\\.env\\.([a-zA-Z0-9_]+)/gm, (match) => {\n const name = match.replace('process.env.', '');\n if (\n // Must start with EXPO_PUBLIC_ to be replaced\n !/^EXPO_PUBLIC_/.test(name)\n ) {\n return match;\n }\n\n const value = JSON.stringify(env[name] ?? '');\n debug(`Inlining environment variable \"${match}\" with ${value}`);\n return value;\n });\n}\n\nexport function getTransformEnvironment(url: string): string | null {\n const match = url.match(/[&?]transform\\.environment=([^&]+)/);\n return match ? match[1] : null;\n}\n\nfunction getAllExpoPublicEnvVars() {\n // Create an object containing all environment variables that start with EXPO_PUBLIC_\n const env = {};\n for (const key in process.env) {\n if (key.startsWith('EXPO_PUBLIC_')) {\n // @ts-ignore\n env[key] = process.env[key];\n }\n }\n return env;\n}\n\n/** Strips the process.env polyfill in server environments to allow for accessing environment variables off the global. */\nexport function serverPreludeSerializerPlugin(\n entryPoint: string,\n preModules: readonly Module<MixedOutput>[],\n graph: ReadOnlyGraph,\n options: SerializerOptions\n): SerializerParameters {\n if (options.sourceUrl && getTransformEnvironment(options.sourceUrl) === 'node') {\n const prelude = preModules.find((module) => module.path === '__prelude__');\n if (prelude) {\n debug('Stripping environment variable polyfill in server environment.');\n prelude.output[0].data.code = prelude.output[0].data.code\n .replace(/process=this\\.process\\|\\|{},/, '')\n .replace(\n /process\\.env=process\\.env\\|\\|{};process\\.env\\.NODE_ENV=process\\.env\\.NODE_ENV\\|\\|\"\\w+\";/,\n ''\n );\n }\n }\n return [entryPoint, preModules, graph, options];\n}\n\nexport function environmentVariableSerializerPlugin(\n entryPoint: string,\n preModules: readonly Module<MixedOutput>[],\n graph: ReadOnlyGraph,\n options: SerializerOptions\n): SerializerParameters {\n // Skip replacement in Node.js environments.\n if (options.sourceUrl && getTransformEnvironment(options.sourceUrl) === 'node') {\n debug('Skipping environment variable inlining in Node.js environment.');\n return [entryPoint, preModules, graph, options];\n }\n\n // Adds about 5ms on a blank Expo Router app.\n // TODO: We can probably cache the results.\n\n // In development, we need to add the process.env object to ensure it\n // persists between Fast Refresh updates.\n if (options.dev) {\n // Set the process.env object to the current environment variables object\n // ensuring they aren't iterable, settable, or enumerable.\n const str = `process.env=Object.defineProperties(process.env, {${Object.keys(\n getAllExpoPublicEnvVars()\n )\n .map((key) => `${JSON.stringify(key)}: { value: ${JSON.stringify(process.env[key])} }`)\n .join(',')}});`;\n\n const [firstModule, ...restModules] = preModules;\n // const envCode = `var process=this.process||{};${str}`;\n // process.env\n return [\n entryPoint,\n [\n // First module defines the process.env object.\n firstModule,\n // Second module modifies the process.env object.\n getEnvPrelude(str),\n // Now we add the rest\n ...restModules,\n ],\n graph,\n options,\n ];\n }\n\n // In production, inline all process.env variables to ensure they cannot be iterated and read arbitrarily.\n for (const value of graph.dependencies.values()) {\n // Skip node_modules, the feature is a bit too sensitive to allow in arbitrary code.\n if (/node_modules/.test(value.path)) {\n continue;\n }\n\n for (const index in value.output) {\n // TODO: This probably breaks source maps.\n const code = replaceEnvironmentVariables(value.output[index].data.code, process.env);\n value.output[index].data.code = code;\n }\n }\n return [entryPoint, preModules, graph, options];\n}\n\nfunction getEnvPrelude(contents: string): Module<MixedOutput> {\n const code = '// HMR env vars from Expo CLI (dev-only)\\n' + contents;\n const name = '__env__';\n const lineCount = countLines(code);\n\n return {\n dependencies: new Map(),\n getSource: (): Buffer => Buffer.from(code),\n inverseDependencies: new CountingSet(),\n path: name,\n output: [\n {\n type: 'js/script/virtual',\n data: {\n code,\n // @ts-expect-error: typed incorrectly upstream\n lineCount,\n map: [],\n },\n },\n ],\n };\n}\n"],"mappings":";;;;;;;;;AAOA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAkD,SAAAC,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AARlD;AACA;AACA;AACA;AACA;AACA;;AAOA,MAAMG,KAAK,GAAGL,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAuB;AAErF,SAASM,2BAA2BA,CACzCC,IAAY,EACZC,GAAuC,EAC/B;EACR;EACA;EACA,OAAOD,IAAI,CAACE,OAAO,CAAC,iCAAiC,EAAGC,KAAK,IAAK;IAAA,IAAAC,SAAA;IAChE,MAAMC,IAAI,GAAGF,KAAK,CAACD,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;IAC9C;IACE;IACA,CAAC,eAAe,CAACI,IAAI,CAACD,IAAI,CAAC,EAC3B;MACA,OAAOF,KAAK;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KAAK,CAACmB,MAAM,EAAE;MAChC;MACA,MAAM1B,IAAI,GAAGD,2BAA2B,CAACQ,KAAK,CAACmB,MAAM,CAACa,KAAK,CAAC,CAAChD,IAAI,CAACS,IAAI,EAAEc,OAAO,CAACb,GAAG,CAAC;MACpFM,KAAK,CAACmB,MAAM,CAACa,KAAK,CAAC,CAAChD,IAAI,CAACS,IAAI,GAAGA,IAAI;IACtC;EACF;EACA,OAAO,CAACiB,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,CAAC;AACjD;AAEA,SAASgB,aAAaA,CAACI,QAAgB,EAAuB;EAC5D,MAAMxC,IAAI,GAAG,4CAA4C,GAAGwC,QAAQ;EACpE,MAAMnC,IAAI,GAAG,SAAS;EACtB,MAAMoC,SAAS,GAAG,IAAAC,qBAAU,EAAC1C,IAAI,CAAC;EAElC,OAAO;IACLqC,YAAY,EAAE,IAAIM,GAAG,EAAE;IACvBC,SAAS,EAAEA,CAAA,KAAcC,MAAM,CAACC,IAAI,CAAC9C,IAAI,CAAC;IAC1C+C,mBAAmB,EAAE,KAAIC,sBAAW,GAAE;IACtCvB,IAAI,EAAEpB,IAAI;IACVqB,MAAM,EAAE,CACN;MACEuB,IAAI,EAAE,mBAAmB;MACzB1D,IAAI,EAAE;QACJS,IAAI;QACJ;QACAyC,SAAS;QACTT,GAAG,EAAE;MACP;IACF,CAAC;EAEL,CAAC;AACH"}
@@ -21,7 +21,7 @@ export type JSModule = Module<{
21
21
  };
22
22
  type: 'js/module';
23
23
  }>;
24
- export declare function filterJsModules(dependencies: ReadOnlyDependencies, { processModuleFilter, projectRoot }: Pick<Options, 'projectRoot' | 'processModuleFilter'>): JSModule[];
24
+ export declare function filterJsModules(dependencies: ReadOnlyDependencies, type: 'js/script' | 'js/module' | 'js/module/asset', { processModuleFilter, projectRoot }: Pick<Options, 'projectRoot' | 'processModuleFilter'>): JSModule[];
25
25
  export declare function getCssSerialAssets<T extends any>(dependencies: ReadOnlyDependencies<T>, { processModuleFilter, projectRoot }: Pick<Options, 'projectRoot' | 'processModuleFilter'>): SerialAsset[];
26
26
  export declare function fileNameFromContents({ filepath, src }: {
27
27
  filepath: string;
@@ -38,13 +38,13 @@ function _hash() {
38
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
39
  // s = static
40
40
  const STATIC_EXPORT_DIRECTORY = '_expo/static/css';
41
- function filterJsModules(dependencies, {
41
+ function filterJsModules(dependencies, type, {
42
42
  processModuleFilter,
43
43
  projectRoot
44
44
  }) {
45
45
  const assets = [];
46
46
  for (const module of dependencies.values()) {
47
- if ((0, _js().isJsModule)(module) && processModuleFilter(module) && (0, _js().getJsOutput)(module).type === 'js/module' && _path().default.relative(projectRoot, module.path) !== 'package.json') {
47
+ if ((0, _js().isJsModule)(module) && processModuleFilter(module) && (0, _js().getJsOutput)(module).type === type && _path().default.relative(projectRoot, module.path) !== 'package.json') {
48
48
  assets.push(module);
49
49
  }
50
50
  }
@@ -55,22 +55,23 @@ function getCssSerialAssets(dependencies, {
55
55
  projectRoot
56
56
  }) {
57
57
  const assets = [];
58
- for (const module of filterJsModules(dependencies, {
58
+ for (const module of filterJsModules(dependencies, 'js/module', {
59
59
  processModuleFilter,
60
60
  projectRoot
61
61
  })) {
62
62
  const cssMetadata = getCssMetadata(module);
63
63
  if (cssMetadata) {
64
64
  const contents = cssMetadata.code;
65
+ const originFilename = _path().default.relative(projectRoot, module.path);
65
66
  const filename = _path().default.join(
66
67
  // Consistent location
67
68
  STATIC_EXPORT_DIRECTORY,
68
69
  // Hashed file contents + name for caching
69
70
  fileNameFromContents({
70
- filepath: module.path,
71
+ // Stable filename for hashing in CI.
72
+ filepath: originFilename,
71
73
  src: contents
72
74
  }) + '.css');
73
- const originFilename = _path().default.relative(projectRoot, module.path);
74
75
  assets.push({
75
76
  type: 'css',
76
77
  originFilename,
@@ -99,7 +100,9 @@ function fileNameFromContents({
99
100
  filepath,
100
101
  src
101
102
  }) {
102
- return getFileName(filepath) + '-' + (0, _hash().hashString)(filepath + src);
103
+ // Decode if the path is encoded from the Metro dev server, then normalize paths for Windows support.
104
+ const decoded = decodeURIComponent(filepath).replace(/\\/g, '/');
105
+ return getFileName(decoded) + '-' + (0, _hash().hashString)(decoded + src);
103
106
  }
104
107
  function getFileName(module) {
105
108
  return _path().default.basename(module).replace(/\.[^.]+$/, '');
@@ -1 +1 @@
1
- {"version":3,"file":"getCssDeps.js","names":["_js","data","require","_path","_interopRequireDefault","_css","_hash","obj","__esModule","default","STATIC_EXPORT_DIRECTORY","filterJsModules","dependencies","processModuleFilter","projectRoot","assets","module","values","isJsModule","getJsOutput","type","path","relative","push","getCssSerialAssets","cssMetadata","getCssMetadata","contents","code","filename","join","fileNameFromContents","filepath","src","originFilename","source","metadata","hmrId","pathToHtmlSafeName","_module$output$","output","css","Error","JSON","stringify","getFileName","hashString","basename","replace"],"sources":["../../src/serializer/getCssDeps.ts"],"sourcesContent":["import type { Module } from 'metro';\nimport { getJsOutput, isJsModule } from 'metro/src/DeltaBundler/Serializers/helpers/js';\nimport path from 'path';\n\nimport { pathToHtmlSafeName } from '../transform-worker/css';\nimport { hashString } from '../utils/hash';\nimport { SerialAsset } from './serializerAssets';\n\nexport type ReadOnlyDependencies<T = any> = ReadonlyMap<string, Module<T>>;\n\ntype Options = {\n processModuleFilter: (modules: Module) => boolean;\n assetPlugins: readonly string[];\n platform?: string | null;\n projectRoot: string;\n publicPath: string;\n};\n\ntype MetroModuleCSSMetadata = {\n code: string;\n lineCount: number;\n map: any[];\n};\n\n// s = static\nconst STATIC_EXPORT_DIRECTORY = '_expo/static/css';\n\nexport type JSModule = Module<{\n data: {\n code: string;\n map: unknown;\n lineCount: number;\n css?: {\n code: string;\n map: unknown;\n lineCount: number;\n };\n };\n type: 'js/module';\n}>;\n\nexport function filterJsModules(\n dependencies: ReadOnlyDependencies,\n { processModuleFilter, projectRoot }: Pick<Options, 'projectRoot' | 'processModuleFilter'>\n) {\n const assets: JSModule[] = [];\n\n for (const module of dependencies.values()) {\n if (\n isJsModule(module) &&\n processModuleFilter(module) &&\n getJsOutput(module).type === 'js/module' &&\n path.relative(projectRoot, module.path) !== 'package.json'\n ) {\n assets.push(module as JSModule);\n }\n }\n return assets;\n}\n\nexport function getCssSerialAssets<T extends any>(\n dependencies: ReadOnlyDependencies<T>,\n { processModuleFilter, projectRoot }: Pick<Options, 'projectRoot' | 'processModuleFilter'>\n): SerialAsset[] {\n const assets: SerialAsset[] = [];\n\n for (const module of filterJsModules(dependencies, { processModuleFilter, projectRoot })) {\n const cssMetadata = getCssMetadata(module);\n if (cssMetadata) {\n const contents = cssMetadata.code;\n const filename = path.join(\n // Consistent location\n STATIC_EXPORT_DIRECTORY,\n // Hashed file contents + name for caching\n fileNameFromContents({\n filepath: module.path,\n src: contents,\n }) + '.css'\n );\n const originFilename = path.relative(projectRoot, module.path);\n assets.push({\n type: 'css',\n originFilename,\n filename,\n source: contents,\n metadata: {\n hmrId: pathToHtmlSafeName(originFilename),\n },\n });\n }\n }\n\n return assets;\n}\n\nfunction getCssMetadata(module: JSModule): MetroModuleCSSMetadata | null {\n const data = module.output[0]?.data;\n if (data && typeof data === 'object' && 'css' in data) {\n if (typeof data.css !== 'object' || !('code' in (data as any).css)) {\n throw new Error(\n `Unexpected CSS metadata in Metro module (${module.path}): ${JSON.stringify(data.css)}`\n );\n }\n return data.css as MetroModuleCSSMetadata;\n }\n return null;\n}\n\nexport function fileNameFromContents({ filepath, src }: { filepath: string; src: string }): string {\n return getFileName(filepath) + '-' + hashString(filepath + src);\n}\n\nexport function getFileName(module: string) {\n return path.basename(module).replace(/\\.[^.]+$/, '');\n}\n"],"mappings":";;;;;;;;;AACA,SAAAA,IAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,GAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,MAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAA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AAC,EAAU;EACjG,OAAOY,WAAW,CAACb,QAAQ,CAAC,GAAG,GAAG,GAAG,IAAAc,kBAAU,EAACd,QAAQ,GAAGC,GAAG,CAAC;AACjE;AAEO,SAASY,WAAWA,CAAC7B,MAAc,EAAE;EAC1C,OAAOK,eAAI,CAAC0B,QAAQ,CAAC/B,MAAM,CAAC,CAACgC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;AACtD"}
1
+ {"version":3,"file":"getCssDeps.js","names":["_js","data","require","_path","_interopRequireDefault","_css","_hash","obj","__esModule","default","STATIC_EXPORT_DIRECTORY","filterJsModules","dependencies","type","processModuleFilter","projectRoot","assets","module","values","isJsModule","getJsOutput","path","relative","push","getCssSerialAssets","cssMetadata","getCssMetadata","contents","code","originFilename","filename","join","fileNameFromContents","filepath","src","source","metadata","hmrId","pathToHtmlSafeName","_module$output$","output","css","Error","JSON","stringify","decoded","decodeURIComponent","replace","getFileName","hashString","basename"],"sources":["../../src/serializer/getCssDeps.ts"],"sourcesContent":["import type { Module } from 'metro';\nimport { getJsOutput, isJsModule } from 'metro/src/DeltaBundler/Serializers/helpers/js';\nimport path from 'path';\n\nimport { SerialAsset } from './serializerAssets';\nimport { pathToHtmlSafeName } from '../transform-worker/css';\nimport { hashString } from '../utils/hash';\n\nexport type ReadOnlyDependencies<T = any> = ReadonlyMap<string, Module<T>>;\n\ntype Options = {\n processModuleFilter: (modules: Module) => boolean;\n assetPlugins: readonly string[];\n platform?: string | null;\n projectRoot: string;\n publicPath: string;\n};\n\ntype MetroModuleCSSMetadata = {\n code: string;\n lineCount: number;\n map: any[];\n};\n\n// s = static\nconst STATIC_EXPORT_DIRECTORY = '_expo/static/css';\n\nexport type JSModule = Module<{\n data: {\n code: string;\n map: unknown;\n lineCount: number;\n css?: {\n code: string;\n map: unknown;\n lineCount: number;\n };\n };\n type: 'js/module';\n}>;\n\nexport function filterJsModules(\n dependencies: ReadOnlyDependencies,\n type: 'js/script' | 'js/module' | 'js/module/asset',\n { processModuleFilter, projectRoot }: Pick<Options, 'projectRoot' | 'processModuleFilter'>\n) {\n const assets: JSModule[] = [];\n\n for (const module of dependencies.values()) {\n if (\n isJsModule(module) &&\n processModuleFilter(module) &&\n getJsOutput(module).type === type &&\n path.relative(projectRoot, module.path) !== 'package.json'\n ) {\n assets.push(module as JSModule);\n }\n }\n return assets;\n}\n\nexport function getCssSerialAssets<T extends any>(\n dependencies: ReadOnlyDependencies<T>,\n { processModuleFilter, projectRoot }: Pick<Options, 'projectRoot' | 'processModuleFilter'>\n): SerialAsset[] {\n const assets: SerialAsset[] = [];\n\n for (const module of filterJsModules(dependencies, 'js/module', {\n processModuleFilter,\n projectRoot,\n })) {\n const cssMetadata = getCssMetadata(module);\n if (cssMetadata) {\n const contents = cssMetadata.code;\n const originFilename = path.relative(projectRoot, module.path);\n\n const filename = path.join(\n // Consistent location\n STATIC_EXPORT_DIRECTORY,\n // Hashed file contents + name for caching\n fileNameFromContents({\n // Stable filename for hashing in CI.\n filepath: originFilename,\n src: contents,\n }) + '.css'\n );\n assets.push({\n type: 'css',\n originFilename,\n filename,\n source: contents,\n metadata: {\n hmrId: pathToHtmlSafeName(originFilename),\n },\n });\n }\n }\n\n return assets;\n}\n\nfunction getCssMetadata(module: JSModule): MetroModuleCSSMetadata | null {\n const data = module.output[0]?.data;\n if (data && typeof data === 'object' && 'css' in data) {\n if (typeof data.css !== 'object' || !('code' in (data as any).css)) {\n throw new Error(\n `Unexpected CSS metadata in Metro module (${module.path}): ${JSON.stringify(data.css)}`\n );\n }\n return data.css as MetroModuleCSSMetadata;\n }\n return null;\n}\n\nexport function fileNameFromContents({ filepath, src }: { filepath: string; src: string }): string {\n // Decode if the path is encoded from the Metro dev server, then normalize paths for Windows support.\n const decoded = decodeURIComponent(filepath).replace(/\\\\/g, '/');\n return getFileName(decoded) + '-' + hashString(decoded + src);\n}\n\nexport function getFileName(module: string) {\n return path.basename(module).replace(/\\.[^.]+$/, '');\n}\n"],"mappings":";;;;;;;;;AACA,S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M,CAACI,IAAK,MAAKsB,IAAI,CAACC,SAAS,CAAC3C,IAAI,CAACwC,GAAG,CAAE,EAAC,CACxF;IACH;IACA,OAAOxC,IAAI,CAACwC,GAAG;EACjB;EACA,OAAO,IAAI;AACb;AAEO,SAAST,oBAAoBA,CAAC;EAAEC,QAAQ;EAAEC;AAAuC,CAAC,EAAU;EACjG;EACA,MAAMW,OAAO,GAAGC,kBAAkB,CAACb,QAAQ,CAAC,CAACc,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;EAChE,OAAOC,WAAW,CAACH,OAAO,CAAC,GAAG,GAAG,GAAG,IAAAI,kBAAU,EAACJ,OAAO,GAAGX,GAAG,CAAC;AAC/D;AAEO,SAASc,WAAWA,CAAC/B,MAAc,EAAE;EAC1C,OAAOI,eAAI,CAAC6B,QAAQ,CAACjC,MAAM,CAAC,CAAC8B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;AACtD"}
@@ -2,6 +2,6 @@ export type SerialAsset = {
2
2
  originFilename: string;
3
3
  filename: string;
4
4
  source: string;
5
- type: 'css' | 'js';
5
+ type: 'css' | 'js' | 'map';
6
6
  metadata: Record<string, string>;
7
7
  };
@@ -1 +1 @@
1
- {"version":3,"file":"serializerAssets.js","names":[],"sources":["../../src/serializer/serializerAssets.ts"],"sourcesContent":["export type SerialAsset = {\n // 'styles.css'\n originFilename: string;\n // '_expo/static/css/bc6aa0a69dcebf8e8cac1faa76705756.css'\n filename: string;\n // '\\ndiv {\\n background: cyan;\\n}\\n\\n'\n source: string;\n type: 'css' | 'js';\n\n metadata: Record<string, string>;\n};\n"],"mappings":""}
1
+ {"version":3,"file":"serializerAssets.js","names":[],"sources":["../../src/serializer/serializerAssets.ts"],"sourcesContent":["export type SerialAsset = {\n // 'styles.css'\n originFilename: string;\n // '_expo/static/css/bc6aa0a69dcebf8e8cac1faa76705756.css'\n filename: string;\n // '\\ndiv {\\n background: cyan;\\n}\\n\\n'\n source: string;\n type: 'css' | 'js' | 'map';\n\n metadata: Record<string, string>;\n};\n"],"mappings":""}
@@ -26,6 +26,13 @@ function _baseJSBundle() {
26
26
  };
27
27
  return data;
28
28
  }
29
+ function _sourceMapString() {
30
+ const data = _interopRequireDefault(require("metro/src/DeltaBundler/Serializers/sourceMapString"));
31
+ _sourceMapString = function () {
32
+ return data;
33
+ };
34
+ return data;
35
+ }
29
36
  function _bundleToString() {
30
37
  const data = _interopRequireDefault(require("metro/src/lib/bundleToString"));
31
38
  _bundleToString = function () {
@@ -33,9 +40,9 @@ function _bundleToString() {
33
40
  };
34
41
  return data;
35
42
  }
36
- function _env() {
37
- const data = require("../env");
38
- _env = function () {
43
+ function _path() {
44
+ const data = _interopRequireDefault(require("path"));
45
+ _path = function () {
39
46
  return data;
40
47
  };
41
48
  return data;
@@ -61,6 +68,13 @@ function _serializerAssets() {
61
68
  };
62
69
  return data;
63
70
  }
71
+ function _env() {
72
+ const data = require("../env");
73
+ _env = function () {
74
+ return data;
75
+ };
76
+ return data;
77
+ }
64
78
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
65
79
  /**
66
80
  * Copyright © 2022 650 Industries.
@@ -69,8 +83,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
69
83
  * LICENSE file in the root directory of this source tree.
70
84
  */
71
85
 
86
+ // @ts-expect-error
87
+
72
88
  function withExpoSerializers(config) {
73
89
  const processors = [];
90
+ processors.push(_environmentVariableSerializerPlugin().serverPreludeSerializerPlugin);
74
91
  if (!_env().env.EXPO_NO_CLIENT_ENV_VARS) {
75
92
  processors.push(_environmentVariableSerializerPlugin().environmentVariableSerializerPlugin);
76
93
  }
@@ -97,8 +114,8 @@ function getDefaultSerializer(fallbackSerializer) {
97
114
  return outputCode;
98
115
  };
99
116
  return async (...props) => {
100
- const [,, graph, options] = props;
101
- const jsCode = await defaultSerializer(...props);
117
+ const [entryPoint, preModules, graph, options] = props;
118
+ const jsCode = await defaultSerializer(entryPoint, preModules, graph, options);
102
119
  if (!options.sourceUrl) {
103
120
  return jsCode;
104
121
  }
@@ -108,27 +125,75 @@ function getDefaultSerializer(fallbackSerializer) {
108
125
  // Default behavior if `serializer.output=static` is not present in the URL.
109
126
  return jsCode;
110
127
  }
128
+ const includeSourceMaps = url.searchParams.get('serializer.map') === 'true';
111
129
  const cssDeps = (0, _getCssDeps().getCssSerialAssets)(graph.dependencies, {
112
130
  projectRoot: options.projectRoot,
113
131
  processModuleFilter: options.processModuleFilter
114
132
  });
115
- let jsAsset;
133
+ const jsAssets = [];
116
134
  if (jsCode) {
117
135
  const stringContents = typeof jsCode === 'string' ? jsCode : jsCode.code;
118
- jsAsset = {
119
- filename: options.dev ? 'index.js' : `_expo/static/js/web/${(0, _getCssDeps().fileNameFromContents)({
120
- filepath: url.pathname,
121
- src: stringContents
122
- })}.js`,
136
+ const jsFilename = (0, _getCssDeps().fileNameFromContents)({
137
+ filepath: url.pathname,
138
+ src: stringContents
139
+ });
140
+ jsAssets.push({
141
+ filename: options.dev ? 'index.js' : `_expo/static/js/web/${jsFilename}.js`,
123
142
  originFilename: 'index.js',
124
143
  type: 'js',
125
144
  metadata: {},
126
145
  source: stringContents
127
- };
146
+ });
147
+ if (
148
+ // Only include the source map if the `options.sourceMapUrl` option is provided and we are exporting a static build.
149
+ includeSourceMaps && options.sourceMapUrl) {
150
+ const sourceMap = typeof jsCode === 'string' ? serializeToSourceMap(...props) : jsCode.map;
151
+
152
+ // Make all paths relative to the server root to prevent the entire user filesystem from being exposed.
153
+ const parsed = JSON.parse(sourceMap);
154
+ // TODO: Maybe we can do this earlier.
155
+ parsed.sources = parsed.sources.map(
156
+ // TODO: Maybe basePath support
157
+ value => {
158
+ if (value.startsWith('/')) {
159
+ var _options$serverRoot;
160
+ return '/' + _path().default.relative((_options$serverRoot = options.serverRoot) !== null && _options$serverRoot !== void 0 ? _options$serverRoot : options.projectRoot, value);
161
+ }
162
+ // Prevent `__prelude__` from being relative.
163
+ return value;
164
+ });
165
+ jsAssets.push({
166
+ filename: options.dev ? 'index.map' : `_expo/static/js/web/${jsFilename}.js.map`,
167
+ originFilename: 'index.map',
168
+ type: 'map',
169
+ metadata: {},
170
+ source: JSON.stringify(parsed)
171
+ });
172
+ }
128
173
  }
129
- return JSON.stringify([jsAsset, ...cssDeps]);
174
+ return JSON.stringify([...jsAssets, ...cssDeps]);
130
175
  };
131
176
  }
177
+ function getSortedModules(graph, {
178
+ createModuleId
179
+ }) {
180
+ const modules = [...graph.dependencies.values()];
181
+ // Assign IDs to modules in a consistent order
182
+ for (const module of modules) {
183
+ createModuleId(module.path);
184
+ }
185
+ // Sort by IDs
186
+ return modules.sort((a, b) => createModuleId(a.path) - createModuleId(b.path));
187
+ }
188
+ function serializeToSourceMap(...props) {
189
+ const [, prepend, graph, options] = props;
190
+ const modules = [...prepend, ...getSortedModules(graph, {
191
+ createModuleId: options.createModuleId
192
+ })];
193
+ return (0, _sourceMapString().default)(modules, {
194
+ ...options
195
+ });
196
+ }
132
197
  function createSerializerFromSerialProcessors(processors, originalSerializer) {
133
198
  const finalSerializer = getDefaultSerializer(originalSerializer);
134
199
  return (...props) => {
@@ -1 +1 @@
1
- {"version":3,"file":"withExpoSerializers.js","names":["_jscSafeUrl","data","require","_baseJSBundle","_interopRequireDefault","_bundleToString","_env","_environmentVariableSerializerPlugin","_getCssDeps","_serializerAssets","obj","__esModule","default","withExpoSerializers","config","processors","env","EXPO_NO_CLIENT_ENV_VARS","push","environmentVariableSerializerPlugin","withSerializerPlugins","_config$serializer","originalSerializer","serializer","customSerializer","createSerializerFromSerialProcessors","getDefaultSerializer","fallbackSerializer","defaultSerializer","params","bundle","baseJSBundle","outputCode","bundleToString","code","props","graph","options","jsCode","sourceUrl","isJscSafeUrl","toNormalUrl","url","URL","searchParams","get","cssDeps","getCssSerialAssets","dependencies","projectRoot","processModuleFilter","jsAsset","stringContents","filename","dev","fileNameFromContents","filepath","pathname","src","originFilename","type","metadata","source","JSON","stringify","finalSerializer","processor"],"sources":["../../src/serializer/withExpoSerializers.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { isJscSafeUrl, toNormalUrl } from 'jsc-safe-url';\nimport { MixedOutput } from 'metro';\nimport { InputConfigT, SerializerConfigT } from 'metro-config';\nimport baseJSBundle from 'metro/src/DeltaBundler/Serializers/baseJSBundle';\nimport bundleToString from 'metro/src/lib/bundleToString';\n\nimport { env } from '../env';\nimport { environmentVariableSerializerPlugin } from './environmentVariableSerializerPlugin';\nimport { fileNameFromContents, getCssSerialAssets } from './getCssDeps';\nimport { SerialAsset } from './serializerAssets';\n\nexport type Serializer = NonNullable<SerializerConfigT['customSerializer']>;\n\nexport type SerializerParameters = Parameters<Serializer>;\n\n// A serializer that processes the input and returns a modified version.\n// Unlike a serializer, these can be chained together.\nexport type SerializerPlugin = (...props: SerializerParameters) => SerializerParameters;\n\nexport function withExpoSerializers(config: InputConfigT): InputConfigT {\n const processors: SerializerPlugin[] = [];\n if (!env.EXPO_NO_CLIENT_ENV_VARS) {\n processors.push(environmentVariableSerializerPlugin);\n }\n\n return withSerializerPlugins(config, processors);\n}\n\n// There can only be one custom serializer as the input doesn't match the output.\n// Here we simply run\nexport function withSerializerPlugins(\n config: InputConfigT,\n processors: SerializerPlugin[]\n): InputConfigT {\n const originalSerializer = config.serializer?.customSerializer;\n\n return {\n ...config,\n serializer: {\n ...config.serializer,\n customSerializer: createSerializerFromSerialProcessors(processors, originalSerializer),\n },\n };\n}\n\nfunction getDefaultSerializer(fallbackSerializer?: Serializer | null): Serializer {\n const defaultSerializer =\n fallbackSerializer ??\n (async (...params: SerializerParameters) => {\n const bundle = baseJSBundle(...params);\n const outputCode = bundleToString(bundle).code;\n return outputCode;\n });\n return async (\n ...props: SerializerParameters\n ): Promise<string | { code: string; map: string }> => {\n const [, , graph, options] = props;\n const jsCode = await defaultSerializer(...props);\n\n if (!options.sourceUrl) {\n return jsCode;\n }\n const sourceUrl = isJscSafeUrl(options.sourceUrl)\n ? toNormalUrl(options.sourceUrl)\n : options.sourceUrl;\n const url = new URL(sourceUrl, 'https://expo.dev');\n if (\n url.searchParams.get('platform') !== 'web' ||\n url.searchParams.get('serializer.output') !== 'static'\n ) {\n // Default behavior if `serializer.output=static` is not present in the URL.\n return jsCode;\n }\n\n const cssDeps = getCssSerialAssets<MixedOutput>(graph.dependencies, {\n projectRoot: options.projectRoot,\n processModuleFilter: options.processModuleFilter,\n });\n\n let jsAsset: SerialAsset | undefined;\n\n if (jsCode) {\n const stringContents = typeof jsCode === 'string' ? jsCode : jsCode.code;\n jsAsset = {\n filename: options.dev\n ? 'index.js'\n : `_expo/static/js/web/${fileNameFromContents({\n filepath: url.pathname,\n src: stringContents,\n })}.js`,\n originFilename: 'index.js',\n type: 'js',\n metadata: {},\n source: stringContents,\n };\n }\n\n return JSON.stringify([jsAsset, ...cssDeps]);\n };\n}\n\nexport function createSerializerFromSerialProcessors(\n processors: (SerializerPlugin | undefined)[],\n originalSerializer?: Serializer | null\n): Serializer {\n const finalSerializer = getDefaultSerializer(originalSerializer);\n return (...props: SerializerParameters): ReturnType<Serializer> => {\n for (const processor of processors) {\n if (processor) {\n props = processor(...props);\n }\n }\n\n return finalSerializer(...props);\n };\n}\n\nexport { SerialAsset };\n"],"mappings":";;;;;;;;;;;;;;AAMA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,cAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,aAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,gBAAA;EAAA,MAAAJ,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAG,eAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,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AAGA,MAAM,GAAGA,MAAM,CAACJ,IAAI;MACxEiB,OAAO,GAAG;QACRE,QAAQ,EAAEhB,OAAO,CAACiB,GAAG,GACjB,UAAU,GACT,uBAAsB,IAAAC,kCAAoB,EAAC;UAC1CC,QAAQ,EAAEd,GAAG,CAACe,QAAQ;UACtBC,GAAG,EAAEN;QACP,CAAC,CAAE,KAAI;QACXO,cAAc,EAAE,UAAU;QAC1BC,IAAI,EAAE,IAAI;QACVC,QAAQ,EAAE,CAAC,CAAC;QACZC,MAAM,EAAEV;MACV,CAAC;IACH;IAEA,OAAOW,IAAI,CAACC,SAAS,CAAC,CAACb,OAAO,EAAE,GAAGL,OAAO,CAAC,CAAC;EAC9C,CAAC;AACH;AAEO,SAASrB,oCAAoCA,CAClDV,UAA4C,EAC5CO,kBAAsC,EAC1B;EACZ,MAAM2C,eAAe,GAAGvC,oBAAoB,CAACJ,kBAAkB,CAAC;EAChE,OAAO,CAAC,GAAGa,KAA2B,KAA6B;IACjE,KAAK,MAAM+B,SAAS,IAAInD,UAAU,EAAE;MAClC,IAAImD,SAAS,EAAE;QACb/B,KAAK,GAAG+B,SAAS,CAAC,GAAG/B,KAAK,CAAC;MAC7B;IACF;IAEA,OAAO8B,eAAe,CAAC,GAAG9B,KAAK,CAAC;EAClC,CAAC;AACH"}
1
+ {"version":3,"file":"withExpoSerializers.js","names":["_jscSafeUrl","data","require","_baseJSBundle","_interopRequireDefault","_sourceMapString","_bundleToString","_path","_environmentVariableSerializerPlugin","_getCssDeps","_serializerAssets","_env","obj","__esModule","default","withExpoSerializers","config","processors","push","serverPreludeSerializerPlugin","env","EXPO_NO_CLIENT_ENV_VARS","environmentVariableSerializerPlugin","withSerializerPlugins","_config$serializer","originalSerializer","serializer","customSerializer","createSerializerFromSerialProcessors","getDefaultSerializer","fallbackSerializer","defaultSerializer","params","bundle","baseJSBundle","outputCode","bundleToString","code","props","entryPoint","preModules","graph","options","jsCode","sourceUrl","isJscSafeUrl","toNormalUrl","url","URL","searchParams","get","includeSourceMaps","cssDeps","getCssSerialAssets","dependencies","projectRoot","processModuleFilter","jsAssets","stringContents","jsFilename","fileNameFromContents","filepath","pathname","src","filename","dev","originFilename","type","metadata","source","sourceMapUrl","sourceMap","serializeToSourceMap","map","parsed","JSON","parse","sources","value","startsWith","_options$serverRoot","path","relative","serverRoot","stringify","getSortedModules","createModuleId","modules","values","module","sort","a","b","prepend","sourceMapString","finalSerializer","processor"],"sources":["../../src/serializer/withExpoSerializers.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { isJscSafeUrl, toNormalUrl } from 'jsc-safe-url';\nimport { Module, MixedOutput } from 'metro';\nimport baseJSBundle from 'metro/src/DeltaBundler/Serializers/baseJSBundle';\n// @ts-expect-error\nimport sourceMapString from 'metro/src/DeltaBundler/Serializers/sourceMapString';\nimport bundleToString from 'metro/src/lib/bundleToString';\nimport { InputConfigT, SerializerConfigT } from 'metro-config';\nimport path from 'path';\n\nimport {\n serverPreludeSerializerPlugin,\n environmentVariableSerializerPlugin,\n} from './environmentVariableSerializerPlugin';\nimport { fileNameFromContents, getCssSerialAssets } from './getCssDeps';\nimport { SerialAsset } from './serializerAssets';\nimport { env } from '../env';\n\nexport type Serializer = NonNullable<SerializerConfigT['customSerializer']>;\n\nexport type SerializerParameters = Parameters<Serializer>;\n\n// A serializer that processes the input and returns a modified version.\n// Unlike a serializer, these can be chained together.\nexport type SerializerPlugin = (...props: SerializerParameters) => SerializerParameters;\n\nexport function withExpoSerializers(config: InputConfigT): InputConfigT {\n const processors: SerializerPlugin[] = [];\n processors.push(serverPreludeSerializerPlugin);\n if (!env.EXPO_NO_CLIENT_ENV_VARS) {\n processors.push(environmentVariableSerializerPlugin);\n }\n\n return withSerializerPlugins(config, processors);\n}\n\n// There can only be one custom serializer as the input doesn't match the output.\n// Here we simply run\nexport function withSerializerPlugins(\n config: InputConfigT,\n processors: SerializerPlugin[]\n): InputConfigT {\n const originalSerializer = config.serializer?.customSerializer;\n\n return {\n ...config,\n serializer: {\n ...config.serializer,\n customSerializer: createSerializerFromSerialProcessors(processors, originalSerializer),\n },\n };\n}\n\nfunction getDefaultSerializer(fallbackSerializer?: Serializer | null): Serializer {\n const defaultSerializer =\n fallbackSerializer ??\n (async (...params: SerializerParameters) => {\n const bundle = baseJSBundle(...params);\n const outputCode = bundleToString(bundle).code;\n return outputCode;\n });\n return async (\n ...props: SerializerParameters\n ): Promise<string | { code: string; map: string }> => {\n const [entryPoint, preModules, graph, options] = props;\n\n const jsCode = await defaultSerializer(entryPoint, preModules, graph, options);\n\n if (!options.sourceUrl) {\n return jsCode;\n }\n const sourceUrl = isJscSafeUrl(options.sourceUrl)\n ? toNormalUrl(options.sourceUrl)\n : options.sourceUrl;\n const url = new URL(sourceUrl, 'https://expo.dev');\n if (\n url.searchParams.get('platform') !== 'web' ||\n url.searchParams.get('serializer.output') !== 'static'\n ) {\n // Default behavior if `serializer.output=static` is not present in the URL.\n return jsCode;\n }\n\n const includeSourceMaps = url.searchParams.get('serializer.map') === 'true';\n\n const cssDeps = getCssSerialAssets<MixedOutput>(graph.dependencies, {\n projectRoot: options.projectRoot,\n processModuleFilter: options.processModuleFilter,\n });\n\n const jsAssets: SerialAsset[] = [];\n\n if (jsCode) {\n const stringContents = typeof jsCode === 'string' ? jsCode : jsCode.code;\n const jsFilename = fileNameFromContents({\n filepath: url.pathname,\n src: stringContents,\n });\n jsAssets.push({\n filename: options.dev ? 'index.js' : `_expo/static/js/web/${jsFilename}.js`,\n originFilename: 'index.js',\n type: 'js',\n metadata: {},\n source: stringContents,\n });\n\n if (\n // Only include the source map if the `options.sourceMapUrl` option is provided and we are exporting a static build.\n includeSourceMaps &&\n options.sourceMapUrl\n ) {\n const sourceMap = typeof jsCode === 'string' ? serializeToSourceMap(...props) : jsCode.map;\n\n // Make all paths relative to the server root to prevent the entire user filesystem from being exposed.\n const parsed = JSON.parse(sourceMap);\n // TODO: Maybe we can do this earlier.\n parsed.sources = parsed.sources.map(\n // TODO: Maybe basePath support\n (value: string) => {\n if (value.startsWith('/')) {\n return '/' + path.relative(options.serverRoot ?? options.projectRoot, value);\n }\n // Prevent `__prelude__` from being relative.\n return value;\n }\n );\n\n jsAssets.push({\n filename: options.dev ? 'index.map' : `_expo/static/js/web/${jsFilename}.js.map`,\n originFilename: 'index.map',\n type: 'map',\n metadata: {},\n source: JSON.stringify(parsed),\n });\n }\n }\n\n return JSON.stringify([...jsAssets, ...cssDeps]);\n };\n}\n\nfunction getSortedModules(\n graph: SerializerParameters[2],\n {\n createModuleId,\n }: {\n createModuleId: (path: string) => number;\n }\n): readonly Module<any>[] {\n const modules = [...graph.dependencies.values()];\n // Assign IDs to modules in a consistent order\n for (const module of modules) {\n createModuleId(module.path);\n }\n // Sort by IDs\n return modules.sort(\n (a: Module<any>, b: Module<any>) => createModuleId(a.path) - createModuleId(b.path)\n );\n}\n\nfunction serializeToSourceMap(...props: SerializerParameters): string {\n const [, prepend, graph, options] = props;\n\n const modules = [\n ...prepend,\n ...getSortedModules(graph, {\n createModuleId: options.createModuleId,\n }),\n ];\n\n return sourceMapString(modules, {\n ...options,\n });\n}\n\nexport function createSerializerFromSerialProcessors(\n processors: (SerializerPlugin | undefined)[],\n originalSerializer?: Serializer | null\n): Serializer {\n const finalSerializer = getDefaultSerializer(originalSerializer);\n return (...props: SerializerParameters): ReturnType<Serializer> => {\n for (const processor of processors) {\n if (processor) {\n props = processor(...props);\n }\n }\n\n return finalSerializer(...props);\n };\n}\n\nexport { SerialAsset };\n"],"mappings":";;;;;;;;;;;;;;AAMA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,cAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,aAAA,YAAAA,CAAA;IAAA,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CAAC,GAAGK,cAAc,CAACM,CAAC,CAACX,IAAI,CAAC,CACpF;AACH;AAEA,SAAST,oBAAoBA,CAAC,GAAGlC,KAA2B,EAAU;EACpE,MAAM,GAAGuD,OAAO,EAAEpD,KAAK,EAAEC,OAAO,CAAC,GAAGJ,KAAK;EAEzC,MAAMiD,OAAO,GAAG,CACd,GAAGM,OAAO,EACV,GAAGR,gBAAgB,CAAC5C,KAAK,EAAE;IACzB6C,cAAc,EAAE5C,OAAO,CAAC4C;EAC1B,CAAC,CAAC,CACH;EAED,OAAO,IAAAQ,0BAAe,EAACP,OAAO,EAAE;IAC9B,GAAG7C;EACL,CAAC,CAAC;AACJ;AAEO,SAASd,oCAAoCA,CAClDX,UAA4C,EAC5CQ,kBAAsC,EAC1B;EACZ,MAAMsE,eAAe,GAAGlE,oBAAoB,CAACJ,kBAAkB,CAAC;EAChE,OAAO,CAAC,GAAGa,KAA2B,KAA6B;IACjE,KAAK,MAAM0D,SAAS,IAAI/E,UAAU,EAAE;MAClC,IAAI+E,SAAS,EAAE;QACb1D,KAAK,GAAG0D,SAAS,CAAC,GAAG1D,KAAK,CAAC;MAC7B;IACF;IAEA,OAAOyD,eAAe,CAAC,GAAGzD,KAAK,CAAC;EAClC,CAAC;AACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/metro-config",
3
- "version": "0.11.1",
3
+ "version": "0.13.0",
4
4
  "description": "A Metro config for running React Native projects with the Metro bundler",
5
5
  "main": "build/ExpoMetroConfig.js",
6
6
  "scripts": {
@@ -32,7 +32,7 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "babel-preset-fbjs": "^3.4.0",
35
- "@expo/config": "~8.2.0",
35
+ "@expo/config": "~8.3.0",
36
36
  "@expo/env": "~0.1.0",
37
37
  "@expo/json-file": "~8.2.37",
38
38
  "chalk": "^4.1.0",
@@ -56,5 +56,5 @@
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  },
59
- "gitHead": "2240630a92eb79a4e4bf73e1439916c394876478"
59
+ "gitHead": "ee2c866ba3c7fbc35ff2a3e896041cf15d3bd7c5"
60
60
  }