@expo/cli 57.0.27 → 57.0.29
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.
- package/build/bin/cli +1 -1
- package/build/src/events/index.js +1 -1
- package/build/src/prebuild/resolveLocalTemplate.js +14 -8
- package/build/src/prebuild/resolveLocalTemplate.js.map +1 -1
- package/build/src/start/server/metro/createTypescriptResolver.js +2 -2
- package/build/src/start/server/metro/createTypescriptResolver.js.map +1 -1
- package/build/src/start/server/middleware/CorsMiddleware.js +1 -1
- package/build/src/start/server/middleware/CorsMiddleware.js.map +1 -1
- package/build/src/utils/obj.js +3 -0
- package/build/src/utils/obj.js.map +1 -1
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/package.json +15 -15
package/build/bin/cli
CHANGED
|
@@ -76,7 +76,7 @@ function getInitMetadata() {
|
|
|
76
76
|
return {
|
|
77
77
|
format: 'v0-jsonl',
|
|
78
78
|
// Version is added in the build script.
|
|
79
|
-
version: "57.0.
|
|
79
|
+
version: "57.0.29" ?? 'UNVERSIONED'
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
function getWellKnownTemporaryLogFile(projectRoot, command) {
|
|
@@ -8,6 +8,13 @@ Object.defineProperty(exports, "resolveLocalTemplateAsync", {
|
|
|
8
8
|
return resolveLocalTemplateAsync;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
function _requireutils() {
|
|
12
|
+
const data = require("@expo/require-utils");
|
|
13
|
+
_requireutils = function() {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
11
18
|
function _fs() {
|
|
12
19
|
const data = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
13
20
|
_fs = function() {
|
|
@@ -22,13 +29,6 @@ function _path() {
|
|
|
22
29
|
};
|
|
23
30
|
return data;
|
|
24
31
|
}
|
|
25
|
-
function _resolvefrom() {
|
|
26
|
-
const data = /*#__PURE__*/ _interop_require_default(require("resolve-from"));
|
|
27
|
-
_resolvefrom = function() {
|
|
28
|
-
return data;
|
|
29
|
-
};
|
|
30
|
-
return data;
|
|
31
|
-
}
|
|
32
32
|
const _npm = require("../utils/npm");
|
|
33
33
|
function _interop_require_default(obj) {
|
|
34
34
|
return obj && obj.__esModule ? obj : {
|
|
@@ -61,7 +61,13 @@ async function resolveLocalTemplateAsync({ templateDirectory, projectRoot, exp }
|
|
|
61
61
|
}
|
|
62
62
|
} else {
|
|
63
63
|
// The default is to use `expo/template.tgz` which exists in all published versions of it
|
|
64
|
-
|
|
64
|
+
const resolvedTemplatePath = (0, _requireutils().resolveFrom)(projectRoot, 'expo/template.tgz', {
|
|
65
|
+
extensions: []
|
|
66
|
+
});
|
|
67
|
+
if (!resolvedTemplatePath) {
|
|
68
|
+
throw new Error(`Cannot resolve 'expo/template.tgz' from '${projectRoot}'`);
|
|
69
|
+
}
|
|
70
|
+
templatePath = resolvedTemplatePath;
|
|
65
71
|
debug('Using local template from Expo package:', templatePath);
|
|
66
72
|
}
|
|
67
73
|
return await (0, _npm.extractLocalNpmTarballAsync)(templatePath, templateDirectory, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prebuild/resolveLocalTemplate.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/prebuild/resolveLocalTemplate.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config';\nimport { resolveFrom } from '@expo/require-utils';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { packNpmTarballAsync, extractLocalNpmTarballAsync } from '../utils/npm';\n\nconst debug = require('debug')('expo:prebuild:resolveLocalTemplate') as typeof console.log;\n\n/** Returns the `local-template` target path, only for the `expo/expo` monorepo */\nconst getMonorepoTemplatePath = async () => {\n const cliPath = path.dirname(require.resolve('@expo/cli/package.json'));\n const localTemplateOriginPath = path.join(cliPath, 'local-template');\n try {\n return await fs.promises.realpath(localTemplateOriginPath);\n } catch {\n return null;\n }\n};\n\nexport async function resolveLocalTemplateAsync({\n templateDirectory,\n projectRoot,\n exp,\n}: {\n templateDirectory: string;\n projectRoot: string;\n exp: Pick<ExpoConfig, 'name'>;\n}): Promise<string> {\n let templatePath: string;\n\n // In the expo/expo monorepo only, we use `templates/expo-template-bare-minimum` directly\n const monorepoTemplatePath = await getMonorepoTemplatePath();\n if (monorepoTemplatePath) {\n debug('Packing local template from expo-template-bare-minimum path:', monorepoTemplatePath);\n try {\n templatePath = await packNpmTarballAsync(monorepoTemplatePath);\n debug('Using packed local template at:', templatePath);\n } catch (error) {\n // We're vocal here about an error, since we don't expect this to fail, and it's only for our monorepo\n console.error(\n `Failed to pack local expo-template-bare-minimum to be used as a prebuild template:\\n`,\n error\n );\n throw error;\n }\n } else {\n // The default is to use `expo/template.tgz` which exists in all published versions of it\n const resolvedTemplatePath = resolveFrom(projectRoot, 'expo/template.tgz', { extensions: [] });\n if (!resolvedTemplatePath) {\n throw new Error(`Cannot resolve 'expo/template.tgz' from '${projectRoot}'`);\n }\n templatePath = resolvedTemplatePath;\n debug('Using local template from Expo package:', templatePath);\n }\n\n return await extractLocalNpmTarballAsync(templatePath, templateDirectory, {\n expName: exp.name,\n });\n}\n"],"names":["resolveLocalTemplateAsync","debug","require","getMonorepoTemplatePath","cliPath","path","dirname","resolve","localTemplateOriginPath","join","fs","promises","realpath","templateDirectory","projectRoot","exp","templatePath","monorepoTemplatePath","packNpmTarballAsync","error","console","resolvedTemplatePath","resolveFrom","extensions","Error","extractLocalNpmTarballAsync","expName","name"],"mappings":";;;;+BAoBsBA;;;eAAAA;;;;yBAnBM;;;;;;;gEACb;;;;;;;gEACE;;;;;;qBAEgD;;;;;;AAEjE,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,gFAAgF,GAChF,MAAMC,0BAA0B;IAC9B,MAAMC,UAAUC,eAAI,CAACC,OAAO,CAACJ,QAAQK,OAAO,CAAC;IAC7C,MAAMC,0BAA0BH,eAAI,CAACI,IAAI,CAACL,SAAS;IACnD,IAAI;QACF,OAAO,MAAMM,aAAE,CAACC,QAAQ,CAACC,QAAQ,CAACJ;IACpC,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEO,eAAeR,0BAA0B,EAC9Ca,iBAAiB,EACjBC,WAAW,EACXC,GAAG,EAKJ;IACC,IAAIC;IAEJ,yFAAyF;IACzF,MAAMC,uBAAuB,MAAMd;IACnC,IAAIc,sBAAsB;QACxBhB,MAAM,gEAAgEgB;QACtE,IAAI;YACFD,eAAe,MAAME,IAAAA,wBAAmB,EAACD;YACzChB,MAAM,mCAAmCe;QAC3C,EAAE,OAAOG,OAAO;YACd,sGAAsG;YACtGC,QAAQD,KAAK,CACX,CAAC,oFAAoF,CAAC,EACtFA;YAEF,MAAMA;QACR;IACF,OAAO;QACL,yFAAyF;QACzF,MAAME,uBAAuBC,IAAAA,2BAAW,EAACR,aAAa,qBAAqB;YAAES,YAAY,EAAE;QAAC;QAC5F,IAAI,CAACF,sBAAsB;YACzB,MAAM,IAAIG,MAAM,CAAC,yCAAyC,EAAEV,YAAY,CAAC,CAAC;QAC5E;QACAE,eAAeK;QACfpB,MAAM,2CAA2Ce;IACnD;IAEA,OAAO,MAAMS,IAAAA,gCAA2B,EAACT,cAAcH,mBAAmB;QACxEa,SAASX,IAAIY,IAAI;IACnB;AACF"}
|
|
@@ -118,7 +118,7 @@ function setupTsConfigWatcher(input, bundler, projectRoot) {
|
|
|
118
118
|
}
|
|
119
119
|
const escapePrefix = (str)=>str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
120
120
|
function joinBaseUrl(baseUrl, lookup) {
|
|
121
|
-
return _path().default.
|
|
121
|
+
return _path().default.resolve(baseUrl, lookup);
|
|
122
122
|
}
|
|
123
123
|
function _resolveWithTsConfigPaths(config, moduleName, resolve) {
|
|
124
124
|
// Exact matches contain no '*' wildcards, and can be 1:1 replacements
|
|
@@ -404,7 +404,7 @@ function _loadTsConfigWithExtends(projectRoot, configPath, depGraph) {
|
|
|
404
404
|
return lookup == null ? void 0 : lookup.absolutePath;
|
|
405
405
|
}
|
|
406
406
|
/** TypeScript's `${configDir}` template prefix for the user config's path */ function substituteConfigDir(value, configDir) {
|
|
407
|
-
return value.startsWith('${configDir}') ? value.replace('${configDir}',
|
|
407
|
+
return value.startsWith('${configDir}') ? _path().default.resolve(configDir, value.replace('${configDir}', './')) : value;
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
//# sourceMappingURL=createTypescriptResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/createTypescriptResolver.ts"],"sourcesContent":["// Resolves bare module specifiers using `compilerOptions.paths` and `compilerOptions.baseUrl`\n// from the project's tsconfig.json or jsconfig.json.\n// Includes a standalone tsconfig parser that walks the `extends` chain using @expo/json-file\n// without depending on the `typescript` package. Uses Metro's DependencyGraph for file\n// existence, realpath, and node_modules resolution.\n\nimport JsonFile from '@expo/json-file';\nimport type Bundler from '@expo/metro/metro/Bundler';\nimport type DependencyGraph from '@expo/metro/metro/node-haste/DependencyGraph';\nimport type FileMap from '@expo/metro/metro-file-map';\nimport type { FileSystem, ChangeEvent } from '@expo/metro/metro-file-map';\nimport { RootPathUtils } from '@expo/metro/metro-file-map/lib/RootPathUtils';\nimport type { ResolutionContext, Resolution } from '@expo/metro/metro-resolver';\nimport path from 'path';\n\nimport { isFailedToResolveNameError, isFailedToResolvePathError } from './metroErrors';\nimport type { StrictResolverFactory } from './withMetroMultiPlatform';\nimport type { ExpoCustomMetroResolver } from './withMetroResolvers';\n\nconst debug = require('debug')('expo:start:server:metro:typescript-resolver') as typeof console.log;\n\ninterface ParsedTsConfig {\n baseUrl?: string;\n paths?: Record<string, string[]>;\n pathsBasePath?: string;\n configNormalPaths?: Set<string>;\n}\n\ninterface SuffixEntry {\n suffix: string;\n mapping: string[];\n}\n\nexport interface TsConfigResolveConfig {\n exactMatches: Record<string, string[] | undefined>;\n prefixRe: RegExp | null;\n prefixMap: Record<string, SuffixEntry[]>;\n baseUrl: string | null;\n configNormalPaths: Set<string> | undefined;\n}\n\ninterface TypescriptResolverInput {\n current: TsConfigResolveConfig | null;\n}\n\n/** Creates a TypeScript paths/baseUrl module resolver.\n * @remarks\n * The TypeScript resolver finds and loads tsconfig.json/jsconfig.json configuration files and sets up resolution\n * for `compilerOptions.paths` and `compilerOptions.baseUrl`. These are typically prefix-style replacements of\n * input module specifiers.\n * It lazily initializes the TypeScript configuration and resolves the files via the Metro filesystem for added\n * efficiency.\n * It skips loading TypeScript configurations via the `typescript` package itself and instead approximates\n * TypeScript's behaviour.\n */\nexport function createTypescriptResolver({\n projectRoot,\n getMetroBundler,\n getStrictResolver,\n watch,\n}: {\n projectRoot: string;\n getMetroBundler: () => Bundler;\n getStrictResolver: StrictResolverFactory;\n watch: boolean;\n}): ExpoCustomMetroResolver {\n const input: TypescriptResolverInput = { current: null };\n let initialized = false;\n\n function init() {\n initialized = true;\n const bundler = getMetroBundler();\n const tsconfig = loadTsConfigPaths(projectRoot, bundler._depGraph);\n input.current = _toResolveConfig(tsconfig, projectRoot);\n if (watch) {\n setupTsConfigWatcher(input, bundler, projectRoot);\n }\n }\n\n const fileSpecifierRe = /^[\\\\/]|^\\.\\.?(?:$|[\\\\/])/i;\n const nodeModulesPart = `${path.sep}node_modules${path.sep}`;\n\n return function requestTsconfigPaths(immutableContext, moduleName, platform) {\n if (!initialized) {\n init();\n }\n\n if (!input.current) {\n return null;\n } else if (fileSpecifierRe.test(moduleName)) {\n return null;\n } else if (immutableContext.originModulePath.includes(nodeModulesPart)) {\n return null;\n }\n\n // TypeScript paths resolution is heavily pre-computed, which is processed\n // in the `_toResolveConfig` helper. This allows the actual resolver to do\n // very little work\n return _resolveWithTsConfigPaths(\n input.current,\n moduleName,\n getOptionalResolve(immutableContext, platform, getStrictResolver)\n );\n };\n}\n\nfunction setupTsConfigWatcher(\n input: TypescriptResolverInput,\n bundler: Bundler,\n projectRoot: string\n): void {\n function reload() {\n const tsconfig = loadTsConfigPaths(projectRoot, bundler._depGraph);\n input.current = _toResolveConfig(tsconfig, projectRoot);\n }\n\n const watcher = bundler.getWatcher() as FileMap;\n watcher.addListener('change', ({ changes }: ChangeEvent) => {\n for (const change of changes.addedFiles) {\n // Additions are only relevant if we haven't watched tsconfigs before\n if (change[0] === TSCONFIG_NAME || change[0] === JSCONFIG_NAME) {\n return reload();\n }\n }\n if (input.current?.configNormalPaths) {\n for (const change of changes.modifiedFiles) {\n if (input.current.configNormalPaths.has(change[0])) {\n return reload();\n }\n }\n for (const change of changes.removedFiles) {\n if (input.current.configNormalPaths.has(change[0])) {\n return reload();\n }\n }\n }\n });\n}\n\nconst escapePrefix = (str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\nfunction joinBaseUrl(baseUrl: string, lookup: string): string {\n return path.join(baseUrl, lookup);\n}\n\n/** Attempts to resolve a target module given a pre-processed TypeScript configuration */\nexport function _resolveWithTsConfigPaths(\n config: TsConfigResolveConfig,\n moduleName: string,\n resolve: (moduleName: string) => Resolution | null\n): Resolution | null {\n // Exact matches contain no '*' wildcards, and can be 1:1 replacements\n const exactPaths = config.exactMatches[moduleName];\n if (exactPaths != null) {\n for (const alias of exactPaths) {\n const result = resolve(alias);\n if (result != null) {\n debug(`${moduleName} -> ${alias}`);\n return result;\n }\n }\n return null;\n }\n\n // Widlcard matches contain '*' and we first match the preceding string before it with a regex\n if (config.prefixRe != null) {\n const match = config.prefixRe.exec(moduleName);\n if (match != null) {\n const prefix = match[1]!;\n const rest = moduleName.slice(prefix.length);\n for (const entry of config.prefixMap[prefix]!) {\n let star = rest;\n if (entry.suffix) {\n // If we have a suffix (string after '*') it's checked separately\n // This is cheap, since most matches are complex path prefixes\n if (!rest.endsWith(entry.suffix)) continue;\n star = rest.slice(0, -entry.suffix.length);\n }\n for (const alias of entry.mapping) {\n const possibleResult = alias.replace('*', star);\n const result = resolve(possibleResult);\n if (result != null) {\n debug(`${moduleName} -> ${possibleResult}`);\n return result;\n }\n }\n break; // First matching suffix wins\n }\n\n // NOTE: Special case for `\"*\"` paths pattern (replacement for `baseUrl`)\n // If a non-catch-all prefix matched but failed, try the \"*\" catch-all\n // This could also apply to `*.[ext]` paths commonly though\n if (prefix !== '' && config.prefixMap[''] != null) {\n for (const entry of config.prefixMap['']) {\n let star = moduleName;\n if (entry.suffix) {\n if (!moduleName.endsWith(entry.suffix)) continue;\n star = moduleName.slice(0, -entry.suffix.length);\n }\n for (const alias of entry.mapping) {\n const possibleResult = alias.replace('*', star);\n const result = resolve(possibleResult);\n if (result != null) {\n debug(`${moduleName} -> ${possibleResult}`);\n return result;\n }\n }\n }\n }\n\n return null;\n }\n }\n\n // Only resolve against baseUrl if no `paths` groups were matched.\n // Base URL is resolved after paths, and before node_modules.\n // NOTE: In TypeScript 6 this is disabled unless `\"ignoreDeprecations\": \"6.0\"` is added\n // In TypeScript 7, this will be removed, and `paths['*']` is the replacement\n if (config.baseUrl != null) {\n const possibleResult = joinBaseUrl(config.baseUrl, moduleName);\n const result = resolve(possibleResult);\n if (result) {\n debug(`baseUrl: ${moduleName} -> ${possibleResult}`);\n return result;\n }\n }\n\n return null;\n}\n\nfunction getOptionalResolve(\n context: ResolutionContext,\n platform: string | null,\n getStrictResolver: StrictResolverFactory\n): (moduleName: string) => Resolution | null {\n const doResolve = getStrictResolver(context, platform);\n return function optionalResolve(moduleName: string): Resolution | null {\n try {\n return doResolve(moduleName);\n } catch (error) {\n // If the error is directly related to a resolver not being able to resolve a module, then\n // we can ignore the error and try the next resolver. Otherwise, we should throw the error.\n const isResolutionError =\n isFailedToResolveNameError(error) || isFailedToResolvePathError(error);\n if (!isResolutionError) {\n throw error;\n }\n }\n return null;\n };\n}\n\n/** Pre-processes TypeScript configuration for _resolveWithTsConfigPaths */\nexport function _toResolveConfig(\n tsconfig: ParsedTsConfig | null,\n projectRoot: string\n): TsConfigResolveConfig | null {\n if (!tsconfig || (!tsconfig.paths && tsconfig.baseUrl == null)) {\n return null;\n }\n\n // NOTE(@kitten): We previously had a bug that assumed that paths are relative to the `baseUrl` only\n // However, the `baseUrl` is optional and paths can be relative to the config path instead.\n const pathsBasePath = tsconfig.baseUrl ?? tsconfig.pathsBasePath ?? projectRoot;\n\n const paths = tsconfig.paths ?? {};\n const exactMatches: Record<string, string[]> = Object.create(null);\n const prefixMap: Record<string, SuffixEntry[]> = Object.create(null);\n const seenPrefixes: string[] = [];\n\n for (const key in paths) {\n if (!Array.isArray(paths[key])) {\n continue;\n }\n // Pre-join with baseUrl so the hot path avoids path.join entirely\n const mapping = paths[key]\n .filter((p) => typeof p === 'string' && !p.endsWith('.d.ts'))\n .map((p) => joinBaseUrl(pathsBasePath, p));\n if (mapping.length > 0) {\n const starIndex = key.indexOf('*');\n if (starIndex === -1) {\n exactMatches[key] = mapping;\n } else {\n const prefix = key.slice(0, starIndex);\n const suffix = key.slice(starIndex + 1);\n if (!prefixMap[prefix]) {\n prefixMap[prefix] = [];\n seenPrefixes.push(prefix);\n }\n prefixMap[prefix].push({ suffix, mapping });\n }\n }\n }\n\n // Match longest prefix first\n seenPrefixes.sort((a, b) => b.length - a.length);\n const prefixRe = seenPrefixes.length\n ? new RegExp(`^(${seenPrefixes.map(escapePrefix).join('|')})`)\n : null;\n\n return {\n exactMatches,\n prefixRe,\n prefixMap,\n baseUrl: tsconfig.baseUrl ?? null,\n configNormalPaths: tsconfig.configNormalPaths,\n };\n}\n\nconst TSCONFIG_NAME = 'tsconfig.json';\nconst JSCONFIG_NAME = 'jsconfig.json';\n\nfunction loadTsConfigPaths(projectRoot: string, depGraph: DependencyGraph): ParsedTsConfig | null {\n let configPath: string | null = null;\n if (depGraph.doesFileExist(TSCONFIG_NAME)) {\n configPath = path.join(projectRoot, TSCONFIG_NAME);\n } else if (depGraph.doesFileExist(JSCONFIG_NAME)) {\n configPath = path.join(projectRoot, JSCONFIG_NAME);\n }\n\n if (!configPath) {\n return null;\n }\n\n try {\n return _loadTsConfigWithExtends(projectRoot, configPath, depGraph);\n } catch (error: any) {\n if (error?.isJsonFileError || error?.name === 'SyntaxError') {\n debug(`Failed to parse ${configPath}: ${error.message}`);\n return null;\n }\n throw error;\n }\n}\n\n/** Loads a given tsconfig.json and parses it */\nexport function _loadTsConfigWithExtends(\n projectRoot: string,\n configPath: string,\n depGraph: DependencyGraph\n): ParsedTsConfig | null {\n const visited = new Set<string>();\n const rootConfigDir = path.dirname(configPath);\n\n function load(configPath: string | undefined): ParsedTsConfig | null {\n // NOTE: We avoid cycles here, which are theoretically possible\n // We avoid warning or throwing an error though, since TypeScript will complain about this anyway\n if (typeof configPath !== 'string' || visited.has(configPath)) {\n return null;\n } else {\n visited.add(configPath);\n }\n\n const configDir = path.dirname(configPath);\n const raw = JsonFile.read(configPath, { json5: true });\n const own = extractPathsFromCompilerOptions(raw);\n\n let baseUrl: string | undefined;\n let paths: Record<string, string[]> | undefined;\n let pathsBasePath: string | undefined;\n if (raw.extends) {\n const exts = !Array.isArray(raw.extends) ? [raw.extends] : raw.extends;\n for (const ext of exts) {\n if (typeof ext === 'string') {\n // Resolve the `extends` path with Node-like resolution, similar to TypeScript\n const extPath = resolveExtendsPath(ext, configDir, depGraph._fileSystem);\n const parent = load(extPath);\n if (parent) {\n baseUrl = parent.baseUrl ?? baseUrl;\n paths = parent.paths ?? paths;\n pathsBasePath = parent.pathsBasePath ?? pathsBasePath;\n }\n }\n }\n }\n\n // Outermost config values win, but can be combined\n // The `pathsBasePath` is the path of the config that `paths` are defined in\n // `paths` are not merged\n return {\n baseUrl: own.baseUrl ?? baseUrl,\n paths: own.paths ?? paths,\n pathsBasePath: own.paths != null ? configDir : pathsBasePath,\n };\n }\n\n const result = load(configPath);\n if (result != null) {\n const pathUtils = new RootPathUtils(projectRoot);\n const configPaths = new Set<string>();\n // Keep track of the configuration paths here for the file watcher\n for (const visitedConfigPath of visited) {\n configPaths.add(pathUtils.absoluteToNormal(visitedConfigPath));\n }\n result.configNormalPaths = configPaths;\n if (result.baseUrl != null) {\n result.baseUrl = path.resolve(\n rootConfigDir,\n substituteConfigDir(result.baseUrl, rootConfigDir)\n );\n }\n if (result.paths != null) {\n for (const key in result.paths) {\n const mapping = result.paths[key]!;\n for (let idx = 0; idx < mapping.length; idx++) {\n mapping[idx] = substituteConfigDir(mapping[idx]!, rootConfigDir);\n }\n }\n }\n }\n return result;\n}\n\n/** Normalize JSON's tsconfig compilerOptions */\nfunction extractPathsFromCompilerOptions(raw: Record<string, unknown>): {\n baseUrl?: string;\n paths?: Record<string, string[]>;\n} {\n if (raw.compilerOptions == null || typeof raw.compilerOptions !== 'object') {\n return {};\n }\n const opts = raw.compilerOptions as Record<string, unknown>;\n const baseUrl = typeof opts.baseUrl === 'string' ? opts.baseUrl : undefined;\n\n let paths: Record<string, string[]> | undefined;\n if (opts.paths != null && typeof opts.paths === 'object') {\n paths = {};\n for (const key in opts.paths as Record<string, unknown>) {\n const values = (opts.paths as Record<string, unknown>)[key];\n if (Array.isArray(values)) {\n paths[key] = values.filter((v): v is string => typeof v === 'string');\n }\n }\n }\n\n return { baseUrl, paths };\n}\n\n/** Lookup/resolve an `extends` path */\nfunction resolveExtendsPath(\n targetPath: string,\n configDir: string,\n fileSystem: FileSystem\n): string | undefined {\n let target = fileSystem.lookup(path.join(configDir, targetPath));\n if (target.exists && target.type === 'f') {\n return target.realPath;\n }\n\n if (!targetPath.endsWith('.json')) {\n target = fileSystem.lookup(path.join(configDir, targetPath + '.json'));\n if (target.exists && target.type === 'f') {\n return target.realPath;\n }\n }\n\n // Last attempt is Node-like resolution\n let lookup: null | undefined | { absolutePath: string; containerRelativePath: string };\n if (!targetPath.endsWith('.json')) {\n lookup = fileSystem.hierarchicalLookup(configDir, `node_modules/${targetPath}.json`, {\n subpathType: 'f',\n });\n if (lookup != null) {\n return lookup.absolutePath;\n }\n }\n if (lookup == null) {\n lookup = fileSystem.hierarchicalLookup(configDir, `node_modules/${targetPath}`, {\n subpathType: 'f',\n });\n }\n if (lookup == null && !targetPath.endsWith('.json')) {\n lookup = fileSystem.hierarchicalLookup(\n configDir,\n `node_modules/${targetPath}/${TSCONFIG_NAME}`,\n {\n subpathType: 'f',\n }\n );\n }\n\n // NOTE(@kitten): Some implementations opt to add `package.json:exports` and `package.json:tsconfig`\n // field support here, but it's unclear if this is even supported in TypeScript itself. It's likely\n // not used, as it's impossible to find an example of this anywhere\n\n return lookup?.absolutePath;\n}\n\n/** TypeScript's `${configDir}` template prefix for the user config's path */\nfunction substituteConfigDir(value: string, configDir: string): string {\n return value.startsWith('${configDir}')\n ? value.replace('${configDir}', configDir.endsWith(path.sep) ? '.' : './')\n : value;\n}\n"],"names":["_loadTsConfigWithExtends","_resolveWithTsConfigPaths","_toResolveConfig","createTypescriptResolver","debug","require","projectRoot","getMetroBundler","getStrictResolver","watch","input","current","initialized","init","bundler","tsconfig","loadTsConfigPaths","_depGraph","setupTsConfigWatcher","fileSpecifierRe","nodeModulesPart","path","sep","requestTsconfigPaths","immutableContext","moduleName","platform","test","originModulePath","includes","getOptionalResolve","reload","watcher","getWatcher","addListener","changes","change","addedFiles","TSCONFIG_NAME","JSCONFIG_NAME","configNormalPaths","modifiedFiles","has","removedFiles","escapePrefix","str","replace","joinBaseUrl","baseUrl","lookup","join","config","resolve","exactPaths","exactMatches","alias","result","prefixRe","match","exec","prefix","rest","slice","length","entry","prefixMap","star","suffix","endsWith","mapping","possibleResult","context","doResolve","optionalResolve","error","isResolutionError","isFailedToResolveNameError","isFailedToResolvePathError","paths","pathsBasePath","Object","create","seenPrefixes","key","Array","isArray","filter","p","map","starIndex","indexOf","push","sort","a","b","RegExp","depGraph","configPath","doesFileExist","isJsonFileError","name","message","visited","Set","rootConfigDir","dirname","load","add","configDir","raw","JsonFile","read","json5","own","extractPathsFromCompilerOptions","extends","exts","ext","extPath","resolveExtendsPath","_fileSystem","parent","pathUtils","RootPathUtils","configPaths","visitedConfigPath","absoluteToNormal","substituteConfigDir","idx","compilerOptions","opts","undefined","values","v","targetPath","fileSystem","target","exists","type","realPath","hierarchicalLookup","subpathType","absolutePath","value","startsWith"],"mappings":"AAAA,8FAA8F;AAC9F,qDAAqD;AACrD,6FAA6F;AAC7F,uFAAuF;AACvF,oDAAoD;;;;;;;;;;;;QA4UpCA;eAAAA;;QA9LAC;eAAAA;;QA2GAC;eAAAA;;QAtMAC;eAAAA;;;;gEAjDK;;;;;;;yBAKS;;;;;;;gEAEb;;;;;;6BAEsD;;;;;;AAIvE,MAAMC,QAAQC,QAAQ,SAAS;AAoCxB,SAASF,yBAAyB,EACvCG,WAAW,EACXC,eAAe,EACfC,iBAAiB,EACjBC,KAAK,EAMN;IACC,MAAMC,QAAiC;QAAEC,SAAS;IAAK;IACvD,IAAIC,cAAc;IAElB,SAASC;QACPD,cAAc;QACd,MAAME,UAAUP;QAChB,MAAMQ,WAAWC,kBAAkBV,aAAaQ,QAAQG,SAAS;QACjEP,MAAMC,OAAO,GAAGT,iBAAiBa,UAAUT;QAC3C,IAAIG,OAAO;YACTS,qBAAqBR,OAAOI,SAASR;QACvC;IACF;IAEA,MAAMa,kBAAkB;IACxB,MAAMC,kBAAkB,GAAGC,eAAI,CAACC,GAAG,CAAC,YAAY,EAAED,eAAI,CAACC,GAAG,EAAE;IAE5D,OAAO,SAASC,qBAAqBC,gBAAgB,EAAEC,UAAU,EAAEC,QAAQ;QACzE,IAAI,CAACd,aAAa;YAChBC;QACF;QAEA,IAAI,CAACH,MAAMC,OAAO,EAAE;YAClB,OAAO;QACT,OAAO,IAAIQ,gBAAgBQ,IAAI,CAACF,aAAa;YAC3C,OAAO;QACT,OAAO,IAAID,iBAAiBI,gBAAgB,CAACC,QAAQ,CAACT,kBAAkB;YACtE,OAAO;QACT;QAEA,0EAA0E;QAC1E,0EAA0E;QAC1E,mBAAmB;QACnB,OAAOnB,0BACLS,MAAMC,OAAO,EACbc,YACAK,mBAAmBN,kBAAkBE,UAAUlB;IAEnD;AACF;AAEA,SAASU,qBACPR,KAA8B,EA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;IACF;IAEA,uCAAuC;IACvC,IAAI1F;IACJ,IAAI,CAACqF,WAAWlE,QAAQ,CAAC,UAAU;QACjCnB,SAASsF,WAAWK,kBAAkB,CAAChC,WAAW,CAAC,aAAa,EAAE0B,WAAW,KAAK,CAAC,EAAE;YACnFO,aAAa;QACf;QACA,IAAI5F,UAAU,MAAM;YAClB,OAAOA,OAAO6F,YAAY;QAC5B;IACF;IACA,IAAI7F,UAAU,MAAM;QAClBA,SAASsF,WAAWK,kBAAkB,CAAChC,WAAW,CAAC,aAAa,EAAE0B,YAAY,EAAE;YAC9EO,aAAa;QACf;IACF;IACA,IAAI5F,UAAU,QAAQ,CAACqF,WAAWlE,QAAQ,CAAC,UAAU;QACnDnB,SAASsF,WAAWK,kBAAkB,CACpChC,WACA,CAAC,aAAa,EAAE0B,WAAW,CAAC,EAAEhG,eAAe,EAC7C;YACEuG,aAAa;QACf;IAEJ;IAEA,oGAAoG;IACpG,mGAAmG;IACnG,mEAAmE;IAEnE,OAAO5F,0BAAAA,OAAQ6F,YAAY;AAC7B;AAEA,2EAA2E,GAC3E,SAASf,oBAAoBgB,KAAa,EAAEnC,SAAiB;IAC3D,OAAOmC,MAAMC,UAAU,CAAC,kBACpBD,MAAMjG,OAAO,CAAC,gBAAgB8D,UAAUxC,QAAQ,CAAC/C,eAAI,CAACC,GAAG,IAAI,MAAM,QACnEyH;AACN"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/createTypescriptResolver.ts"],"sourcesContent":["// Resolves bare module specifiers using `compilerOptions.paths` and `compilerOptions.baseUrl`\n// from the project's tsconfig.json or jsconfig.json.\n// Includes a standalone tsconfig parser that walks the `extends` chain using @expo/json-file\n// without depending on the `typescript` package. Uses Metro's DependencyGraph for file\n// existence, realpath, and node_modules resolution.\n\nimport JsonFile from '@expo/json-file';\nimport type Bundler from '@expo/metro/metro/Bundler';\nimport type DependencyGraph from '@expo/metro/metro/node-haste/DependencyGraph';\nimport type FileMap from '@expo/metro/metro-file-map';\nimport type { FileSystem, ChangeEvent } from '@expo/metro/metro-file-map';\nimport { RootPathUtils } from '@expo/metro/metro-file-map/lib/RootPathUtils';\nimport type { ResolutionContext, Resolution } from '@expo/metro/metro-resolver';\nimport path from 'path';\n\nimport { isFailedToResolveNameError, isFailedToResolvePathError } from './metroErrors';\nimport type { StrictResolverFactory } from './withMetroMultiPlatform';\nimport type { ExpoCustomMetroResolver } from './withMetroResolvers';\n\nconst debug = require('debug')('expo:start:server:metro:typescript-resolver') as typeof console.log;\n\ninterface ParsedTsConfig {\n baseUrl?: string;\n paths?: Record<string, string[]>;\n pathsBasePath?: string;\n configNormalPaths?: Set<string>;\n}\n\ninterface SuffixEntry {\n suffix: string;\n mapping: string[];\n}\n\nexport interface TsConfigResolveConfig {\n exactMatches: Record<string, string[] | undefined>;\n prefixRe: RegExp | null;\n prefixMap: Record<string, SuffixEntry[]>;\n baseUrl: string | null;\n configNormalPaths: Set<string> | undefined;\n}\n\ninterface TypescriptResolverInput {\n current: TsConfigResolveConfig | null;\n}\n\n/** Creates a TypeScript paths/baseUrl module resolver.\n * @remarks\n * The TypeScript resolver finds and loads tsconfig.json/jsconfig.json configuration files and sets up resolution\n * for `compilerOptions.paths` and `compilerOptions.baseUrl`. These are typically prefix-style replacements of\n * input module specifiers.\n * It lazily initializes the TypeScript configuration and resolves the files via the Metro filesystem for added\n * efficiency.\n * It skips loading TypeScript configurations via the `typescript` package itself and instead approximates\n * TypeScript's behaviour.\n */\nexport function createTypescriptResolver({\n projectRoot,\n getMetroBundler,\n getStrictResolver,\n watch,\n}: {\n projectRoot: string;\n getMetroBundler: () => Bundler;\n getStrictResolver: StrictResolverFactory;\n watch: boolean;\n}): ExpoCustomMetroResolver {\n const input: TypescriptResolverInput = { current: null };\n let initialized = false;\n\n function init() {\n initialized = true;\n const bundler = getMetroBundler();\n const tsconfig = loadTsConfigPaths(projectRoot, bundler._depGraph);\n input.current = _toResolveConfig(tsconfig, projectRoot);\n if (watch) {\n setupTsConfigWatcher(input, bundler, projectRoot);\n }\n }\n\n const fileSpecifierRe = /^[\\\\/]|^\\.\\.?(?:$|[\\\\/])/i;\n const nodeModulesPart = `${path.sep}node_modules${path.sep}`;\n\n return function requestTsconfigPaths(immutableContext, moduleName, platform) {\n if (!initialized) {\n init();\n }\n\n if (!input.current) {\n return null;\n } else if (fileSpecifierRe.test(moduleName)) {\n return null;\n } else if (immutableContext.originModulePath.includes(nodeModulesPart)) {\n return null;\n }\n\n // TypeScript paths resolution is heavily pre-computed, which is processed\n // in the `_toResolveConfig` helper. This allows the actual resolver to do\n // very little work\n return _resolveWithTsConfigPaths(\n input.current,\n moduleName,\n getOptionalResolve(immutableContext, platform, getStrictResolver)\n );\n };\n}\n\nfunction setupTsConfigWatcher(\n input: TypescriptResolverInput,\n bundler: Bundler,\n projectRoot: string\n): void {\n function reload() {\n const tsconfig = loadTsConfigPaths(projectRoot, bundler._depGraph);\n input.current = _toResolveConfig(tsconfig, projectRoot);\n }\n\n const watcher = bundler.getWatcher() as FileMap;\n watcher.addListener('change', ({ changes }: ChangeEvent) => {\n for (const change of changes.addedFiles) {\n // Additions are only relevant if we haven't watched tsconfigs before\n if (change[0] === TSCONFIG_NAME || change[0] === JSCONFIG_NAME) {\n return reload();\n }\n }\n if (input.current?.configNormalPaths) {\n for (const change of changes.modifiedFiles) {\n if (input.current.configNormalPaths.has(change[0])) {\n return reload();\n }\n }\n for (const change of changes.removedFiles) {\n if (input.current.configNormalPaths.has(change[0])) {\n return reload();\n }\n }\n }\n });\n}\n\nconst escapePrefix = (str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\nfunction joinBaseUrl(baseUrl: string, lookup: string): string {\n return path.resolve(baseUrl, lookup);\n}\n\n/** Attempts to resolve a target module given a pre-processed TypeScript configuration */\nexport function _resolveWithTsConfigPaths(\n config: TsConfigResolveConfig,\n moduleName: string,\n resolve: (moduleName: string) => Resolution | null\n): Resolution | null {\n // Exact matches contain no '*' wildcards, and can be 1:1 replacements\n const exactPaths = config.exactMatches[moduleName];\n if (exactPaths != null) {\n for (const alias of exactPaths) {\n const result = resolve(alias);\n if (result != null) {\n debug(`${moduleName} -> ${alias}`);\n return result;\n }\n }\n return null;\n }\n\n // Widlcard matches contain '*' and we first match the preceding string before it with a regex\n if (config.prefixRe != null) {\n const match = config.prefixRe.exec(moduleName);\n if (match != null) {\n const prefix = match[1]!;\n const rest = moduleName.slice(prefix.length);\n for (const entry of config.prefixMap[prefix]!) {\n let star = rest;\n if (entry.suffix) {\n // If we have a suffix (string after '*') it's checked separately\n // This is cheap, since most matches are complex path prefixes\n if (!rest.endsWith(entry.suffix)) continue;\n star = rest.slice(0, -entry.suffix.length);\n }\n for (const alias of entry.mapping) {\n const possibleResult = alias.replace('*', star);\n const result = resolve(possibleResult);\n if (result != null) {\n debug(`${moduleName} -> ${possibleResult}`);\n return result;\n }\n }\n break; // First matching suffix wins\n }\n\n // NOTE: Special case for `\"*\"` paths pattern (replacement for `baseUrl`)\n // If a non-catch-all prefix matched but failed, try the \"*\" catch-all\n // This could also apply to `*.[ext]` paths commonly though\n if (prefix !== '' && config.prefixMap[''] != null) {\n for (const entry of config.prefixMap['']) {\n let star = moduleName;\n if (entry.suffix) {\n if (!moduleName.endsWith(entry.suffix)) continue;\n star = moduleName.slice(0, -entry.suffix.length);\n }\n for (const alias of entry.mapping) {\n const possibleResult = alias.replace('*', star);\n const result = resolve(possibleResult);\n if (result != null) {\n debug(`${moduleName} -> ${possibleResult}`);\n return result;\n }\n }\n }\n }\n\n return null;\n }\n }\n\n // Only resolve against baseUrl if no `paths` groups were matched.\n // Base URL is resolved after paths, and before node_modules.\n // NOTE: In TypeScript 6 this is disabled unless `\"ignoreDeprecations\": \"6.0\"` is added\n // In TypeScript 7, this will be removed, and `paths['*']` is the replacement\n if (config.baseUrl != null) {\n const possibleResult = joinBaseUrl(config.baseUrl, moduleName);\n const result = resolve(possibleResult);\n if (result) {\n debug(`baseUrl: ${moduleName} -> ${possibleResult}`);\n return result;\n }\n }\n\n return null;\n}\n\nfunction getOptionalResolve(\n context: ResolutionContext,\n platform: string | null,\n getStrictResolver: StrictResolverFactory\n): (moduleName: string) => Resolution | null {\n const doResolve = getStrictResolver(context, platform);\n return function optionalResolve(moduleName: string): Resolution | null {\n try {\n return doResolve(moduleName);\n } catch (error) {\n // If the error is directly related to a resolver not being able to resolve a module, then\n // we can ignore the error and try the next resolver. Otherwise, we should throw the error.\n const isResolutionError =\n isFailedToResolveNameError(error) || isFailedToResolvePathError(error);\n if (!isResolutionError) {\n throw error;\n }\n }\n return null;\n };\n}\n\n/** Pre-processes TypeScript configuration for _resolveWithTsConfigPaths */\nexport function _toResolveConfig(\n tsconfig: ParsedTsConfig | null,\n projectRoot: string\n): TsConfigResolveConfig | null {\n if (!tsconfig || (!tsconfig.paths && tsconfig.baseUrl == null)) {\n return null;\n }\n\n // NOTE(@kitten): We previously had a bug that assumed that paths are relative to the `baseUrl` only\n // However, the `baseUrl` is optional and paths can be relative to the config path instead.\n const pathsBasePath = tsconfig.baseUrl ?? tsconfig.pathsBasePath ?? projectRoot;\n\n const paths = tsconfig.paths ?? {};\n const exactMatches: Record<string, string[]> = Object.create(null);\n const prefixMap: Record<string, SuffixEntry[]> = Object.create(null);\n const seenPrefixes: string[] = [];\n\n for (const key in paths) {\n if (!Array.isArray(paths[key])) {\n continue;\n }\n // Pre-join with baseUrl so the hot path avoids path.join entirely\n const mapping = paths[key]\n .filter((p) => typeof p === 'string' && !p.endsWith('.d.ts'))\n .map((p) => joinBaseUrl(pathsBasePath, p));\n if (mapping.length > 0) {\n const starIndex = key.indexOf('*');\n if (starIndex === -1) {\n exactMatches[key] = mapping;\n } else {\n const prefix = key.slice(0, starIndex);\n const suffix = key.slice(starIndex + 1);\n if (!prefixMap[prefix]) {\n prefixMap[prefix] = [];\n seenPrefixes.push(prefix);\n }\n prefixMap[prefix].push({ suffix, mapping });\n }\n }\n }\n\n // Match longest prefix first\n seenPrefixes.sort((a, b) => b.length - a.length);\n const prefixRe = seenPrefixes.length\n ? new RegExp(`^(${seenPrefixes.map(escapePrefix).join('|')})`)\n : null;\n\n return {\n exactMatches,\n prefixRe,\n prefixMap,\n baseUrl: tsconfig.baseUrl ?? null,\n configNormalPaths: tsconfig.configNormalPaths,\n };\n}\n\nconst TSCONFIG_NAME = 'tsconfig.json';\nconst JSCONFIG_NAME = 'jsconfig.json';\n\nfunction loadTsConfigPaths(projectRoot: string, depGraph: DependencyGraph): ParsedTsConfig | null {\n let configPath: string | null = null;\n if (depGraph.doesFileExist(TSCONFIG_NAME)) {\n configPath = path.join(projectRoot, TSCONFIG_NAME);\n } else if (depGraph.doesFileExist(JSCONFIG_NAME)) {\n configPath = path.join(projectRoot, JSCONFIG_NAME);\n }\n\n if (!configPath) {\n return null;\n }\n\n try {\n return _loadTsConfigWithExtends(projectRoot, configPath, depGraph);\n } catch (error: any) {\n if (error?.isJsonFileError || error?.name === 'SyntaxError') {\n debug(`Failed to parse ${configPath}: ${error.message}`);\n return null;\n }\n throw error;\n }\n}\n\n/** Loads a given tsconfig.json and parses it */\nexport function _loadTsConfigWithExtends(\n projectRoot: string,\n configPath: string,\n depGraph: DependencyGraph\n): ParsedTsConfig | null {\n const visited = new Set<string>();\n const rootConfigDir = path.dirname(configPath);\n\n function load(configPath: string | undefined): ParsedTsConfig | null {\n // NOTE: We avoid cycles here, which are theoretically possible\n // We avoid warning or throwing an error though, since TypeScript will complain about this anyway\n if (typeof configPath !== 'string' || visited.has(configPath)) {\n return null;\n } else {\n visited.add(configPath);\n }\n\n const configDir = path.dirname(configPath);\n const raw = JsonFile.read(configPath, { json5: true });\n const own = extractPathsFromCompilerOptions(raw);\n\n let baseUrl: string | undefined;\n let paths: Record<string, string[]> | undefined;\n let pathsBasePath: string | undefined;\n if (raw.extends) {\n const exts = !Array.isArray(raw.extends) ? [raw.extends] : raw.extends;\n for (const ext of exts) {\n if (typeof ext === 'string') {\n // Resolve the `extends` path with Node-like resolution, similar to TypeScript\n const extPath = resolveExtendsPath(ext, configDir, depGraph._fileSystem);\n const parent = load(extPath);\n if (parent) {\n baseUrl = parent.baseUrl ?? baseUrl;\n paths = parent.paths ?? paths;\n pathsBasePath = parent.pathsBasePath ?? pathsBasePath;\n }\n }\n }\n }\n\n // Outermost config values win, but can be combined\n // The `pathsBasePath` is the path of the config that `paths` are defined in\n // `paths` are not merged\n return {\n baseUrl: own.baseUrl ?? baseUrl,\n paths: own.paths ?? paths,\n pathsBasePath: own.paths != null ? configDir : pathsBasePath,\n };\n }\n\n const result = load(configPath);\n if (result != null) {\n const pathUtils = new RootPathUtils(projectRoot);\n const configPaths = new Set<string>();\n // Keep track of the configuration paths here for the file watcher\n for (const visitedConfigPath of visited) {\n configPaths.add(pathUtils.absoluteToNormal(visitedConfigPath));\n }\n result.configNormalPaths = configPaths;\n if (result.baseUrl != null) {\n result.baseUrl = path.resolve(\n rootConfigDir,\n substituteConfigDir(result.baseUrl, rootConfigDir)\n );\n }\n if (result.paths != null) {\n for (const key in result.paths) {\n const mapping = result.paths[key]!;\n for (let idx = 0; idx < mapping.length; idx++) {\n mapping[idx] = substituteConfigDir(mapping[idx]!, rootConfigDir);\n }\n }\n }\n }\n return result;\n}\n\n/** Normalize JSON's tsconfig compilerOptions */\nfunction extractPathsFromCompilerOptions(raw: Record<string, unknown>): {\n baseUrl?: string;\n paths?: Record<string, string[]>;\n} {\n if (raw.compilerOptions == null || typeof raw.compilerOptions !== 'object') {\n return {};\n }\n const opts = raw.compilerOptions as Record<string, unknown>;\n const baseUrl = typeof opts.baseUrl === 'string' ? opts.baseUrl : undefined;\n\n let paths: Record<string, string[]> | undefined;\n if (opts.paths != null && typeof opts.paths === 'object') {\n paths = {};\n for (const key in opts.paths as Record<string, unknown>) {\n const values = (opts.paths as Record<string, unknown>)[key];\n if (Array.isArray(values)) {\n paths[key] = values.filter((v): v is string => typeof v === 'string');\n }\n }\n }\n\n return { baseUrl, paths };\n}\n\n/** Lookup/resolve an `extends` path */\nfunction resolveExtendsPath(\n targetPath: string,\n configDir: string,\n fileSystem: FileSystem\n): string | undefined {\n let target = fileSystem.lookup(path.join(configDir, targetPath));\n if (target.exists && target.type === 'f') {\n return target.realPath;\n }\n\n if (!targetPath.endsWith('.json')) {\n target = fileSystem.lookup(path.join(configDir, targetPath + '.json'));\n if (target.exists && target.type === 'f') {\n return target.realPath;\n }\n }\n\n // Last attempt is Node-like resolution\n let lookup: null | undefined | { absolutePath: string; containerRelativePath: string };\n if (!targetPath.endsWith('.json')) {\n lookup = fileSystem.hierarchicalLookup(configDir, `node_modules/${targetPath}.json`, {\n subpathType: 'f',\n });\n if (lookup != null) {\n return lookup.absolutePath;\n }\n }\n if (lookup == null) {\n lookup = fileSystem.hierarchicalLookup(configDir, `node_modules/${targetPath}`, {\n subpathType: 'f',\n });\n }\n if (lookup == null && !targetPath.endsWith('.json')) {\n lookup = fileSystem.hierarchicalLookup(\n configDir,\n `node_modules/${targetPath}/${TSCONFIG_NAME}`,\n {\n subpathType: 'f',\n }\n );\n }\n\n // NOTE(@kitten): Some implementations opt to add `package.json:exports` and `package.json:tsconfig`\n // field support here, but it's unclear if this is even supported in TypeScript itself. It's likely\n // not used, as it's impossible to find an example of this anywhere\n\n return lookup?.absolutePath;\n}\n\n/** TypeScript's `${configDir}` template prefix for the user config's path */\nfunction substituteConfigDir(value: string, configDir: string): string {\n return value.startsWith('${configDir}')\n ? path.resolve(configDir, value.replace('${configDir}', './'))\n : value;\n}\n"],"names":["_loadTsConfigWithExtends","_resolveWithTsConfigPaths","_toResolveConfig","createTypescriptResolver","debug","require","projectRoot","getMetroBundler","getStrictResolver","watch","input","current","initialized","init","bundler","tsconfig","loadTsConfigPaths","_depGraph","setupTsConfigWatcher","fileSpecifierRe","nodeModulesPart","path","sep","requestTsconfigPaths","immutableContext","moduleName","platform","test","originModulePath","includes","getOptionalResolve","reload","watcher","getWatcher","addListener","changes","change","addedFiles","TSCONFIG_NAME","JSCONFIG_NAME","configNormalPaths","modifiedFiles","has","removedFiles","escapePrefix","str","replace","joinBaseUrl","baseUrl","lookup","resolve","config","exactPaths","exactMatches","alias","result","prefixRe","match","exec","prefix","rest","slice","length","entry","prefixMap","star","suffix","endsWith","mapping","possibleResult","context","doResolve","optionalResolve","error","isResolutionError","isFailedToResolveNameError","isFailedToResolvePathError","paths","pathsBasePath","Object","create","seenPrefixes","key","Array","isArray","filter","p","map","starIndex","indexOf","push","sort","a","b","RegExp","join","depGraph","configPath","doesFileExist","isJsonFileError","name","message","visited","Set","rootConfigDir","dirname","load","add","configDir","raw","JsonFile","read","json5","own","extractPathsFromCompilerOptions","extends","exts","ext","extPath","resolveExtendsPath","_fileSystem","parent","pathUtils","RootPathUtils","configPaths","visitedConfigPath","absoluteToNormal","substituteConfigDir","idx","compilerOptions","opts","undefined","values","v","targetPath","fileSystem","target","exists","type","realPath","hierarchicalLookup","subpathType","absolutePath","value","startsWith"],"mappings":"AAAA,8FAA8F;AAC9F,qDAAqD;AACrD,6FAA6F;AAC7F,uFAAuF;AACvF,oDAAoD;;;;;;;;;;;;QA4UpCA;eAAAA;;QA9LAC;eAAAA;;QA2GAC;eAAAA;;QAtMAC;eAAAA;;;;gEAjDK;;;;;;;yBAKS;;;;;;;gEAEb;;;;;;6BAEsD;;;;;;AAIvE,MAAMC,QAAQC,QAAQ,SAAS;AAoCxB,SAASF,yBAAyB,EACvCG,WAAW,EACXC,eAAe,EACfC,iBAAiB,EACjBC,KAAK,EAMN;IACC,MAAMC,QAAiC;QAAEC,SAAS;IAAK;IACvD,IAAIC,cAAc;IAElB,SAASC;QACPD,cAAc;QACd,MAAME,UAAUP;QAChB,MAAMQ,WAAWC,kBAAkBV,aAAaQ,QAAQG,SAAS;QACjEP,MAAMC,OAAO,GAAGT,iBAAiBa,UAAUT;QAC3C,IAAIG,OAAO;YACTS,qBAAqBR,OAAOI,SAASR;QACvC;IACF;IAEA,MAAMa,kBAAkB;IACxB,MAAMC,kBAAkB,GAAGC,eAAI,CAACC,GAAG,CAAC,YAAY,EA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AAC6B,OAAO,CAAC0D,WAAWmC,MAAMjG,OAAO,CAAC,gBAAgB,SACtDiG;AACN"}
|
|
@@ -30,7 +30,7 @@ const _isLocalHostname = (hostname)=>{
|
|
|
30
30
|
}
|
|
31
31
|
if (maybeIp === '::1') {
|
|
32
32
|
return true;
|
|
33
|
-
} else if (/^127(
|
|
33
|
+
} else if (/^127(?:\.\d+){3}$/.test(maybeIp)) {
|
|
34
34
|
return maybeIp.split('.').every((part)=>{
|
|
35
35
|
const num = parseInt(part, 10);
|
|
36
36
|
return num >= 0 && num <= 255;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/middleware/CorsMiddleware.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config';\n\nimport type { ServerRequest, ServerResponse } from './server.types';\n\nconst DEFAULT_ALLOWED_CORS_HOSTS = [\n 'devtools', // Support local Chrome DevTools `devtools://devtools`\n];\n\n/** Check if hostname matches \"localhost\" exactly, the local IPv6,\n * a local IPV4 in the 127.0.0.0/8 range, or an IPv6-to-4 range\n * (starting with ::ffff: and ending in an IPv4) */\nexport const _isLocalHostname = (hostname: string) => {\n if (hostname === 'localhost') {\n return true;\n }\n let maybeIp = hostname;\n const ipv6To4Prefix = '::ffff:';\n if (maybeIp.startsWith(ipv6To4Prefix)) {\n maybeIp = maybeIp.slice(ipv6To4Prefix.length);\n }\n if (maybeIp === '::1') {\n return true;\n } else if (/^127(
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/CorsMiddleware.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config';\n\nimport type { ServerRequest, ServerResponse } from './server.types';\n\nconst DEFAULT_ALLOWED_CORS_HOSTS = [\n 'devtools', // Support local Chrome DevTools `devtools://devtools`\n];\n\n/** Check if hostname matches \"localhost\" exactly, the local IPv6,\n * a local IPV4 in the 127.0.0.0/8 range, or an IPv6-to-4 range\n * (starting with ::ffff: and ending in an IPv4) */\nexport const _isLocalHostname = (hostname: string) => {\n if (hostname === 'localhost') {\n return true;\n }\n let maybeIp = hostname;\n const ipv6To4Prefix = '::ffff:';\n if (maybeIp.startsWith(ipv6To4Prefix)) {\n maybeIp = maybeIp.slice(ipv6To4Prefix.length);\n }\n if (maybeIp === '::1') {\n return true;\n } else if (/^127(?:\\.\\d+){3}$/.test(maybeIp)) {\n return maybeIp.split('.').every((part) => {\n const num = parseInt(part, 10);\n return num >= 0 && num <= 255;\n });\n } else {\n return false;\n }\n};\n\nexport function createCorsMiddleware(exp: ExpoConfig) {\n const allowedHosts = [...DEFAULT_ALLOWED_CORS_HOSTS];\n // Support for expo-router API routes\n if (exp.extra?.router?.headOrigin) {\n allowedHosts.push(new URL(exp.extra.router.headOrigin).host);\n }\n if (exp.extra?.router?.origin) {\n allowedHosts.push(new URL(exp.extra.router.origin).host);\n }\n\n return (req: ServerRequest, res: ServerResponse, next: (err?: Error) => void) => {\n if (typeof req.headers.origin === 'string') {\n const { host, hostname } = new URL(req.headers.origin);\n const isSameOrigin = host === req.headers.host;\n const isLocalhost = _isLocalHostname(hostname);\n const isAllowedHost = allowedHosts.includes(host) || isLocalhost;\n if (!isSameOrigin && !isAllowedHost) {\n next(\n new Error(\n `Unauthorized request from ${req.headers.origin}. ` +\n 'This may happen because of a conflicting browser extension to intercept HTTP requests. ' +\n 'Disable browser extensions or use incognito mode and try again.'\n )\n );\n return;\n } else if (!isLocalhost && isAllowedHost) {\n // Skipped for localhost to only allow requests from this dev-sever and not escalate\n // the cross-origin resource sharing that's allowed beyond the browser's defaults\n res.setHeader('Access-Control-Allow-Origin', req.headers.origin);\n }\n\n maybePreventMetroResetCorsHeader(req, res);\n }\n\n // Block MIME-type sniffing.\n res.setHeader('X-Content-Type-Options', 'nosniff');\n\n next();\n };\n}\n\n// When accessing source maps,\n// metro will overwrite the `Access-Control-Allow-Origin` header with hardcoded `devtools://devtools` value.\n// https://github.com/facebook/metro/blob/a7f8955e6d2424b0d5f73d4bcdaf22560e1d5f27/packages/metro/src/Server.js#L540\n// This is a workaround to prevent this behavior.\nfunction maybePreventMetroResetCorsHeader(req: ServerRequest, res: ServerResponse) {\n const pathname = req.url ? new URL(req.url, `http://${req.headers.host}`).pathname : '';\n if (pathname.endsWith('.map')) {\n const setHeader = res.setHeader.bind(res);\n res.setHeader = (key, ...args) => {\n if (key !== 'Access-Control-Allow-Origin') {\n setHeader(key, ...args);\n }\n return res;\n };\n }\n}\n"],"names":["_isLocalHostname","createCorsMiddleware","DEFAULT_ALLOWED_CORS_HOSTS","hostname","maybeIp","ipv6To4Prefix","startsWith","slice","length","test","split","every","part","num","parseInt","exp","allowedHosts","extra","router","headOrigin","push","URL","host","origin","req","res","next","headers","isSameOrigin","isLocalhost","isAllowedHost","includes","Error","setHeader","maybePreventMetroResetCorsHeader","pathname","url","endsWith","bind","key","args"],"mappings":";;;;;;;;;;;QAWaA;eAAAA;;QAqBGC;eAAAA;;;AA5BhB,MAAMC,6BAA6B;IACjC;CACD;AAKM,MAAMF,mBAAmB,CAACG;IAC/B,IAAIA,aAAa,aAAa;QAC5B,OAAO;IACT;IACA,IAAIC,UAAUD;IACd,MAAME,gBAAgB;IACtB,IAAID,QAAQE,UAAU,CAACD,gBAAgB;QACrCD,UAAUA,QAAQG,KAAK,CAACF,cAAcG,MAAM;IAC9C;IACA,IAAIJ,YAAY,OAAO;QACrB,OAAO;IACT,OAAO,IAAI,oBAAoBK,IAAI,CAACL,UAAU;QAC5C,OAAOA,QAAQM,KAAK,CAAC,KAAKC,KAAK,CAAC,CAACC;YAC/B,MAAMC,MAAMC,SAASF,MAAM;YAC3B,OAAOC,OAAO,KAAKA,OAAO;QAC5B;IACF,OAAO;QACL,OAAO;IACT;AACF;AAEO,SAASZ,qBAAqBc,GAAe;QAG9CA,mBAAAA,YAGAA,oBAAAA;IALJ,MAAMC,eAAe;WAAId;KAA2B;IACpD,qCAAqC;IACrC,KAAIa,aAAAA,IAAIE,KAAK,sBAATF,oBAAAA,WAAWG,MAAM,qBAAjBH,kBAAmB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IAAI,EAAE,EAAEa,QAAQ,GAAG;IACrF,IAAIA,SAASE,QAAQ,CAAC,SAAS;QAC7B,MAAMJ,YAAYR,IAAIQ,SAAS,CAACK,IAAI,CAACb;QACrCA,IAAIQ,SAAS,GAAG,CAACM,KAAK,GAAGC;YACvB,IAAID,QAAQ,+BAA+B;gBACzCN,UAAUM,QAAQC;YACpB;YACA,OAAOf;QACT;IACF;AACF"}
|
package/build/src/utils/obj.js
CHANGED
|
@@ -36,6 +36,9 @@ function set(obj, key, value) {
|
|
|
36
36
|
let current = obj;
|
|
37
37
|
let branch;
|
|
38
38
|
while(branch = branches.shift()){
|
|
39
|
+
if (branch === '__proto__' || branch === 'constructor' || branch === 'prototype') {
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
39
42
|
if (branches.length === 0) {
|
|
40
43
|
current[branch] = value;
|
|
41
44
|
return obj;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/obj.ts"],"sourcesContent":["/** `lodash.get` */\nexport function get(obj: any, key: string): any | null {\n const branches = key.split('.');\n let current: any = obj;\n let branch: string | undefined;\n while ((branch = branches.shift())) {\n if (!(branch in current)) {\n return null;\n }\n current = current[branch];\n }\n return current;\n}\n\n/** `lodash.set` */\nexport function set(obj: any, key: string, value: any): any | null {\n const branches = key.split('.');\n let current: any = obj;\n let branch: string | undefined;\n while ((branch = branches.shift())) {\n if (branches.length === 0) {\n current[branch] = value;\n return obj;\n }\n\n if (!(branch in current)) {\n current[branch] = {};\n }\n\n current = current[branch];\n }\n return null;\n}\n\n/** `lodash.pickBy` */\nexport function pickBy<T>(\n obj: { [key: string]: T },\n predicate: (value: T, key: string) => boolean | undefined\n) {\n return Object.entries(obj).reduce(\n (acc, [key, value]) => {\n if (predicate(value, key)) {\n acc[key] = value;\n }\n return acc;\n },\n {} as { [key: string]: T }\n );\n}\n"],"names":["get","pickBy","set","obj","key","branches","split","current","branch","shift","value","length","predicate","Object","entries","reduce","acc"],"mappings":"AAAA,iBAAiB;;;;;;;;;;;QACDA;eAAAA;;
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/obj.ts"],"sourcesContent":["/** `lodash.get` */\nexport function get(obj: any, key: string): any | null {\n const branches = key.split('.');\n let current: any = obj;\n let branch: string | undefined;\n while ((branch = branches.shift())) {\n if (!(branch in current)) {\n return null;\n }\n current = current[branch];\n }\n return current;\n}\n\n/** `lodash.set` */\nexport function set(obj: any, key: string, value: any): any | null {\n const branches = key.split('.');\n let current: any = obj;\n let branch: string | undefined;\n while ((branch = branches.shift())) {\n if (branch === '__proto__' || branch === 'constructor' || branch === 'prototype') {\n return obj;\n }\n\n if (branches.length === 0) {\n current[branch] = value;\n return obj;\n }\n\n if (!(branch in current)) {\n current[branch] = {};\n }\n\n current = current[branch];\n }\n return null;\n}\n\n/** `lodash.pickBy` */\nexport function pickBy<T>(\n obj: { [key: string]: T },\n predicate: (value: T, key: string) => boolean | undefined\n) {\n return Object.entries(obj).reduce(\n (acc, [key, value]) => {\n if (predicate(value, key)) {\n acc[key] = value;\n }\n return acc;\n },\n {} as { [key: string]: T }\n );\n}\n"],"names":["get","pickBy","set","obj","key","branches","split","current","branch","shift","value","length","predicate","Object","entries","reduce","acc"],"mappings":"AAAA,iBAAiB;;;;;;;;;;;QACDA;eAAAA;;QAsCAC;eAAAA;;QAxBAC;eAAAA;;;AAdT,SAASF,IAAIG,GAAQ,EAAEC,GAAW;IACvC,MAAMC,WAAWD,IAAIE,KAAK,CAAC;IAC3B,IAAIC,UAAeJ;IACnB,IAAIK;IACJ,MAAQA,SAASH,SAASI,KAAK,GAAK;QAClC,IAAI,CAAED,CAAAA,UAAUD,OAAM,GAAI;YACxB,OAAO;QACT;QACAA,UAAUA,OAAO,CAACC,OAAO;IAC3B;IACA,OAAOD;AACT;AAGO,SAASL,IAAIC,GAAQ,EAAEC,GAAW,EAAEM,KAAU;IACnD,MAAML,WAAWD,IAAIE,KAAK,CAAC;IAC3B,IAAIC,UAAeJ;IACnB,IAAIK;IACJ,MAAQA,SAASH,SAASI,KAAK,GAAK;QAClC,IAAID,WAAW,eAAeA,WAAW,iBAAiBA,WAAW,aAAa;YAChF,OAAOL;QACT;QAEA,IAAIE,SAASM,MAAM,KAAK,GAAG;YACzBJ,OAAO,CAACC,OAAO,GAAGE;YAClB,OAAOP;QACT;QAEA,IAAI,CAAEK,CAAAA,UAAUD,OAAM,GAAI;YACxBA,OAAO,CAACC,OAAO,GAAG,CAAC;QACrB;QAEAD,UAAUA,OAAO,CAACC,OAAO;IAC3B;IACA,OAAO;AACT;AAGO,SAASP,OACdE,GAAyB,EACzBS,SAAyD;IAEzD,OAAOC,OAAOC,OAAO,CAACX,KAAKY,MAAM,CAC/B,CAACC,KAAK,CAACZ,KAAKM,MAAM;QAChB,IAAIE,UAAUF,OAAON,MAAM;YACzBY,GAAG,CAACZ,IAAI,GAAGM;QACb;QACA,OAAOM;IACT,GACA,CAAC;AAEL"}
|
|
@@ -26,7 +26,7 @@ class FetchClient {
|
|
|
26
26
|
this.headers = {
|
|
27
27
|
accept: 'application/json',
|
|
28
28
|
'content-type': 'application/json',
|
|
29
|
-
'user-agent': `expo-cli/${"57.0.
|
|
29
|
+
'user-agent': `expo-cli/${"57.0.29"}`,
|
|
30
30
|
authorization: 'Basic ' + _nodebuffer().Buffer.from(`${target}:`).toString('base64')
|
|
31
31
|
};
|
|
32
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/cli",
|
|
3
|
-
"version": "57.0.
|
|
3
|
+
"version": "57.0.29",
|
|
4
4
|
"description": "The Expo CLI",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"bin": {
|
|
@@ -38,23 +38,23 @@
|
|
|
38
38
|
"homepage": "https://github.com/expo/expo/tree/main/packages/@expo/cli",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@expo/code-signing-certificates": "^0.0.6",
|
|
41
|
-
"@expo/config": "~57.0.
|
|
42
|
-
"@expo/config-plugins": "~57.0.
|
|
41
|
+
"@expo/config": "~57.0.10",
|
|
42
|
+
"@expo/config-plugins": "~57.0.10",
|
|
43
43
|
"@expo/devcert": "^1.2.1",
|
|
44
44
|
"@expo/env": "~2.4.3",
|
|
45
|
-
"@expo/image-utils": "^0.11.
|
|
46
|
-
"@expo/inline-modules": "^0.1.
|
|
45
|
+
"@expo/image-utils": "^0.11.6",
|
|
46
|
+
"@expo/inline-modules": "^0.1.8",
|
|
47
47
|
"@expo/json-file": "^11.0.1",
|
|
48
48
|
"@expo/log-box": "^57.0.4",
|
|
49
49
|
"@expo/metro": "~56.0.2",
|
|
50
|
-
"@expo/metro-config": "~57.0.
|
|
51
|
-
"@expo/metro-file-map": "^57.0.
|
|
50
|
+
"@expo/metro-config": "~57.0.13",
|
|
51
|
+
"@expo/metro-file-map": "^57.0.4",
|
|
52
52
|
"@expo/osascript": "^2.7.1",
|
|
53
53
|
"@expo/package-manager": "^1.13.1",
|
|
54
54
|
"@expo/plist": "^0.8.1",
|
|
55
|
-
"@expo/prebuild-config": "^57.0.
|
|
56
|
-
"@expo/require-utils": "^57.0.
|
|
57
|
-
"@expo/router-server": "^57.0.
|
|
55
|
+
"@expo/prebuild-config": "^57.0.18",
|
|
56
|
+
"@expo/require-utils": "^57.0.6",
|
|
57
|
+
"@expo/router-server": "^57.0.12",
|
|
58
58
|
"@expo/schema-utils": "^57.0.2",
|
|
59
59
|
"@expo/spawn-async": "^1.8.0",
|
|
60
60
|
"@expo/ws-tunnel": "^2.0.0",
|
|
@@ -157,13 +157,13 @@
|
|
|
157
157
|
"playwright": "^1.59.0",
|
|
158
158
|
"taskr": "^1.1.0",
|
|
159
159
|
"tree-kill": "^1.2.2",
|
|
160
|
-
"@expo/fingerprint": "0.20.
|
|
161
|
-
"expo": "57.0.
|
|
160
|
+
"@expo/fingerprint": "0.20.14",
|
|
161
|
+
"expo": "57.0.28",
|
|
162
162
|
"expo-module-scripts": "56.0.3",
|
|
163
|
-
"expo-
|
|
164
|
-
"expo-
|
|
163
|
+
"expo-modules-autolinking": "57.0.15",
|
|
164
|
+
"expo-router": "57.0.26"
|
|
165
165
|
},
|
|
166
|
-
"gitHead": "
|
|
166
|
+
"gitHead": "58da4edafcb043872c3ed9bf8f5957e6544d0a9c",
|
|
167
167
|
"scripts": {
|
|
168
168
|
"build": "taskr",
|
|
169
169
|
"clean": "expo-module clean",
|