@expo/cli 0.14.0 → 0.15.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.
Files changed (161) hide show
  1. package/build/bin/cli +5 -4
  2. package/build/bin/cli.map +1 -1
  3. package/build/src/api/getVersions.js.map +1 -1
  4. package/build/src/api/rest/cache/response.js.map +1 -1
  5. package/build/src/api/rest/client.js +2 -2
  6. package/build/src/api/rest/client.js.map +1 -1
  7. package/build/src/customize/typescript.js +3 -1
  8. package/build/src/customize/typescript.js.map +1 -1
  9. package/build/src/export/createMetadataJson.js +3 -2
  10. package/build/src/export/createMetadataJson.js.map +1 -1
  11. package/build/src/export/embed/exportEmbedAsync.js +44 -17
  12. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  13. package/build/src/export/embed/resolveOptions.js +3 -3
  14. package/build/src/export/embed/resolveOptions.js.map +1 -1
  15. package/build/src/export/exportApp.js +69 -80
  16. package/build/src/export/exportApp.js.map +1 -1
  17. package/build/src/export/exportAssets.js +81 -21
  18. package/build/src/export/exportAssets.js.map +1 -1
  19. package/build/src/export/exportHermes.js +4 -4
  20. package/build/src/export/exportHermes.js.map +1 -1
  21. package/build/src/export/exportStaticAsync.js +55 -20
  22. package/build/src/export/exportStaticAsync.js.map +1 -1
  23. package/build/src/export/favicon.js +2 -2
  24. package/build/src/export/favicon.js.map +1 -1
  25. package/build/src/export/fork-bundleAsync.js +12 -10
  26. package/build/src/export/fork-bundleAsync.js.map +1 -1
  27. package/build/src/export/index.js +9 -7
  28. package/build/src/export/index.js.map +1 -1
  29. package/build/src/export/metroAssetLocalPath.js +101 -0
  30. package/build/src/export/metroAssetLocalPath.js.map +1 -0
  31. package/build/src/export/persistMetroAssets.js +94 -21
  32. package/build/src/export/persistMetroAssets.js.map +1 -1
  33. package/build/src/export/resolveOptions.js +1 -1
  34. package/build/src/export/resolveOptions.js.map +1 -1
  35. package/build/src/export/saveAssets.js +9 -48
  36. package/build/src/export/saveAssets.js.map +1 -1
  37. package/build/src/export/web/exportWebAsync.js +1 -1
  38. package/build/src/export/web/exportWebAsync.js.map +1 -1
  39. package/build/src/export/writeContents.js +3 -2
  40. package/build/src/export/writeContents.js.map +1 -1
  41. package/build/src/install/applyPlugins.js +52 -0
  42. package/build/src/install/applyPlugins.js.map +1 -0
  43. package/build/src/install/checkPackages.js +2 -2
  44. package/build/src/install/checkPackages.js.map +1 -1
  45. package/build/src/install/fixPackages.js +84 -0
  46. package/build/src/install/fixPackages.js.map +1 -0
  47. package/build/src/install/installAsync.js +32 -61
  48. package/build/src/install/installAsync.js.map +1 -1
  49. package/build/src/install/installExpoPackage.js +79 -0
  50. package/build/src/install/installExpoPackage.js.map +1 -0
  51. package/build/src/prebuild/clearNativeFolder.js +1 -1
  52. package/build/src/prebuild/clearNativeFolder.js.map +1 -1
  53. package/build/src/prebuild/configureProjectAsync.js +3 -3
  54. package/build/src/prebuild/configureProjectAsync.js.map +1 -1
  55. package/build/src/prebuild/copyTemplateFiles.js +21 -30
  56. package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
  57. package/build/src/prebuild/prebuildAsync.js +37 -15
  58. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  59. package/build/src/prebuild/resolveOptions.js +2 -2
  60. package/build/src/prebuild/resolveOptions.js.map +1 -1
  61. package/build/src/prebuild/updateFromTemplate.js +6 -6
  62. package/build/src/prebuild/updateFromTemplate.js.map +1 -1
  63. package/build/src/prebuild/updatePackageJson.js +49 -36
  64. package/build/src/prebuild/updatePackageJson.js.map +1 -1
  65. package/build/src/prebuild/validateTemplatePlatforms.js +2 -2
  66. package/build/src/prebuild/validateTemplatePlatforms.js.map +1 -1
  67. package/build/src/start/doctor/dependencies/getVersionedPackages.js +12 -4
  68. package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
  69. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +20 -3
  70. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  71. package/build/src/start/interface/interactiveActions.js +30 -11
  72. package/build/src/start/interface/interactiveActions.js.map +1 -1
  73. package/build/src/start/server/BundlerDevServer.js +14 -10
  74. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  75. package/build/src/start/server/DevServerManager.js +6 -1
  76. package/build/src/start/server/DevServerManager.js.map +1 -1
  77. package/build/src/start/server/DevToolsPluginManager.js +63 -0
  78. package/build/src/start/server/DevToolsPluginManager.js.map +1 -0
  79. package/build/src/start/server/getStaticRenderFunctions.js +21 -23
  80. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  81. package/build/src/start/server/metro/MetroBundlerDevServer.js +48 -64
  82. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  83. package/build/src/start/server/metro/bundleApiRoutes.js +4 -3
  84. package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
  85. package/build/src/start/server/metro/createExpoMetroResolver.js +62 -45
  86. package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -1
  87. package/build/src/start/server/metro/createJResolver.js +149 -0
  88. package/build/src/start/server/metro/createJResolver.js.map +1 -0
  89. package/build/src/start/server/metro/createServerRouteMiddleware.js +13 -1
  90. package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
  91. package/build/src/start/server/metro/externals.js +25 -3
  92. package/build/src/start/server/metro/externals.js.map +1 -1
  93. package/build/src/start/server/metro/inspector-proxy/device.js +3 -1
  94. package/build/src/start/server/metro/inspector-proxy/device.js.map +1 -1
  95. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js +3 -4
  96. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js.map +1 -1
  97. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeCallFunctionOn.js +24 -0
  98. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeCallFunctionOn.js.map +1 -0
  99. package/build/src/start/server/metro/inspector-proxy/handlers/utils.js +11 -0
  100. package/build/src/start/server/metro/inspector-proxy/handlers/utils.js.map +1 -0
  101. package/build/src/start/server/metro/inspector-proxy/index.js +10 -7
  102. package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
  103. package/build/src/start/server/metro/instantiateMetro.js +32 -10
  104. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  105. package/build/src/start/server/metro/metroErrorInterface.js +1 -1
  106. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  107. package/build/src/start/server/metro/router.js +4 -1
  108. package/build/src/start/server/metro/router.js.map +1 -1
  109. package/build/src/start/server/metro/runServer-fork.js +19 -10
  110. package/build/src/start/server/metro/runServer-fork.js.map +1 -1
  111. package/build/src/start/server/metro/serializeHtml.js +43 -0
  112. package/build/src/start/server/metro/serializeHtml.js.map +1 -0
  113. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +1 -2
  114. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -1
  115. package/build/src/start/server/metro/withMetroMultiPlatform.js +261 -201
  116. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  117. package/build/src/start/server/metro/withMetroResolvers.js +114 -40
  118. package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
  119. package/build/src/start/server/middleware/DevToolsPluginMiddleware.js +61 -0
  120. package/build/src/start/server/middleware/DevToolsPluginMiddleware.js.map +1 -0
  121. package/build/src/start/server/middleware/ExpoMiddleware.js +2 -2
  122. package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
  123. package/build/src/start/server/middleware/ManifestMiddleware.js +15 -66
  124. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  125. package/build/src/start/server/middleware/inspector/JsInspector.js +1 -1
  126. package/build/src/start/server/middleware/inspector/JsInspector.js.map +1 -1
  127. package/build/src/start/server/middleware/inspector/LaunchBrowser.js +30 -26
  128. package/build/src/start/server/middleware/inspector/LaunchBrowser.js.map +1 -1
  129. package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js +7 -7
  130. package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js.map +1 -1
  131. package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js +5 -2
  132. package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js.map +1 -1
  133. package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js +3 -2
  134. package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js.map +1 -1
  135. package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js +8 -7
  136. package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js.map +1 -1
  137. package/build/src/start/server/middleware/metroOptions.js +123 -0
  138. package/build/src/start/server/middleware/metroOptions.js.map +1 -0
  139. package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js.map +1 -1
  140. package/build/src/utils/analytics/getMetroDebugProperties.js +1 -2
  141. package/build/src/utils/analytics/getMetroDebugProperties.js.map +1 -1
  142. package/build/src/utils/analytics/getMetroProperties.js +1 -2
  143. package/build/src/utils/analytics/getMetroProperties.js.map +1 -1
  144. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  145. package/build/src/utils/args.js +4 -2
  146. package/build/src/utils/args.js.map +1 -1
  147. package/build/src/utils/cocoapods.js +1 -1
  148. package/build/src/utils/cocoapods.js.map +1 -1
  149. package/build/src/utils/dir.js +18 -8
  150. package/build/src/utils/dir.js.map +1 -1
  151. package/build/src/utils/env.js +3 -0
  152. package/build/src/utils/env.js.map +1 -1
  153. package/build/src/utils/getOrPromptApplicationId.js +2 -4
  154. package/build/src/utils/getOrPromptApplicationId.js.map +1 -1
  155. package/build/src/utils/prompts.js +1 -28
  156. package/build/src/utils/prompts.js.map +1 -1
  157. package/package.json +15 -14
  158. package/static/shims/react-native-web/dist/cjs/exports/AppRegistry/AppContainer.js +13 -0
  159. package/static/shims/react-native-web/dist/exports/AppRegistry/AppContainer.js +12 -0
  160. package/build/src/start/server/metro/resolveFromProject.js +0 -90
  161. package/build/src/start/server/metro/resolveFromProject.js.map +0 -1
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.createFastResolver = createFastResolver;
6
6
  var _path = _interopRequireDefault(require("path"));
7
- var _resolve = _interopRequireDefault(require("resolve"));
7
+ var _createJResolver = _interopRequireDefault(require("./createJResolver"));
8
8
  var _externals = require("./externals");
9
9
  var _formatFileCandidates = require("./formatFileCandidates");
10
- var _errors = require("../../../utils/errors");
11
10
  function _interopRequireDefault(obj) {
12
11
  return obj && obj.__esModule ? obj : {
13
12
  default: obj
@@ -17,7 +16,7 @@ class FailedToResolvePathError extends Error {
17
16
  }
18
17
  class ShimModuleError extends Error {
19
18
  }
20
- function createFastResolver({ preserveSymlinks }) {
19
+ function createFastResolver({ preserveSymlinks , blockList }) {
21
20
  const cachedExtensions = new Map();
22
21
  function getAdjustedExtensions({ metroSourceExtensions , platform , isNative }) {
23
22
  const key = JSON.stringify({
@@ -49,12 +48,6 @@ function createFastResolver({ preserveSymlinks }) {
49
48
  }
50
49
  function fastResolve(context, moduleName, platform) {
51
50
  var ref2;
52
- // TODO: Support extraNodeModules for tsconfig basePath support
53
- // TODO: Support package exports import { resolve as resolveExports } from 'resolve.exports'
54
- // TODO: Support `resolver.blockList`
55
- if (context.unstable_enablePackageExports) {
56
- throw new _errors.CommandError("package exports are not supported with EXPO_USE_FAST_RESOLVER=1");
57
- }
58
51
  const environment = (ref2 = context.customResolverOptions) == null ? void 0 : ref2.environment;
59
52
  const isServer = environment === "node";
60
53
  const extensions = getAdjustedExtensions({
@@ -64,18 +57,23 @@ function createFastResolver({ preserveSymlinks }) {
64
57
  });
65
58
  let fp;
66
59
  try {
67
- fp = _resolve.default.sync(moduleName, {
60
+ var _platform;
61
+ const conditions = context.unstable_enablePackageExports ? [
62
+ ...new Set([
63
+ "default",
64
+ ...context.unstable_conditionNames,
65
+ ...platform != null ? (_platform = context.unstable_conditionsByPlatform[platform]) != null ? _platform : [] : [],
66
+ ]),
67
+ ] : [];
68
+ fp = (0, _createJResolver).default(moduleName, {
69
+ blockList,
70
+ enablePackageExports: context.unstable_enablePackageExports,
68
71
  basedir: _path.default.dirname(context.originModulePath),
72
+ paths: context.nodeModulesPaths,
69
73
  extensions,
70
- // Used to ensure files trace to packages instead of node_modules in expo/expo. This is how Metro works and
71
- // the app doesn't finish without it.
72
- preserveSymlinks,
73
- readPackageSync (readFileSync, pkgFile) {
74
- var ref;
75
- return (ref = context.getPackage(pkgFile)) != null ? ref : JSON.parse(// @ts-expect-error
76
- readFileSync(pkgfile));
77
- },
78
- moduleDirectory: context.nodeModulesPaths,
74
+ conditions,
75
+ // @ts-ignore
76
+ realpathSync: context.unstable_getRealPath,
79
77
  packageFilter (pkg) {
80
78
  // set the pkg.main to the first available field in context.mainFields
81
79
  for (const field of context.mainFields){
@@ -89,7 +87,17 @@ function createFastResolver({ preserveSymlinks }) {
89
87
  }
90
88
  return pkg;
91
89
  },
92
- pathFilter: isServer ? undefined : (pkg, _resolvedPath, relativePathIn)=>{
90
+ // Used to ensure files trace to packages instead of node_modules in expo/expo. This is how Metro works and
91
+ // the app doesn't finish without it.
92
+ preserveSymlinks,
93
+ readPackageSync (readFileSync, pkgFile) {
94
+ var ref;
95
+ return (ref = context.getPackage(pkgFile)) != null ? ref : JSON.parse(// @ts-expect-error
96
+ readFileSync(pkgfile));
97
+ },
98
+ includeCoreModules: isServer,
99
+ pathFilter: // Disable `browser` field for server environments.
100
+ isServer ? undefined : (pkg, _resolvedPath, relativePathIn)=>{
93
101
  let relativePath = relativePathIn;
94
102
  if (relativePath[0] !== ".") {
95
103
  relativePath = `./${relativePath}`;
@@ -106,17 +114,8 @@ function createFastResolver({ preserveSymlinks }) {
106
114
  throw new ShimModuleError();
107
115
  }
108
116
  return mappedPath;
109
- },
110
- // Not needed but added for parity...
111
- // @ts-ignore
112
- realpathSync: context.unstable_getRealPath
117
+ }
113
118
  });
114
- if (!isServer && (0, _externals).isNodeExternal(fp)) {
115
- // In this case, mock the file to use an empty module.
116
- return {
117
- type: "empty"
118
- };
119
- }
120
119
  } catch (error) {
121
120
  if (error instanceof ShimModuleError) {
122
121
  return {
@@ -124,6 +123,12 @@ function createFastResolver({ preserveSymlinks }) {
124
123
  };
125
124
  }
126
125
  if ("code" in error && error.code === "MODULE_NOT_FOUND") {
126
+ if ((0, _externals).isNodeExternal(moduleName)) {
127
+ // In this case, mock the file to use an empty module.
128
+ return {
129
+ type: "empty"
130
+ };
131
+ }
127
132
  // TODO: Add improved error handling.
128
133
  throw new FailedToResolvePathError("The module could not be resolved because no file or module matched the pattern:\n" + ` ${(0, _formatFileCandidates).formatFileCandidates({
129
134
  type: "sourceFile",
@@ -139,30 +144,42 @@ function createFastResolver({ preserveSymlinks }) {
139
144
  type: "sourceFile",
140
145
  filePath: fp
141
146
  };
142
- } else {
143
- // NOTE: platform extensions may not be supported on assets.
144
- if (platform === "web") {
145
- // Skip multi-resolution on web/server bundles. Only consideration here is that
146
- // we may still need it in case the only image is a multi-resolution image.
147
+ }
148
+ if ((0, _externals).isNodeExternal(fp)) {
149
+ if (isServer) {
147
150
  return {
148
- type: "assetFiles",
149
- filePaths: [
150
- fp
151
- ]
151
+ type: "sourceFile",
152
+ filePath: fp
152
153
  };
153
154
  }
154
- const dirPath = _path.default.dirname(fp);
155
- const extension = _path.default.extname(fp);
156
- const basename = _path.default.basename(fp, extension);
157
- var ref1;
155
+ // NOTE: This shouldn't happen, the module should throw.
156
+ // Mock non-server built-in modules to empty.
157
+ return {
158
+ type: "empty"
159
+ };
160
+ }
161
+ // NOTE: platform extensions may not be supported on assets.
162
+ if (platform === "web") {
163
+ // Skip multi-resolution on web/server bundles. Only consideration here is that
164
+ // we may still need it in case the only image is a multi-resolution image.
158
165
  return {
159
166
  type: "assetFiles",
160
- // Support multi-resolution asset extensions...
161
- filePaths: (ref1 = context.resolveAsset(dirPath, basename, extension)) != null ? ref1 : [
167
+ filePaths: [
162
168
  fp
163
169
  ]
164
170
  };
165
171
  }
172
+ const dirPath = _path.default.dirname(fp);
173
+ const extension = _path.default.extname(fp);
174
+ const basename = _path.default.basename(fp, extension);
175
+ var ref1;
176
+ return {
177
+ type: "assetFiles",
178
+ // Support multi-resolution asset extensions...
179
+ filePaths: (ref1 = context.resolveAsset(dirPath, basename, extension)) != null ? ref1 : [
180
+ fp
181
+ ]
182
+ };
166
183
  }
167
184
  return fastResolve;
168
185
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/createExpoMetroResolver.ts"],"sourcesContent":["/**\n * Copyright © 2023 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 { Resolution, ResolutionContext } from 'metro-resolver';\nimport path from 'path';\nimport nodeResolve from 'resolve';\n\nimport { isNodeExternal } from './externals';\nimport { formatFileCandidates } from './formatFileCandidates';\nimport { CommandError } from '../../../utils/errors';\n\nclass FailedToResolvePathError extends Error {}\n\nclass ShimModuleError extends Error {}\n\nexport function createFastResolver({ preserveSymlinks }: { preserveSymlinks: boolean }) {\n const cachedExtensions: Map<string, readonly string[]> = new Map();\n\n function getAdjustedExtensions({\n metroSourceExtensions,\n platform,\n isNative,\n }: {\n metroSourceExtensions: readonly string[];\n platform: string | null;\n isNative: boolean;\n }): readonly string[] {\n const key = JSON.stringify({ metroSourceExtensions, platform, isNative });\n if (cachedExtensions.has(key)) {\n return cachedExtensions.get(key)!;\n }\n\n let output = metroSourceExtensions;\n if (platform) {\n const nextOutput: string[] = [];\n\n output.forEach((ext) => {\n nextOutput.push(`${platform}.${ext}`);\n if (isNative) {\n nextOutput.push(`native.${ext}`);\n }\n nextOutput.push(ext);\n });\n\n output = nextOutput;\n }\n\n output = Array.from(new Set<string>(output));\n\n // resolve expects these to start with a dot.\n output = output.map((ext) => `.${ext}`);\n\n cachedExtensions.set(key, output);\n\n return output;\n }\n\n function fastResolve(\n context: Pick<\n ResolutionContext,\n | 'unstable_enablePackageExports'\n | 'customResolverOptions'\n | 'sourceExts'\n | 'preferNativePlatform'\n | 'originModulePath'\n | 'getPackage'\n | 'nodeModulesPaths'\n | 'mainFields'\n | 'resolveAsset'\n >,\n moduleName: string,\n platform: string | null\n ): Resolution {\n // TODO: Support extraNodeModules for tsconfig basePath support\n // TODO: Support package exports import { resolve as resolveExports } from 'resolve.exports'\n // TODO: Support `resolver.blockList`\n if (context.unstable_enablePackageExports) {\n throw new CommandError('package exports are not supported with EXPO_USE_FAST_RESOLVER=1');\n }\n\n const environment = context.customResolverOptions?.environment;\n const isServer = environment === 'node';\n\n const extensions = getAdjustedExtensions({\n metroSourceExtensions: context.sourceExts,\n platform,\n isNative: context.preferNativePlatform,\n });\n\n let fp: string;\n\n try {\n fp = nodeResolve.sync(moduleName, {\n basedir: path.dirname(context.originModulePath),\n extensions,\n // Used to ensure files trace to packages instead of node_modules in expo/expo. This is how Metro works and\n // the app doesn't finish without it.\n preserveSymlinks,\n readPackageSync(readFileSync, pkgFile) {\n return (\n context.getPackage(pkgFile) ??\n JSON.parse(\n // @ts-expect-error\n readFileSync(pkgfile)\n )\n );\n },\n moduleDirectory: context.nodeModulesPaths,\n packageFilter(pkg) {\n // set the pkg.main to the first available field in context.mainFields\n for (const field of context.mainFields) {\n if (\n pkg[field] &&\n // object-inspect uses browser: {} in package.json\n typeof pkg[field] === 'string'\n ) {\n return {\n ...pkg,\n main: pkg[field],\n };\n }\n }\n return pkg;\n },\n\n pathFilter: isServer\n ? undefined\n : (pkg: any, _resolvedPath: string, relativePathIn: string): string => {\n let relativePath = relativePathIn;\n if (relativePath[0] !== '.') {\n relativePath = `./${relativePath}`;\n }\n\n const replacements = pkg.browser;\n if (replacements === undefined) {\n return '';\n }\n\n // TODO: Probably use a better extension matching system here.\n // This was added for `uuid/v4` -> `./lib/rng` -> `./lib/rng-browser.js`\n const mappedPath = replacements[relativePath] ?? replacements[relativePath + '.js'];\n if (mappedPath === false) {\n throw new ShimModuleError();\n }\n return mappedPath;\n },\n\n // Not needed but added for parity...\n\n // @ts-ignore\n realpathSync: context.unstable_getRealPath,\n });\n\n if (!isServer && isNodeExternal(fp)) {\n // In this case, mock the file to use an empty module.\n return {\n type: 'empty',\n };\n }\n } catch (error: any) {\n if (error instanceof ShimModuleError) {\n return {\n type: 'empty',\n };\n }\n\n if ('code' in error && error.code === 'MODULE_NOT_FOUND') {\n // TODO: Add improved error handling.\n throw new FailedToResolvePathError(\n 'The module could not be resolved because no file or module matched the pattern:\\n' +\n ` ${formatFileCandidates(\n {\n type: 'sourceFile',\n filePathPrefix: moduleName,\n candidateExts: extensions,\n },\n true\n )}\\n\\n`\n );\n }\n throw error;\n }\n\n if (context.sourceExts.some((ext) => fp.endsWith(ext))) {\n return {\n type: 'sourceFile',\n filePath: fp,\n };\n } else {\n // NOTE: platform extensions may not be supported on assets.\n\n if (platform === 'web') {\n // Skip multi-resolution on web/server bundles. Only consideration here is that\n // we may still need it in case the only image is a multi-resolution image.\n return {\n type: 'assetFiles',\n filePaths: [fp],\n };\n }\n\n const dirPath = path.dirname(fp);\n const extension = path.extname(fp);\n const basename = path.basename(fp, extension);\n return {\n type: 'assetFiles',\n // Support multi-resolution asset extensions...\n filePaths: context.resolveAsset(dirPath, basename, extension) ?? [fp],\n };\n }\n }\n\n return fastResolve;\n}\n"],"names":["createFastResolver","FailedToResolvePathError","Error","ShimModuleError","preserveSymlinks","cachedExtensions","Map","getAdjustedExtensions","metroSourceExtensions","platform","isNative","key","JSON","stringify","has","get","output","nextOutput","forEach","ext","push","Array","from","Set","map","set","fastResolve","context","moduleName","unstable_enablePackageExports","CommandError","environment","customResolverOptions","isServer","extensions","sourceExts","preferNativePlatform","fp","nodeResolve","sync","basedir","path","dirname","originModulePath","readPackageSync","readFileSync","pkgFile","getPackage","parse","pkgfile","moduleDirectory","nodeModulesPaths","packageFilter","pkg","field","mainFields","main","pathFilter","undefined","_resolvedPath","relativePathIn","relativePath","replacements","browser","mappedPath","realpathSync","unstable_getRealPath","isNodeExternal","type","error","code","formatFileCandidates","filePathPrefix","candidateEx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AClBS,SAAS,EAAE;wBAACxC,EAAE;qBAAC;iBAChB,CAAC;aACH;YAED,MAAMyC,OAAO,GAAGrC,KAAI,QAAA,CAACC,OAAO,CAACL,EAAE,CAAC,AAAC;YACjC,MAAM0C,SAAS,GAAGtC,KAAI,QAAA,CAACuC,OAAO,CAAC3C,EAAE,CAAC,AAAC;YACnC,MAAM4C,QAAQ,GAAGxC,KAAI,QAAA,CAACwC,QAAQ,CAAC5C,EAAE,EAAE0C,SAAS,CAAC,AAAC;gBAIjCpD,IAAkD;YAH/D,OAAO;gBACLyC,IAAI,EAAE,YAAY;gBAClB,+CAA+C;gBAC/CS,SAAS,EAAElD,CAAAA,IAAkD,GAAlDA,OAAO,CAACuD,YAAY,CAACJ,OAAO,EAAEG,QAAQ,EAAEF,SAAS,CAAC,YAAlDpD,IAAkD,GAAI;oBAACU,EAAE;iBAAC;aACtE,CAAC;SACH;KACF;IAED,OAAOX,WAAW,CAAC;CACpB"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/createExpoMetroResolver.ts"],"sourcesContent":["/**\n * Copyright © 2023 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 { Resolution, ResolutionContext } from 'metro-resolver';\nimport path from 'path';\n\nimport jestResolver from './createJResolver';\nimport { isNodeExternal } from './externals';\nimport { formatFileCandidates } from './formatFileCandidates';\n\nclass FailedToResolvePathError extends Error {}\n\nclass ShimModuleError extends Error {}\n\nexport function createFastResolver({\n preserveSymlinks,\n blockList,\n}: {\n preserveSymlinks: boolean;\n blockList: RegExp[];\n}) {\n const cachedExtensions: Map<string, readonly string[]> = new Map();\n\n function getAdjustedExtensions({\n metroSourceExtensions,\n platform,\n isNative,\n }: {\n metroSourceExtensions: readonly string[];\n platform: string | null;\n isNative: boolean;\n }): readonly string[] {\n const key = JSON.stringify({ metroSourceExtensions, platform, isNative });\n if (cachedExtensions.has(key)) {\n return cachedExtensions.get(key)!;\n }\n\n let output = metroSourceExtensions;\n if (platform) {\n const nextOutput: string[] = [];\n\n output.forEach((ext) => {\n nextOutput.push(`${platform}.${ext}`);\n if (isNative) {\n nextOutput.push(`native.${ext}`);\n }\n nextOutput.push(ext);\n });\n\n output = nextOutput;\n }\n\n output = Array.from(new Set<string>(output));\n\n // resolve expects these to start with a dot.\n output = output.map((ext) => `.${ext}`);\n\n cachedExtensions.set(key, output);\n\n return output;\n }\n\n function fastResolve(\n context: Pick<\n ResolutionContext,\n | 'unstable_enablePackageExports'\n | 'customResolverOptions'\n | 'sourceExts'\n | 'preferNativePlatform'\n | 'originModulePath'\n | 'getPackage'\n | 'nodeModulesPaths'\n | 'mainFields'\n | 'resolveAsset'\n | 'unstable_conditionNames'\n | 'unstable_conditionsByPlatform'\n >,\n moduleName: string,\n platform: string | null\n ): Resolution {\n const environment = context.customResolverOptions?.environment;\n const isServer = environment === 'node';\n\n const extensions = getAdjustedExtensions({\n metroSourceExtensions: context.sourceExts,\n platform,\n isNative: context.preferNativePlatform,\n }) as string[];\n\n let fp: string;\n\n try {\n const conditions = context.unstable_enablePackageExports\n ? [\n ...new Set([\n 'default',\n ...context.unstable_conditionNames,\n ...(platform != null ? context.unstable_conditionsByPlatform[platform] ?? [] : []),\n ]),\n ]\n : [];\n\n fp = jestResolver(moduleName, {\n blockList,\n enablePackageExports: context.unstable_enablePackageExports,\n basedir: path.dirname(context.originModulePath),\n paths: context.nodeModulesPaths as string[],\n extensions,\n conditions,\n // @ts-ignore\n realpathSync: context.unstable_getRealPath,\n packageFilter(pkg) {\n // set the pkg.main to the first available field in context.mainFields\n for (const field of context.mainFields) {\n if (\n pkg[field] &&\n // object-inspect uses browser: {} in package.json\n typeof pkg[field] === 'string'\n ) {\n return {\n ...pkg,\n main: pkg[field],\n };\n }\n }\n return pkg;\n },\n // Used to ensure files trace to packages instead of node_modules in expo/expo. This is how Metro works and\n // the app doesn't finish without it.\n preserveSymlinks,\n readPackageSync(readFileSync, pkgFile) {\n return (\n context.getPackage(pkgFile) ??\n JSON.parse(\n // @ts-expect-error\n readFileSync(pkgfile)\n )\n );\n },\n includeCoreModules: isServer,\n\n pathFilter:\n // Disable `browser` field for server environments.\n isServer\n ? undefined\n : // Enable `browser` field support\n (pkg: any, _resolvedPath: string, relativePathIn: string): string => {\n let relativePath = relativePathIn;\n if (relativePath[0] !== '.') {\n relativePath = `./${relativePath}`;\n }\n\n const replacements = pkg.browser;\n if (replacements === undefined) {\n return '';\n }\n\n // TODO: Probably use a better extension matching system here.\n // This was added for `uuid/v4` -> `./lib/rng` -> `./lib/rng-browser.js`\n const mappedPath = replacements[relativePath] ?? replacements[relativePath + '.js'];\n if (mappedPath === false) {\n throw new ShimModuleError();\n }\n return mappedPath;\n },\n });\n } catch (error: any) {\n if (error instanceof ShimModuleError) {\n return {\n type: 'empty',\n };\n }\n\n if ('code' in error && error.code === 'MODULE_NOT_FOUND') {\n if (isNodeExternal(moduleName)) {\n // In this case, mock the file to use an empty module.\n return {\n type: 'empty',\n };\n }\n\n // TODO: Add improved error handling.\n throw new FailedToResolvePathError(\n 'The module could not be resolved because no file or module matched the pattern:\\n' +\n ` ${formatFileCandidates(\n {\n type: 'sourceFile',\n filePathPrefix: moduleName,\n candidateExts: extensions,\n },\n true\n )}\\n\\n`\n );\n }\n throw error;\n }\n\n if (context.sourceExts.some((ext) => fp.endsWith(ext))) {\n return {\n type: 'sourceFile',\n filePath: fp,\n };\n }\n\n if (isNodeExternal(fp)) {\n if (isServer) {\n return {\n type: 'sourceFile',\n filePath: fp,\n };\n }\n // NOTE: This shouldn't happen, the module should throw.\n // Mock non-server built-in modules to empty.\n return {\n type: 'empty',\n };\n }\n\n // NOTE: platform extensions may not be supported on assets.\n\n if (platform === 'web') {\n // Skip multi-resolution on web/server bundles. Only consideration here is that\n // we may still need it in case the only image is a multi-resolution image.\n return {\n type: 'assetFiles',\n filePaths: [fp],\n };\n }\n\n const dirPath = path.dirname(fp);\n const extension = path.extname(fp);\n const basename = path.basename(fp, extension);\n return {\n type: 'assetFiles',\n // Support multi-resolution asset extensions...\n filePaths: context.resolveAsset(dirPath, basename, extension) ?? [fp],\n };\n }\n\n return fastResolve;\n}\n"],"names":["createFastResolver","FailedToResolvePathError","Error","ShimModuleError","preserveSymlinks","blockList","cachedExtensions","Map","getAdjustedExtensions","metroSourceExtensions","platform","isNative","key","JSON","stringify","has","get","output","nextOutput","forEach","ext","push","Array","from","Set","map","set","fastResolve","context","moduleName","environment","customResolverOptions","isServer","extensions","sourceExts","preferNativePlatform","fp","conditions","unstable_enablePackageExports","unstable_conditionNames","unstable_conditionsByPlatform","jestResolver","enablePackageExports","basedir","path","dirname","originModulePath","paths","nodeModulesPaths","realpathSync","unstable_getRealPath","packageFilter","pkg","field","mainFields","main","readPackageSync","readFileSync","pkgFile","getPackage","parse","pkgfile","includeCoreModules","pathFilter","undefined","_resolvedPath","relativePathIn","relativePath","replacements","browser","mappedPath","error","type","code","isNodeExternal","formatFileCandidates","filePathPrefix","candidateExts","some","endsWith","filePath","filePaths","dirPath","extension","extname","basename","resolveAsset"],"mappings":"AAMA;;;;QAWgBA,kBAAkB,GAAlBA,kBAAkB;AAVjB,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEE,IAAA,gBAAmB,kCAAnB,mBAAmB,EAAA;AACb,IAAA,UAAa,WAAb,aAAa,CAAA;AACP,IAAA,qBAAwB,WAAxB,wBAAwB,CAAA;;;;;;AAE7D,MAAMC,wBAAwB,SAASC,KAAK;CAAG;AAE/C,MAAMC,eAAe,SAASD,KAAK;CAAG;AAE/B,SAASF,kBAAkB,CAAC,EACjCI,gBAAgB,CAAA,EAChBC,SAAS,CAAA,EAIV,EAAE;IACD,MAAMC,gBAAgB,GAAmC,IAAIC,GAAG,EAAE,AAAC;IAEnE,SAASC,qBAAqB,CAAC,EAC7BC,qBAAqB,CAAA,EACrBC,QAAQ,CAAA,EACRC,QAAQ,CAAA,EAKT,EAAqB;QACpB,MAAMC,GAAG,GAAGC,IAAI,CAACC,SAAS,CAAC;YAAEL,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,OAAO,CAACT,EAAE,CAAC,AAAC;QACjC,MAAM+C,SAAS,GAAGvC,KAAI,QAAA,CAACwC,OAAO,CAAChD,EAAE,CAAC,AAAC;QACnC,MAAMiD,QAAQ,GAAGzC,KAAI,QAAA,CAACyC,QAAQ,CAACjD,EAAE,EAAE+C,SAAS,CAAC,AAAC;YAIjCvD,IAAkD;QAH/D,OAAO;YACL4C,IAAI,EAAE,YAAY;YAClB,+CAA+C;YAC/CS,SAAS,EAAErD,CAAAA,IAAkD,GAAlDA,OAAO,CAAC0D,YAAY,CAACJ,OAAO,EAAEG,QAAQ,EAAEF,SAAS,CAAC,YAAlDvD,IAAkD,GAAI;gBAACQ,EAAE;aAAC;SACtE,CAAC;KACH;IAED,OAAOT,WAAW,CAAC;CACpB"}
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.default = void 0;
6
+ var _assert = _interopRequireDefault(require("assert"));
7
+ var _path = require("path");
8
+ var _resolve = require("resolve");
9
+ var resolve = _interopRequireWildcard(require("resolve.exports"));
10
+ var _dir = require("../../../utils/dir");
11
+ function _interopRequireDefault(obj) {
12
+ return obj && obj.__esModule ? obj : {
13
+ default: obj
14
+ };
15
+ }
16
+ function _interopRequireWildcard(obj) {
17
+ if (obj && obj.__esModule) {
18
+ return obj;
19
+ } else {
20
+ var newObj = {};
21
+ if (obj != null) {
22
+ for(var key in obj){
23
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
24
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
25
+ if (desc.get || desc.set) {
26
+ Object.defineProperty(newObj, key, desc);
27
+ } else {
28
+ newObj[key] = obj[key];
29
+ }
30
+ }
31
+ }
32
+ }
33
+ newObj.default = obj;
34
+ return newObj;
35
+ }
36
+ }
37
+ const defaultResolver = (path, { enablePackageExports , blockList =[] , ...options })=>{
38
+ // @ts-expect-error
39
+ const resolveOptions = {
40
+ ...options,
41
+ isDirectory (file) {
42
+ if (blockList.some((regex)=>regex.test(file)
43
+ )) {
44
+ return false;
45
+ }
46
+ return (0, _dir).directoryExistsSync(file);
47
+ },
48
+ isFile (file) {
49
+ if (blockList.some((regex)=>regex.test(file)
50
+ )) {
51
+ return false;
52
+ }
53
+ return (0, _dir).fileExistsSync(file);
54
+ },
55
+ preserveSymlinks: enablePackageExports ? false : options.preserveSymlinks,
56
+ defaultResolver
57
+ };
58
+ // resolveSync dereferences symlinks to ensure we don't create a separate
59
+ // module instance depending on how it was referenced.
60
+ const result = (0, _resolve).sync(enablePackageExports ? getPathInModule(path, resolveOptions) : path, resolveOptions);
61
+ return result;
62
+ };
63
+ var _default = defaultResolver;
64
+ exports.default = _default;
65
+ /*
66
+ * helper functions
67
+ */ function getPathInModule(path, options) {
68
+ if (shouldIgnoreRequestForExports(path)) {
69
+ return path;
70
+ }
71
+ const segments = path.split("/");
72
+ let moduleName = segments.shift();
73
+ if (moduleName) {
74
+ if (moduleName.startsWith("@")) {
75
+ moduleName = `${moduleName}/${segments.shift()}`;
76
+ }
77
+ // Disable package exports for babel/runtime for https://github.com/facebook/metro/issues/984/
78
+ if (moduleName === "@babel/runtime") {
79
+ return path;
80
+ }
81
+ // self-reference
82
+ const closestPackageJson = findClosestPackageJson(options.basedir, options);
83
+ if (closestPackageJson) {
84
+ const pkg = options.readPackageSync(options.readFileSync, closestPackageJson);
85
+ (0, _assert).default(pkg, "package.json should be read by `readPackageSync`");
86
+ if (pkg.name === moduleName) {
87
+ const resolved = resolve.exports(pkg, segments.join("/") || ".", createResolveOptions(options.conditions));
88
+ if (resolved) {
89
+ return (0, _path).resolve((0, _path).dirname(closestPackageJson), resolved[0]);
90
+ }
91
+ if (pkg.exports) {
92
+ throw new Error("`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Please report an issue");
93
+ }
94
+ }
95
+ }
96
+ let packageJsonPath = "";
97
+ try {
98
+ packageJsonPath = (0, _resolve).sync(`${moduleName}/package.json`, options);
99
+ } catch {
100
+ // ignore if package.json cannot be found
101
+ }
102
+ if (packageJsonPath && options.isFile(packageJsonPath)) {
103
+ const pkg = options.readPackageSync(options.readFileSync, packageJsonPath);
104
+ (0, _assert).default(pkg, "package.json should be read by `readPackageSync`");
105
+ const resolved = resolve.exports(pkg, segments.join("/") || ".", createResolveOptions(options.conditions));
106
+ if (resolved) {
107
+ return (0, _path).resolve((0, _path).dirname(packageJsonPath), resolved[0]);
108
+ }
109
+ if (pkg.exports) {
110
+ throw new Error("`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Please report an issue");
111
+ }
112
+ }
113
+ }
114
+ return path;
115
+ }
116
+ function createResolveOptions(conditions) {
117
+ return conditions ? {
118
+ conditions,
119
+ unsafe: true
120
+ } : {
121
+ browser: false,
122
+ require: true
123
+ };
124
+ }
125
+ // if it's a relative import or an absolute path, imports/exports are ignored
126
+ const shouldIgnoreRequestForExports = (path)=>path.startsWith(".") || (0, _path).isAbsolute(path)
127
+ ;
128
+ // adapted from
129
+ // https://github.com/lukeed/escalade/blob/2477005062cdbd8407afc90d3f48f4930354252b/src/sync.js
130
+ function findClosestPackageJson(start, options) {
131
+ let dir = (0, _path).resolve(".", start);
132
+ if (!options.isDirectory(dir)) {
133
+ dir = (0, _path).dirname(dir);
134
+ }
135
+ while(true){
136
+ const pkgJsonFile = (0, _path).resolve(dir, "./package.json");
137
+ const hasPackageJson = options.isFile(pkgJsonFile);
138
+ if (hasPackageJson) {
139
+ return pkgJsonFile;
140
+ }
141
+ const prevDir = dir;
142
+ dir = (0, _path).dirname(dir);
143
+ if (prevDir === dir) {
144
+ return undefined;
145
+ }
146
+ }
147
+ }
148
+
149
+ //# sourceMappingURL=createJResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/createJResolver.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\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 * Fork of the jest resolver but with additional settings for Metro and pnp removed.\n * https://github.com/jestjs/jest/blob/d1a2ed7fea4bdc19836274cd810c8360e3ab62f3/packages/jest-resolve/src/defaultResolver.ts#L1\n */\nimport type { JSONObject as PackageJSON } from '@expo/json-file';\nimport assert from 'assert';\nimport { dirname, isAbsolute, resolve as pathResolve } from 'path';\nimport { sync as resolveSync, SyncOpts as UpstreamResolveOptions } from 'resolve';\nimport * as resolve from 'resolve.exports';\n\nimport { directoryExistsSync, fileExistsSync } from '../../../utils/dir';\n\n/**\n * Allows transforming parsed `package.json` contents.\n *\n * @param pkg - Parsed `package.json` contents.\n * @param file - Path to `package.json` file.\n * @param dir - Directory that contains the `package.json`.\n *\n * @returns Transformed `package.json` contents.\n */\nexport type PackageFilter = (pkg: PackageJSON, file: string, dir: string) => PackageJSON;\n\n/**\n * Allows transforming a path within a package.\n *\n * @param pkg - Parsed `package.json` contents.\n * @param path - Path being resolved.\n * @param relativePath - Path relative from the `package.json` location.\n *\n * @returns Relative path that will be joined from the `package.json` location.\n */\nexport type PathFilter = (pkg: PackageJSON, path: string, relativePath: string) => string;\n\nexport type ResolverOptions = {\n /** Directory to begin resolving from. */\n basedir: string;\n /** List of export conditions. */\n conditions?: string[];\n /** Instance of default resolver. */\n defaultResolver: typeof defaultResolver;\n /** List of file extensions to search in order. */\n extensions?: string[];\n /**\n * List of directory names to be looked up for modules recursively.\n *\n * @defaultValue\n * The default is `['node_modules']`.\n */\n moduleDirectory?: string[];\n /**\n * List of `require.paths` to use if nothing is found in `node_modules`.\n *\n * @defaultValue\n * The default is `undefined`.\n */\n paths?: string[];\n /** Allows transforming parsed `package.json` contents. */\n packageFilter?: PackageFilter;\n /** Allows transforms a path within a package. */\n pathFilter?: PathFilter;\n /** Current root directory. */\n rootDir?: string;\n\n enablePackageExports?: boolean;\n\n blockList: RegExp[];\n} & Pick<\n UpstreamResolveOptions,\n 'readPackageSync' | 'moduleDirectory' | 'extensions' | 'preserveSymlinks' | 'includeCoreModules'\n>;\n\ntype UpstreamResolveOptionsWithConditions = UpstreamResolveOptions & ResolverOptions;\n\nexport type SyncResolver = (path: string, options: ResolverOptions) => string;\nexport type AsyncResolver = (path: string, options: ResolverOptions) => Promise<string>;\n\nexport type Resolver = SyncResolver | AsyncResolver;\n\nconst defaultResolver: SyncResolver = (\n path,\n { enablePackageExports, blockList = [], ...options }\n) => {\n // @ts-expect-error\n const resolveOptions: UpstreamResolveOptionsWithConditions = {\n ...options,\n\n isDirectory(file) {\n if (blockList.some((regex) => regex.test(file))) {\n return false;\n }\n return directoryExistsSync(file);\n },\n isFile(file) {\n if (blockList.some((regex) => regex.test(file))) {\n return false;\n }\n return fileExistsSync(file);\n },\n preserveSymlinks: enablePackageExports ? false : options.preserveSymlinks,\n defaultResolver,\n };\n\n // resolveSync dereferences symlinks to ensure we don't create a separate\n // module instance depending on how it was referenced.\n const result = resolveSync(\n enablePackageExports ? getPathInModule(path, resolveOptions) : path,\n resolveOptions\n );\n\n return result;\n};\n\nexport default defaultResolver;\n\n/*\n * helper functions\n */\n\nfunction getPathInModule(path: string, options: UpstreamResolveOptionsWithConditions): string {\n if (shouldIgnoreRequestForExports(path)) {\n return path;\n }\n\n const segments = path.split('/');\n\n let moduleName = segments.shift();\n\n if (moduleName) {\n if (moduleName.startsWith('@')) {\n moduleName = `${moduleName}/${segments.shift()}`;\n }\n\n // Disable package exports for babel/runtime for https://github.com/facebook/metro/issues/984/\n if (moduleName === '@babel/runtime') {\n return path;\n }\n\n // self-reference\n const closestPackageJson = findClosestPackageJson(options.basedir, options);\n if (closestPackageJson) {\n const pkg = options.readPackageSync!(options.readFileSync!, closestPackageJson);\n assert(pkg, 'package.json should be read by `readPackageSync`');\n\n if (pkg.name === moduleName) {\n const resolved = resolve.exports(\n pkg,\n (segments.join('/') || '.') as resolve.Exports.Entry,\n createResolveOptions(options.conditions)\n );\n\n if (resolved) {\n return pathResolve(dirname(closestPackageJson), resolved[0]);\n }\n\n if (pkg.exports) {\n throw new Error(\n \"`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Please report an issue\"\n );\n }\n }\n }\n\n let packageJsonPath = '';\n\n try {\n packageJsonPath = resolveSync(`${moduleName}/package.json`, options);\n } catch {\n // ignore if package.json cannot be found\n }\n\n if (packageJsonPath && options.isFile!(packageJsonPath)) {\n const pkg = options.readPackageSync!(options.readFileSync!, packageJsonPath);\n assert(pkg, 'package.json should be read by `readPackageSync`');\n\n const resolved = resolve.exports(\n pkg,\n (segments.join('/') || '.') as resolve.Exports.Entry,\n createResolveOptions(options.conditions)\n );\n\n if (resolved) {\n return pathResolve(dirname(packageJsonPath), resolved[0]);\n }\n\n if (pkg.exports) {\n throw new Error(\n \"`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Please report an issue\"\n );\n }\n }\n }\n\n return path;\n}\n\nfunction createResolveOptions(conditions: string[] | undefined): resolve.Options {\n return conditions\n ? { conditions, unsafe: true }\n : // no conditions were passed - let's assume this is Jest internal and it should be `require`\n { browser: false, require: true };\n}\n\n// if it's a relative import or an absolute path, imports/exports are ignored\nconst shouldIgnoreRequestForExports = (path: string) => path.startsWith('.') || isAbsolute(path);\n\n// adapted from\n// https://github.com/lukeed/escalade/blob/2477005062cdbd8407afc90d3f48f4930354252b/src/sync.js\nfunction findClosestPackageJson(\n start: string,\n options: UpstreamResolveOptions\n): string | undefined {\n let dir = pathResolve('.', start);\n if (!options.isDirectory!(dir)) {\n dir = dirname(dir);\n }\n\n while (true) {\n const pkgJsonFile = pathResolve(dir, './package.json');\n const hasPackageJson = options.isFile!(pkgJsonFile);\n\n if (hasPackageJson) {\n return pkgJsonFile;\n }\n\n const prevDir = dir;\n dir = dirname(dir);\n\n if (prevDir === dir) {\n return undefined;\n }\n }\n}\n"],"names":["resolve","defaultResolver","path","enablePackageExports","blockList","options","resolveOptions","isDirectory","file","some","regex","test","directoryExistsSync","isFile","fileExistsSync","preserveSymlinks","result","resolveSync","getPathInModule","shouldIgnoreRequestForExports","segments","split","moduleName","shift","startsWith","closestPackageJson","findClosestPackageJson","basedir","pkg","readPackageSync","readFileSync","assert","name","resolved","exports","join","createResolveOptions","conditions","pathResolve","dirname","Error","packageJsonPath","unsafe","browser","require","isAbsolute","start","dir","pkgJsonFile","hasPackageJson","prevDir","undefined"],"mappings":"AAUA;;;;;AACmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACiC,IAAA,KAAM,WAAN,MAAM,CAAA;AACM,IAAA,QAAS,WAAT,SAAS,CAAA;AACrEA,IAAAA,OAAO,mCAAM,iBAAiB,EAAvB;AAEiC,IAAA,IAAoB,WAApB,oBAAoB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqExE,MAAMC,eAAe,GAAiB,CACpCC,IAAI,EACJ,EAAEC,oBAAoB,CAAA,EAAEC,SAAS,EAAG,EAAE,CAAA,EAAE,GAAGC,OAAO,EAAE,GACjD;IACH,mBAAmB;IACnB,MAAMC,cAAc,GAAyC;QAC3D,GAAGD,OAAO;QAEVE,WAAW,EAACC,IAAI,EAAE;YAChB,IAAIJ,SAAS,CAACK,IAAI,CAAC,CAACC,KAAK,GAAKA,KAAK,CAACC,IAAI,CAACH,IAAI,CAAC;YAAA,CAAC,EAAE;gBAC/C,OAAO,KAAK,CAAC;aACd;YACD,OAAOI,CAAAA,GAAAA,IAAmB,AAAM,CAAA,oBAAN,CAACJ,IAAI,CAAC,CAAC;SAClC;QACDK,MAAM,EAACL,IAAI,EAAE;YACX,IAAIJ,SAAS,CAACK,IAAI,CAAC,CAACC,KAAK,GAAKA,KAAK,CAACC,IAAI,CAACH,IAAI,CAAC;YAAA,CAAC,EAAE;gBAC/C,OAAO,KAAK,CAAC;aACd;YACD,OAAOM,CAAAA,GAAAA,IAAc,AAAM,CAAA,eAAN,CAACN,IAAI,CAAC,CAAC;SAC7B;QACDO,gBAAgB,EAAEZ,oBAAoB,GAAG,KAAK,GAAGE,OAAO,CAACU,gBAAgB;QACzEd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GAAAA,KAAO,AAAK,CAAA,QAAL,CAACQ,GAAG,CAAC,CAAC;QAEnB,IAAIG,OAAO,KAAKH,GAAG,EAAE;YACnB,OAAOI,SAAS,CAAC;SAClB;KACF;CACF"}
@@ -29,7 +29,19 @@ function createRouteHandlerMiddleware(projectRoot, options) {
29
29
  debug("manifest", manifest);
30
30
  // NOTE: no app dir if null
31
31
  // TODO: Redirect to 404 page
32
- return manifest;
32
+ return manifest != null ? manifest : {
33
+ // Support the onboarding screen if there's no manifest
34
+ htmlRoutes: [
35
+ {
36
+ file: "index.js",
37
+ page: "/index",
38
+ routeKeys: {},
39
+ namedRegex: /^\/(?:index)?\/?$/i
40
+ },
41
+ ],
42
+ apiRoutes: [],
43
+ notFoundRoutes: []
44
+ };
33
45
  },
34
46
  async getHtml (request) {
35
47
  try {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/createServerRouteMiddleware.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 { ExpoResponse } from '@expo/server';\nimport { createRequestHandler } from '@expo/server/build/vendor/http';\nimport requireString from 'require-from-string';\nimport resolve from 'resolve';\nimport { promisify } from 'util';\n\nimport { ForwardHtmlError } from './MetroBundlerDevServer';\nimport { bundleApiRoute } from './bundleApiRoutes';\nimport { fetchManifest } from './fetchRouterManifest';\nimport { getErrorOverlayHtmlAsync, logMetroError, logMetroErrorAsync } from './metroErrorInterface';\nimport { Log } from '../../../log';\n\nconst debug = require('debug')('expo:start:server:metro') as typeof console.log;\n\nconst resolveAsync = promisify(resolve) as any as (\n id: string,\n opts: resolve.AsyncOpts\n) => Promise<string | null>;\n\nexport function createRouteHandlerMiddleware(\n projectRoot: string,\n options: {\n mode?: string;\n appDir: string;\n port?: number;\n getWebBundleUrl: () => string;\n getStaticPageAsync: (pathname: string) => Promise<{ content: string }>;\n }\n) {\n return createRequestHandler(\n { build: '' },\n {\n async getRoutesManifest() {\n const manifest = await fetchManifest<RegExp>(projectRoot, options);\n debug('manifest', manifest);\n // NOTE: no app dir if null\n // TODO: Redirect to 404 page\n return manifest;\n },\n async getHtml(request) {\n try {\n const { content } = await options.getStaticPageAsync(request.url);\n return content;\n } catch (error: any) {\n // Forward the Metro server response as-is. It won't be pretty, but at least it will be accurate.\n if (error instanceof ForwardHtmlError) {\n return new ExpoResponse(error.html, {\n status: error.statusCode,\n headers: {\n 'Content-Type': 'text/html',\n },\n });\n }\n\n try {\n return new ExpoResponse(\n await getErrorOverlayHtmlAsync({\n error,\n projectRoot,\n }),\n {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n }\n );\n } catch (staticError: any) {\n // Fallback error for when Expo Router is misconfigured in the project.\n return new ExpoResponse(\n '<span><h3>Internal Error:</h3><b>Project is not setup correctly for static rendering (check terminal for more info):</b><br/>' +\n error.message +\n '<br/><br/>' +\n staticError.message +\n '</span>',\n {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n }\n );\n }\n }\n },\n logApiRouteExecutionError(error) {\n logMetroError(projectRoot, { error });\n },\n async getApiRoute(route) {\n const resolvedFunctionPath = await resolveAsync(route.page, {\n extensions: ['.js', '.jsx', '.ts', '.tsx'],\n basedir: options.appDir,\n });\n\n const middlewareContents = await bundleApiRoute(\n projectRoot,\n resolvedFunctionPath!,\n options\n );\n if (!middlewareContents) {\n // TODO: Error handling\n return null;\n }\n\n try {\n debug(`Bundling middleware at: ${resolvedFunctionPath}`);\n return requireString(middlewareContents);\n } catch (error: any) {\n if (error instanceof Error) {\n await logMetroErrorAsync({ projectRoot, error });\n } else {\n Log.error('Failed to load middleware: ' + error);\n }\n return new ExpoResponse(\n 'Failed to load middleware: ' + resolvedFunctionPath + '\\n\\n' + error.message,\n {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n }\n );\n }\n },\n }\n );\n}\n"],"names":["createRouteHandlerMiddleware","debug","require","resolveAsync","promisify","resolve","projectRoot","options","createRequestHandler","build","getRoutesManifest","manifest","fetchManifest","getHtml","request","content","getStaticPageAsync","url","error","ForwardHtmlError","ExpoResponse","html","status","statusCode","headers","getErrorOverlayHtmlAsync","staticError","message","logApiRouteExecutionError","logMetroError","getApiRoute","route","resolvedFunctionPath","page","extensions","basedir","appDir","middlewareContents","bundleApiRoute","requireString","Error","logMetroErrorAsync","Log"],"mappings":"AAMA;;;;QAmBgBA,4BAA4B,GAA5BA,4BAA4B;AAnBf,IAAA,OAAc,WAAd,cAAc,CAAA;AACN,IAAA,KAAgC,WAAhC,gCAAgC,CAAA;AAC3C,IAAA,kBAAqB,kCAArB,qBAAqB,EAAA;AAC3B,IAAA,QAAS,kCAAT,SAAS,EAAA;AACH,IAAA,KAAM,WAAN,MAAM,CAAA;AAEC,IAAA,sBAAyB,WAAzB,yBAAyB,CAAA;AAC3B,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;AACpB,IAAA,oBAAuB,WAAvB,uBAAuB,CAAA;AACuB,IAAA,oBAAuB,WAAvB,uBAAuB,CAAA;AAC/E,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;AAElC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,yBAAyB,CAAC,AAAsB,AAAC;AAEhF,MAAMC,YAAY,GAAGC,CAAAA,GAAAA,KAAS,AAAS,CAAA,UAAT,CAACC,QAAO,QAAA,CAAC,AAGZ,AAAC;AAErB,SAASL,4BAA4B,CAC1CM,WAAmB,EACnBC,OAMC,EACD;IACA,OAAOC,CAAAA,GAAAA,KAAoB,AAgG1B,CAAA,qBAhG0B,CACzB;QAAEC,KAAK,EAAE,EAAE;KAAE,EACb;QACE,MAAMC,iBAAiB,IAAG;YACxB,MAAMC,QAAQ,GAAG,MAAMC,CAAAA,GAAAA,oBAAa,AAA8B,CAAA,cAA9B,CAASN,WAAW,EAAEC,OAAO,CAAC,AAAC;YACnEN,KAAK,CAAC,UAAU,EAAEU,QAAQ,CAAC,CAAC;YAC5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B,MAAMC,oBAAoB,GAAG,MAAM7B,YAAY,CAAC4B,KAAK,CAACE,IAAI,EAAE;gBAC1DC,UAAU,EAAE;oBAAC,KAAK;oBAAE,MAAM;oBAAE,KAAK;oBAAE,MAAM;iBAAC;gBAC1CC,OAAO,EAAE5B,OAAO,CAAC6B,MAAM;aACxB,CAAC,AAAC;YAEH,MAAMC,kBAAkB,GAAG,MAAMC,CAAAA,GAAAA,gBAAc,AAI9C,CAAA,eAJ8C,CAC7ChC,WAAW,EACX0B,oBAAoB,EACpBzB,OAAO,CACR,AAAC;YACF,IAAI,CAAC8B,kBAAkB,EAAE;gBACvB,uBAAuB;gBACvB,OAAO,IAAI,CAAC;aACb;YAED,IAAI;gBACFpC,KAAK,CAAC,CAAC,wBAAwB,EAAE+B,oBAAoB,CAAC,CAAC,CAAC,CAAC;gBACzD,OAAOO,CAAAA,GAAAA,kBAAa,AAAoB,CAAA,QAApB,CAACF,kBAAkB,CAAC,CAAC;aAC1C,CAAC,OAAOnB,KAAK,EAAO;gBACnB,IAAIA,KAAK,YAAYsB,KAAK,EAAE;oBAC1B,MAAMC,CAAAA,GAAAA,oBAAkB,AAAwB,CAAA,mBAAxB,CAAC;wBAAEnC,WAAW;wBAAEY,KAAK;qBAAE,CAAC,CAAC;iBAClD,MAAM;oBACLwB,IAAG,IAAA,CAACxB,KAAK,CAAC,6BAA6B,GAAGA,KAAK,CAAC,CAAC;iBAClD;gBACD,OAAO,IAAIE,OAAY,aAAA,CACrB,6BAA6B,GAAGY,oBAAoB,GAAG,MAAM,GAAGd,KAAK,CAACS,OAAO,EAC7E;oBACEL,MAAM,EAAE,GAAG;oBACXE,OAAO,EAAE;wBACP,cAAc,EAAE,WAAW;qBAC5B;iBACF,CACF,CAAC;aACH;SACF;KACF,CACF,CAAC;CACH"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/createServerRouteMiddleware.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 { ExpoResponse } from '@expo/server';\nimport { createRequestHandler } from '@expo/server/build/vendor/http';\nimport requireString from 'require-from-string';\nimport resolve from 'resolve';\nimport { promisify } from 'util';\n\nimport { ForwardHtmlError } from './MetroBundlerDevServer';\nimport { bundleApiRoute } from './bundleApiRoutes';\nimport { fetchManifest } from './fetchRouterManifest';\nimport { getErrorOverlayHtmlAsync, logMetroError, logMetroErrorAsync } from './metroErrorInterface';\nimport { Log } from '../../../log';\n\nconst debug = require('debug')('expo:start:server:metro') as typeof console.log;\n\nconst resolveAsync = promisify(resolve) as any as (\n id: string,\n opts: resolve.AsyncOpts\n) => Promise<string | null>;\n\nexport function createRouteHandlerMiddleware(\n projectRoot: string,\n options: {\n mode?: string;\n appDir: string;\n port?: number;\n baseUrl: string;\n getWebBundleUrl: () => string;\n getStaticPageAsync: (pathname: string) => Promise<{ content: string }>;\n }\n) {\n return createRequestHandler(\n { build: '' },\n {\n async getRoutesManifest() {\n const manifest = await fetchManifest<RegExp>(projectRoot, options);\n debug('manifest', manifest);\n // NOTE: no app dir if null\n // TODO: Redirect to 404 page\n return (\n manifest ?? {\n // Support the onboarding screen if there's no manifest\n htmlRoutes: [\n {\n file: 'index.js',\n page: '/index',\n routeKeys: {},\n namedRegex: /^\\/(?:index)?\\/?$/i,\n },\n ],\n apiRoutes: [],\n notFoundRoutes: [],\n }\n );\n },\n async getHtml(request) {\n try {\n const { content } = await options.getStaticPageAsync(request.url);\n return content;\n } catch (error: any) {\n // Forward the Metro server response as-is. It won't be pretty, but at least it will be accurate.\n if (error instanceof ForwardHtmlError) {\n return new ExpoResponse(error.html, {\n status: error.statusCode,\n headers: {\n 'Content-Type': 'text/html',\n },\n });\n }\n\n try {\n return new ExpoResponse(\n await getErrorOverlayHtmlAsync({\n error,\n projectRoot,\n }),\n {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n }\n );\n } catch (staticError: any) {\n // Fallback error for when Expo Router is misconfigured in the project.\n return new ExpoResponse(\n '<span><h3>Internal Error:</h3><b>Project is not setup correctly for static rendering (check terminal for more info):</b><br/>' +\n error.message +\n '<br/><br/>' +\n staticError.message +\n '</span>',\n {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n }\n );\n }\n }\n },\n logApiRouteExecutionError(error) {\n logMetroError(projectRoot, { error });\n },\n async getApiRoute(route) {\n const resolvedFunctionPath = await resolveAsync(route.page, {\n extensions: ['.js', '.jsx', '.ts', '.tsx'],\n basedir: options.appDir,\n });\n\n const middlewareContents = await bundleApiRoute(\n projectRoot,\n resolvedFunctionPath!,\n options\n );\n if (!middlewareContents) {\n // TODO: Error handling\n return null;\n }\n\n try {\n debug(`Bundling middleware at: ${resolvedFunctionPath}`);\n return requireString(middlewareContents);\n } catch (error: any) {\n if (error instanceof Error) {\n await logMetroErrorAsync({ projectRoot, error });\n } else {\n Log.error('Failed to load middleware: ' + error);\n }\n return new ExpoResponse(\n 'Failed to load middleware: ' + resolvedFunctionPath + '\\n\\n' + error.message,\n {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n }\n );\n }\n },\n }\n );\n}\n"],"names":["createRouteHandlerMiddleware","debug","require","resolveAsync","promisify","resolve","projectRoot","options","createRequestHandler","build","getRoutesManifest","manifest","fetchManifest","htmlRoutes","file","page","routeKeys","namedRegex","apiRoutes","notFoundRoutes","getHtml","request","content","getStaticPageAsync","url","error","ForwardHtmlError","ExpoResponse","html","status","statusCode","headers","getErrorOverlayHtmlAsync","staticError","message","logApiRouteExecutionError","logMetroError","getApiRoute","route","resolvedFunctionPath","extensions","basedir","appDir","middlewareContents","bundleApiRoute","requireString","Error","logMetroErrorAsync","Log"],"mappings":"AAMA;;;;QAmBgBA,4BAA4B,GAA5BA,4BAA4B;AAnBf,IAAA,OAAc,WAAd,cAAc,CAAA;AACN,IAAA,KAAgC,WAAhC,gCAAgC,CAAA;AAC3C,IAAA,kBAAqB,kCAArB,qBAAqB,EAAA;AAC3B,IAAA,QA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AM;aACxB,CAAC,AAAC;YAEH,MAAMC,kBAAkB,GAAG,MAAMC,CAAAA,GAAAA,gBAAc,AAI9C,CAAA,eAJ8C,CAC7CtC,WAAW,EACXiC,oBAAoB,EACpBhC,OAAO,CACR,AAAC;YACF,IAAI,CAACoC,kBAAkB,EAAE;gBACvB,uBAAuB;gBACvB,OAAO,IAAI,CAAC;aACb;YAED,IAAI;gBACF1C,KAAK,CAAC,CAAC,wBAAwB,EAAEsC,oBAAoB,CAAC,CAAC,CAAC,CAAC;gBACzD,OAAOM,CAAAA,GAAAA,kBAAa,AAAoB,CAAA,QAApB,CAACF,kBAAkB,CAAC,CAAC;aAC1C,CAAC,OAAOlB,KAAK,EAAO;gBACnB,IAAIA,KAAK,YAAYqB,KAAK,EAAE;oBAC1B,MAAMC,CAAAA,GAAAA,oBAAkB,AAAwB,CAAA,mBAAxB,CAAC;wBAAEzC,WAAW;wBAAEmB,KAAK;qBAAE,CAAC,CAAC;iBAClD,MAAM;oBACLuB,IAAG,IAAA,CAACvB,KAAK,CAAC,6BAA6B,GAAGA,KAAK,CAAC,CAAC;iBAClD;gBACD,OAAO,IAAIE,OAAY,aAAA,CACrB,6BAA6B,GAAGY,oBAAoB,GAAG,MAAM,GAAGd,KAAK,CAACS,OAAO,EAC7E;oBACEL,MAAM,EAAE,GAAG;oBACXE,OAAO,EAAE;wBACP,cAAc,EAAE,WAAW;qBAC5B;iBACF,CACF,CAAC;aACH;SACF;KACF,CACF,CAAC;CACH"}
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.getNodeExternalModuleId = getNodeExternalModuleId;
6
+ exports.setupShimFiles = setupShimFiles;
6
7
  exports.setupNodeExternals = setupNodeExternals;
7
8
  exports.isNodeExternal = isNodeExternal;
8
- exports.METRO_EXTERNALS_FOLDER = exports.EXTERNAL_REQUIRE_NATIVE_POLYFILL = exports.EXTERNAL_REQUIRE_POLYFILL = exports.NODE_STDLIB_MODULES = void 0;
9
+ exports.METRO_SHIMS_FOLDER = exports.METRO_EXTERNALS_FOLDER = exports.EXTERNAL_REQUIRE_NATIVE_POLYFILL = exports.EXTERNAL_REQUIRE_POLYFILL = exports.NODE_STDLIB_MODULES = void 0;
9
10
  var _fs = _interopRequireDefault(require("fs"));
10
11
  var _module = require("module");
11
12
  var _path = _interopRequireDefault(require("path"));
13
+ var _dir = require("../../../utils/dir");
12
14
  function _interopRequireDefault(obj) {
13
15
  return obj && obj.__esModule ? obj : {
14
16
  default: obj
@@ -29,9 +31,22 @@ const EXTERNAL_REQUIRE_NATIVE_POLYFILL = ".expo/metro/polyfill.native.js";
29
31
  exports.EXTERNAL_REQUIRE_NATIVE_POLYFILL = EXTERNAL_REQUIRE_NATIVE_POLYFILL;
30
32
  const METRO_EXTERNALS_FOLDER = ".expo/metro/externals";
31
33
  exports.METRO_EXTERNALS_FOLDER = METRO_EXTERNALS_FOLDER;
34
+ const METRO_SHIMS_FOLDER = ".expo/metro/shims";
35
+ exports.METRO_SHIMS_FOLDER = METRO_SHIMS_FOLDER;
32
36
  function getNodeExternalModuleId(fromModule, moduleId) {
33
37
  return _path.default.relative(_path.default.dirname(fromModule), _path.default.join(METRO_EXTERNALS_FOLDER, moduleId, "index.js"));
34
38
  }
39
+ async function setupShimFiles(projectRoot) {
40
+ await _fs.default.promises.mkdir(_path.default.join(projectRoot, METRO_SHIMS_FOLDER), {
41
+ recursive: true
42
+ });
43
+ // Copy the shims to the project folder in case we're running in a monorepo.
44
+ const shimsFolder = _path.default.join(require.resolve("@expo/cli/package.json"), "../static/shims");
45
+ await (0, _dir).copyAsync(shimsFolder, _path.default.join(projectRoot, METRO_SHIMS_FOLDER), {
46
+ overwrite: false,
47
+ recursive: true
48
+ });
49
+ }
35
50
  async function setupNodeExternals(projectRoot) {
36
51
  await tapExternalRequirePolyfill(projectRoot);
37
52
  await tapNodeShims(projectRoot);
@@ -40,8 +55,15 @@ async function tapExternalRequirePolyfill(projectRoot) {
40
55
  await _fs.default.promises.mkdir(_path.default.join(projectRoot, _path.default.dirname(EXTERNAL_REQUIRE_POLYFILL)), {
41
56
  recursive: true
42
57
  });
43
- await _fs.default.promises.writeFile(_path.default.join(projectRoot, EXTERNAL_REQUIRE_POLYFILL), 'global.$$require_external = typeof window === "undefined" ? require : () => null;');
44
- await _fs.default.promises.writeFile(_path.default.join(projectRoot, EXTERNAL_REQUIRE_NATIVE_POLYFILL), "global.$$require_external = (moduleId) => {throw new Error(`Node.js standard library module ${moduleId} is not available in this JavaScript environment`);}");
58
+ await writeIfDifferentAsync(_path.default.join(projectRoot, EXTERNAL_REQUIRE_POLYFILL), 'global.$$require_external = typeof window === "undefined" ? require : () => null;');
59
+ await writeIfDifferentAsync(_path.default.join(projectRoot, EXTERNAL_REQUIRE_NATIVE_POLYFILL), "global.$$require_external = (moduleId) => {throw new Error(`Node.js standard library module ${moduleId} is not available in this JavaScript environment`);}");
60
+ }
61
+ async function writeIfDifferentAsync(filePath, contents) {
62
+ if (_fs.default.existsSync(filePath)) {
63
+ const current = await _fs.default.promises.readFile(filePath, "utf8");
64
+ if (current === contents) return;
65
+ }
66
+ await _fs.default.promises.writeFile(filePath, contents);
45
67
  }
46
68
  function isNodeExternal(moduleName) {
47
69
  const moduleId = moduleName.replace(/^node:/, "");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/externals.ts"],"sourcesContent":["/**\n * Copyright © 2023 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 fs from 'fs';\nimport { builtinModules } from 'module';\nimport path from 'path';\n\n// A list of the Node.js standard library modules that are currently\n// available,\nexport const NODE_STDLIB_MODULES: string[] = [\n 'fs/promises',\n ...(\n builtinModules ||\n // @ts-expect-error\n (process.binding ? Object.keys(process.binding('natives')) : []) ||\n []\n ).filter((x) => !/^_|^(internal|v8|node-inspect)\\/|\\//.test(x) && !['sys'].includes(x)),\n].sort();\n\nexport const EXTERNAL_REQUIRE_POLYFILL = '.expo/metro/polyfill.js';\nexport const EXTERNAL_REQUIRE_NATIVE_POLYFILL = '.expo/metro/polyfill.native.js';\nexport const METRO_EXTERNALS_FOLDER = '.expo/metro/externals';\n\nexport function getNodeExternalModuleId(fromModule: string, moduleId: string) {\n return path.relative(\n path.dirname(fromModule),\n path.join(METRO_EXTERNALS_FOLDER, moduleId, 'index.js')\n );\n}\n\nexport async function setupNodeExternals(projectRoot: string) {\n await tapExternalRequirePolyfill(projectRoot);\n await tapNodeShims(projectRoot);\n}\n\nasync function tapExternalRequirePolyfill(projectRoot: string) {\n await fs.promises.mkdir(path.join(projectRoot, path.dirname(EXTERNAL_REQUIRE_POLYFILL)), {\n recursive: true,\n });\n await fs.promises.writeFile(\n path.join(projectRoot, EXTERNAL_REQUIRE_POLYFILL),\n 'global.$$require_external = typeof window === \"undefined\" ? require : () => null;'\n );\n await fs.promises.writeFile(\n path.join(projectRoot, EXTERNAL_REQUIRE_NATIVE_POLYFILL),\n 'global.$$require_external = (moduleId) => {throw new Error(`Node.js standard library module ${moduleId} is not available in this JavaScript environment`);}'\n );\n}\n\nexport function isNodeExternal(moduleName: string): string | null {\n const moduleId = moduleName.replace(/^node:/, '');\n if (NODE_STDLIB_MODULES.includes(moduleId)) {\n return moduleId;\n }\n return null;\n}\n\nfunction tapNodeShimContents(moduleId: string): string {\n return `module.exports = $$require_external('node:${moduleId}');`;\n}\n\n// Ensure Node.js shims which require using `$$require_external` are available inside the project.\nasync function tapNodeShims(projectRoot: string) {\n const externals: Record<string, string> = {};\n for (const moduleId of NODE_STDLIB_MODULES) {\n const shimDir = path.join(projectRoot, METRO_EXTERNALS_FOLDER, moduleId);\n const shimPath = path.join(shimDir, 'index.js');\n externals[moduleId] = shimPath;\n\n if (!fs.existsSync(shimPath)) {\n await fs.promises.mkdir(shimDir, { recursive: true });\n await fs.promises.writeFile(shimPath, tapNodeShimContents(moduleId));\n }\n }\n}\n"],"names":["getNodeExternalModuleId","setupNodeExternals","isNodeExternal","NODE_STDLIB_MODULES","builtinModules","process","binding","Object","keys","filter","x","test","includes","sort","EXTERNAL_REQUIRE_POLYFILL","EXTERNAL_REQUIRE_NATIVE_POLYFILL","METRO_EXTERNALS_FOLDER","fromModule","moduleId","path","relative","dirname","join","projectRoot","tapExternalRequirePolyfill","tapNodeShims","fs","promises","mkdir","recursive","writeFile","moduleName","replace","tapNodeShimContents","externals","shimDir","shimPath","existsSync"],"mappings":"AAMA;;;;QAoBgBA,uBAAuB,GAAvBA,uBAAuB;QAOjBC,kBAAkB,GAAlBA,kBAAkB;QAmBxBC,cAAc,GAAdA,cAAc;;AA9Cf,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACY,IAAA,OAAQ,WAAR,QAAQ,CAAA;AACtB,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAIhB,MAAMC,mBAAmB,GAAa;IAC3C,aAAa;OACV,CACDC,OAAc,eAAA,IACd,mBAAmB;IACnB,CAACC,OAAO,CAACC,OAAO,GAAGC,MAAM,CAACC,IAAI,CAACH,OAAO,CAACC,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,CAAC,IAChE,EAAE,CACH,CAACG,MAAM,CAAC,CAACC,CAAC,GAAK,CAAC,sCAAsCC,IAAI,CAACD,CAAC,CAAC,IAAI,CAAC;YAAC,KAAK;SAAC,CAACE,QAAQ,CAACF,CAAC,CAAC;IAAA,CAAC;CACxF,CAACG,IAAI,EAAE,AAAC;QARIV,mBAAmB,GAAnBA,mBAAmB;AAUzB,MAAMW,yBAAyB,GAAG,yBAAyB,AAAC;QAAtDA,yBAAyB,GAAzBA,yBAAyB;AAC/B,MAAMC,gCAAgC,GAAG,gCAAgC,AAAC;QAApEA,gCAAgC,GAAhCA,gCAAgC;AACtC,MAAMC,sBAAsB,GAAG,uBAAuB,AAAC;QAAjDA,sBAAsB,GAAtBA,sBAAsB;AAE5B,SAAShB,uBAAuB,CAACiB,UAAkB,EAAEC,QAAgB,EAAE;IAC5E,OAAOC,KAA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C,MAAMW,SAAS,GAA2B,EAAE,AAAC;IAC7C,KAAK,MAAMhB,QAAQ,IAAIf,mBAAmB,CAAE;QAC1C,MAAMgC,OAAO,GAAGhB,KAAI,QAAA,CAACG,IAAI,CAACC,WAAW,EAAEP,sBAAsB,EAAEE,QAAQ,CAAC,AAAC;QACzE,MAAMkB,QAAQ,GAAGjB,KAAI,QAAA,CAACG,IAAI,CAACa,OAAO,EAAE,UAAU,CAAC,AAAC;QAChDD,SAAS,CAAChB,QAAQ,CAAC,GAAGkB,QAAQ,CAAC;QAE/B,IAAI,CAACV,GAAE,QAAA,CAACW,UAAU,CAACD,QAAQ,CAAC,EAAE;YAC5B,MAAMV,GAAE,QAAA,CAACC,QAAQ,CAACC,KAAK,CAACO,OAAO,EAAE;gBAAEN,SAAS,EAAE,IAAI;aAAE,CAAC,CAAC;YACtD,MAAMH,GAAE,QAAA,CAACC,QAAQ,CAACG,SAAS,CAACM,QAAQ,EAAEH,mBAAmB,CAACf,QAAQ,CAAC,CAAC,CAAC;SACtE;KACF;CACF"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/externals.ts"],"sourcesContent":["/**\n * Copyright © 2023 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 fs from 'fs';\nimport { builtinModules } from 'module';\nimport path from 'path';\n\nimport { copyAsync } from '../../../utils/dir';\n\n// A list of the Node.js standard library modules that are currently\n// available,\nexport const NODE_STDLIB_MODULES: string[] = [\n 'fs/promises',\n ...(\n builtinModules ||\n // @ts-expect-error\n (process.binding ? Object.keys(process.binding('natives')) : []) ||\n []\n ).filter((x) => !/^_|^(internal|v8|node-inspect)\\/|\\//.test(x) && !['sys'].includes(x)),\n].sort();\n\nexport const EXTERNAL_REQUIRE_POLYFILL = '.expo/metro/polyfill.js';\nexport const EXTERNAL_REQUIRE_NATIVE_POLYFILL = '.expo/metro/polyfill.native.js';\nexport const METRO_EXTERNALS_FOLDER = '.expo/metro/externals';\nexport const METRO_SHIMS_FOLDER = '.expo/metro/shims';\n\nexport function getNodeExternalModuleId(fromModule: string, moduleId: string) {\n return path.relative(\n path.dirname(fromModule),\n path.join(METRO_EXTERNALS_FOLDER, moduleId, 'index.js')\n );\n}\n\nexport async function setupShimFiles(projectRoot: string) {\n await fs.promises.mkdir(path.join(projectRoot, METRO_SHIMS_FOLDER), { recursive: true });\n // Copy the shims to the project folder in case we're running in a monorepo.\n const shimsFolder = path.join(require.resolve('@expo/cli/package.json'), '../static/shims');\n\n await copyAsync(shimsFolder, path.join(projectRoot, METRO_SHIMS_FOLDER), {\n overwrite: false,\n recursive: true,\n });\n}\n\nexport async function setupNodeExternals(projectRoot: string) {\n await tapExternalRequirePolyfill(projectRoot);\n await tapNodeShims(projectRoot);\n}\n\nasync function tapExternalRequirePolyfill(projectRoot: string) {\n await fs.promises.mkdir(path.join(projectRoot, path.dirname(EXTERNAL_REQUIRE_POLYFILL)), {\n recursive: true,\n });\n await writeIfDifferentAsync(\n path.join(projectRoot, EXTERNAL_REQUIRE_POLYFILL),\n 'global.$$require_external = typeof window === \"undefined\" ? require : () => null;'\n );\n await writeIfDifferentAsync(\n path.join(projectRoot, EXTERNAL_REQUIRE_NATIVE_POLYFILL),\n 'global.$$require_external = (moduleId) => {throw new Error(`Node.js standard library module ${moduleId} is not available in this JavaScript environment`);}'\n );\n}\n\nasync function writeIfDifferentAsync(filePath: string, contents: string): Promise<void> {\n if (fs.existsSync(filePath)) {\n const current = await fs.promises.readFile(filePath, 'utf8');\n if (current === contents) return;\n }\n\n await fs.promises.writeFile(filePath, contents);\n}\n\nexport function isNodeExternal(moduleName: string): string | null {\n const moduleId = moduleName.replace(/^node:/, '');\n if (NODE_STDLIB_MODULES.includes(moduleId)) {\n return moduleId;\n }\n return null;\n}\n\nfunction tapNodeShimContents(moduleId: string): string {\n return `module.exports = $$require_external('node:${moduleId}');`;\n}\n\n// Ensure Node.js shims which require using `$$require_external` are available inside the project.\nasync function tapNodeShims(projectRoot: string) {\n const externals: Record<string, string> = {};\n for (const moduleId of NODE_STDLIB_MODULES) {\n const shimDir = path.join(projectRoot, METRO_EXTERNALS_FOLDER, moduleId);\n const shimPath = path.join(shimDir, 'index.js');\n externals[moduleId] = shimPath;\n\n if (!fs.existsSync(shimPath)) {\n await fs.promises.mkdir(shimDir, { recursive: true });\n await fs.promises.writeFile(shimPath, tapNodeShimContents(moduleId));\n }\n }\n}\n"],"names":["getNodeExternalModuleId","setupShimFiles","setupNodeExternals","isNodeExternal","NODE_STDLIB_MODULES","builtinModules","process","binding","Object","keys","filter","x","test","includes","sort","EXTERNAL_REQUIRE_POLYFILL","EXTERNAL_REQUIRE_NATIVE_POLYFILL","METRO_EXTERNALS_FOLDER","METRO_SHIMS_FOLDER","fromModule","moduleId","path","relative","dirname","join","projectRoot","fs","promises","mkdir","recursive","shimsFolder","require","resolve","copyAsync","overwrite","tapExternalRequirePolyfill","tapNodeShims","writeIfDifferentAsync","filePath","contents","existsSync","current","readFile","writeFile","moduleName","replace","tapNodeShimContents","externals","shimDir","shimPath"],"mappings":"AAMA;;;;QAuBgBA,uBAAuB,GAAvBA,uBAAuB;QAOjBC,cAAc,GAAdA,cAAc;QAWdC,kBAAkB,GAAlBA,kBAAkB;QA4BxBC,cAAc,GAAdA,cAAc;;AArEf,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACY,IAAA,OAAQ,WAAR,QAAQ,CAAA;AACtB,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEG,IAAA,IAAoB,WAApB,oBAAoB,CAAA;;;;;;AAIvC,MAAMC,mBAAmB,GAAa;IAC3C,aAAa;OACV,CACDC,OAAc,eAAA,IACd,mBAAmB;IACnB,CAACC,OAAO,CAACC,OAAO,GAAGC,MAAM,CAACC,IAAI,CAACH,OAAO,CAACC,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,CAAC,IAChE,EAAE,CACH,CAACG,MAAM,CAAC,CAACC,CAAC,GAAK,CAAC,sCAAsCC,IAAI,CAAC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AI,CAAC;CACb;AAED,SAAS0B,mBAAmB,CAAC1B,QAAgB,EAAU;IACrD,OAAO,CAAC,0CAA0C,EAAEA,QAAQ,CAAC,GAAG,CAAC,CAAC;CACnE;AAED,kGAAkG;AAClG,eAAegB,YAAY,CAACX,WAAmB,EAAE;IAC/C,MAAMsB,SAAS,GAA2B,EAAE,AAAC;IAC7C,KAAK,MAAM3B,QAAQ,IAAIhB,mBAAmB,CAAE;QAC1C,MAAM4C,OAAO,GAAG3B,KAAI,QAAA,CAACG,IAAI,CAACC,WAAW,EAAER,sBAAsB,EAAEG,QAAQ,CAAC,AAAC;QACzE,MAAM6B,QAAQ,GAAG5B,KAAI,QAAA,CAACG,IAAI,CAACwB,OAAO,EAAE,UAAU,CAAC,AAAC;QAChDD,SAAS,CAAC3B,QAAQ,CAAC,GAAG6B,QAAQ,CAAC;QAE/B,IAAI,CAACvB,GAAE,QAAA,CAACc,UAAU,CAACS,QAAQ,CAAC,EAAE;YAC5B,MAAMvB,GAAE,QAAA,CAACC,QAAQ,CAACC,KAAK,CAACoB,OAAO,EAAE;gBAAEnB,SAAS,EAAE,IAAI;aAAE,CAAC,CAAC;YACtD,MAAMH,GAAE,QAAA,CAACC,QAAQ,CAACgB,SAAS,CAACM,QAAQ,EAAEH,mBAAmB,CAAC1B,QAAQ,CAAC,CAAC,CAAC;SACtE;KACF;CACF"}
@@ -9,6 +9,7 @@ var _pageReload = require("./handlers/PageReload");
9
9
  var _vscodeDebuggerGetPossibleBreakpoints = require("./handlers/VscodeDebuggerGetPossibleBreakpoints");
10
10
  var _vscodeDebuggerScriptParsed = require("./handlers/VscodeDebuggerScriptParsed");
11
11
  var _vscodeDebuggerSetBreakpointByUrl = require("./handlers/VscodeDebuggerSetBreakpointByUrl");
12
+ var _vscodeRuntimeCallFunctionOn = require("./handlers/VscodeRuntimeCallFunctionOn");
12
13
  var _vscodeRuntimeGetProperties = require("./handlers/VscodeRuntimeGetProperties");
13
14
  function _interopRequireDefault(obj) {
14
15
  return obj && obj.__esModule ? obj : {
@@ -26,7 +27,8 @@ function createInspectorDeviceClass(metroBundler, MetroDeviceClass) {
26
27
  new _vscodeDebuggerGetPossibleBreakpoints.VscodeDebuggerGetPossibleBreakpointsHandler(),
27
28
  new _vscodeDebuggerScriptParsed.VscodeDebuggerScriptParsedHandler(this),
28
29
  new _vscodeDebuggerSetBreakpointByUrl.VscodeDebuggerSetBreakpointByUrlHandler(),
29
- new _vscodeRuntimeGetProperties.VscodeRuntimeGetPropertiesHandler(),
30
+ new _vscodeRuntimeGetProperties.VscodeRuntimeGetPropertiesHandler(),
31
+ new _vscodeRuntimeCallFunctionOn.VscodeRuntimeCallFunctionOnHandler(),
30
32
  ];
31
33
  onDeviceMessage(message, info) {
32
34
  var ref;