@expo/cli 54.1.0-canary-20251031-b135dff → 55.0.0-canary-20251118-8f7ee64

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 (36) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/src/api/rest/cache/ResponseCache.js +3 -1
  3. package/build/src/api/rest/cache/ResponseCache.js.map +1 -1
  4. package/build/src/export/exportStaticAsync.js +30 -2
  5. package/build/src/export/exportStaticAsync.js.map +1 -1
  6. package/build/src/export/saveAssets.js +10 -0
  7. package/build/src/export/saveAssets.js.map +1 -1
  8. package/build/src/start/platforms/android/AndroidDeviceManager.js +2 -7
  9. package/build/src/start/platforms/android/AndroidDeviceManager.js.map +1 -1
  10. package/build/src/start/platforms/android/adb.js +0 -6
  11. package/build/src/start/platforms/android/adb.js.map +1 -1
  12. package/build/src/start/server/metro/MetroBundlerDevServer.js +41 -36
  13. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  14. package/build/src/start/server/metro/createServerRouteMiddleware.js +7 -29
  15. package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
  16. package/build/src/start/server/metro/debugging/createDebugMiddleware.js +3 -1
  17. package/build/src/start/server/metro/debugging/createDebugMiddleware.js.map +1 -1
  18. package/build/src/start/server/metro/errors/FailedToResolveNativeOnlyModuleError.js +17 -0
  19. package/build/src/start/server/metro/errors/FailedToResolveNativeOnlyModuleError.js.map +1 -0
  20. package/build/src/start/server/metro/instantiateMetro.js +14 -10
  21. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  22. package/build/src/start/server/metro/resolveLoader.js +65 -0
  23. package/build/src/start/server/metro/resolveLoader.js.map +1 -0
  24. package/build/src/start/server/metro/withMetroMultiPlatform.js +6 -24
  25. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  26. package/build/src/utils/env.js +0 -3
  27. package/build/src/utils/env.js.map +1 -1
  28. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  29. package/build/src/utils/telemetry/utils/context.js +1 -1
  30. package/package.json +20 -22
  31. package/build/src/start/server/metro/createExpoMetroResolver.js +0 -265
  32. package/build/src/start/server/metro/createExpoMetroResolver.js.map +0 -1
  33. package/build/src/start/server/metro/createJResolver.js +0 -201
  34. package/build/src/start/server/metro/createJResolver.js.map +0 -1
  35. package/build/src/start/server/metro/formatFileCandidates.js +0 -84
  36. package/build/src/start/server/metro/formatFileCandidates.js.map +0 -1
@@ -83,13 +83,6 @@ function _path() {
83
83
  };
84
84
  return data;
85
85
  }
86
- function _resolvefrom() {
87
- const data = /*#__PURE__*/ _interop_require_default(require("resolve-from"));
88
- _resolvefrom = function() {
89
- return data;
90
- };
91
- return data;
92
- }
93
86
  const _createServerComponentsMiddleware = require("./createServerComponentsMiddleware");
94
87
  const _createServerRouteMiddleware = require("./createServerRouteMiddleware");
95
88
  const _fetchRouterManifest = require("./fetchRouterManifest");
@@ -106,6 +99,7 @@ const _filePath = require("../../../utils/filePath");
106
99
  const _port = require("../../../utils/port");
107
100
  const _BundlerDevServer = require("../BundlerDevServer");
108
101
  const _getStaticRenderFunctions = require("../getStaticRenderFunctions");
102
+ const _resolveLoader = require("./resolveLoader");
109
103
  const _ContextModuleSourceMapsMiddleware = require("../middleware/ContextModuleSourceMapsMiddleware");
110
104
  const _CreateFileMiddleware = require("../middleware/CreateFileMiddleware");
111
105
  const _DataLoaderModuleMiddleware = require("../middleware/DataLoaderModuleMiddleware");
@@ -246,7 +240,10 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
246
240
  debug('Adding RSC route to the manifest:', rscPath);
247
241
  // NOTE: This might need to be sorted to the correct spot in the future.
248
242
  manifest.apiRoutes.push({
249
- file: (0, _resolvefrom().default)(this.projectRoot, '@expo/cli/static/template/[...rsc]+api.ts'),
243
+ // TODO(@kitten): This isn't great, we shouldn't be needing to rely on files like this
244
+ // It might even be better to make templating strings since that'd be type-checked, but currently,
245
+ // we rely on this being an entrypoint for Metro
246
+ file: require.resolve('@expo/cli/static/template/[...rsc]+api.ts'),
250
247
  page: rscPath,
251
248
  namedRegex: '^/_flight(?:/(?<rsc>.+?))?(?:/)?$',
252
249
  routeKeys: {
@@ -324,6 +321,9 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
324
321
  * This function is invoked when exporting via `expo export`
325
322
  */ async getStaticRenderFunctionAsync() {
326
323
  var _exp_extra, _exp_extra1;
324
+ const { routerRoot } = this.instanceMetroOptions;
325
+ (0, _assert().default)(routerRoot != null, 'The server must be started before calling getStaticRenderFunctionAsync.');
326
+ const appDir = _path().default.join(this.projectRoot, routerRoot);
327
327
  const url = this.getDevServerUrlOrAssert();
328
328
  const { getStaticContent, getManifest, getBuildTimeServerManifestAsync } = await this.ssrLoadModule('@expo/router-server/node/render.js', {
329
329
  // This must always use the legacy rendering resolution (no `react-server`) because it leverages
@@ -342,8 +342,20 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
342
342
  ...(_exp_extra1 = exp.extra) == null ? void 0 : _exp_extra1.router
343
343
  }),
344
344
  // Get route generating function
345
- async renderAsync (path) {
346
- return await getStaticContent(new URL(path, url));
345
+ renderAsync: async (path, route, opts)=>{
346
+ const location = new URL(path, url);
347
+ return await getStaticContent(location, opts);
348
+ },
349
+ executeLoaderAsync: async (path, route)=>{
350
+ const location = new URL(path, url);
351
+ const resolvedLoaderRoute = (0, _resolveLoader.fromRuntimeManifestRoute)(location.pathname, route, {
352
+ serverManifest: (0, _fetchRouterManifest.inflateManifest)(serverManifest),
353
+ appDir
354
+ });
355
+ if (!resolvedLoaderRoute) {
356
+ return undefined;
357
+ }
358
+ return await this.executeServerDataLoaderAsync(location, resolvedLoaderRoute);
347
359
  }
348
360
  };
349
361
  }
@@ -407,16 +419,19 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
407
419
  });
408
420
  const location = new URL(pathname, this.getDevServerUrlOrAssert());
409
421
  const useServerDataLoaders = (_exp_extra = exp.extra) == null ? void 0 : (_exp_extra_router = _exp_extra.router) == null ? void 0 : _exp_extra_router.unstable_useServerDataLoaders;
410
- if (useServerDataLoaders) {
411
- const data = await this.executeServerDataLoaderAsync(location, route);
412
- return await getStaticContent(location, {
413
- loader: {
414
- data
415
- }
416
- });
417
- } else {
422
+ if (!useServerDataLoaders) {
418
423
  return await getStaticContent(location);
419
424
  }
425
+ const resolvedLoaderRoute = (0, _resolveLoader.fromServerManifestRoute)(location.pathname, route);
426
+ if (!resolvedLoaderRoute) {
427
+ return await getStaticContent(location);
428
+ }
429
+ const data = await this.executeServerDataLoaderAsync(location, resolvedLoaderRoute);
430
+ return await getStaticContent(location, {
431
+ loader: {
432
+ data
433
+ }
434
+ });
420
435
  };
421
436
  const [{ artifacts: resources }, staticHtml] = await Promise.all([
422
437
  this.getStaticResourcesAsync({
@@ -843,7 +858,11 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
843
858
  var _exp_extra_router1, _exp_extra2;
844
859
  if ((_exp_extra2 = exp.extra) == null ? void 0 : (_exp_extra_router1 = _exp_extra2.router) == null ? void 0 : _exp_extra_router1.unstable_useServerDataLoaders) {
845
860
  const loaderModuleMiddleware = new _DataLoaderModuleMiddleware.DataLoaderModuleMiddleware(this.projectRoot, appDir, async (location, route)=>{
846
- return this.executeServerDataLoaderAsync(location, route);
861
+ const resolvedLoaderRoute = (0, _resolveLoader.fromServerManifestRoute)(location.pathname, route);
862
+ if (!resolvedLoaderRoute) {
863
+ return;
864
+ }
865
+ return this.executeServerDataLoaderAsync(location, resolvedLoaderRoute);
847
866
  }, ()=>this.getDevServerUrlOrAssert());
848
867
  // This MUST be before ServeStaticMiddleware so it doesn't treat the loader files as static assets
849
868
  middleware.use(loaderModuleMiddleware.getHandler());
@@ -1178,27 +1197,13 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
1178
1197
  if (!unstable_useServerDataLoaders) {
1179
1198
  throw new _errors.CommandError('LOADERS_NOT_ENABLED', 'Server data loaders are not enabled. Add `unstable_useServerDataLoaders` to your `expo-router` plugin config.');
1180
1199
  }
1181
- // If the route is unmatched, we can ignore it
1182
- // TODO(@hassankhan): Is this the best way of determining the route is unmatched?
1183
- if (route.page === '/+not-found') {
1184
- return;
1185
- }
1186
1200
  const { routerRoot } = this.instanceMetroOptions;
1187
1201
  (0, _assert().default)(routerRoot != null, 'The server must be started before calling executeRouteLoaderAsync.');
1188
1202
  let loaderData;
1189
1203
  try {
1190
- debug('Matched route loader to file: ', route.file);
1191
- // TODO(@hassankhan): This should move to a util function
1192
- const params = {};
1193
- const match = route.namedRegex.exec(location.pathname);
1194
- if (match == null ? void 0 : match.groups) {
1195
- for (const [key, value] of Object.entries(match.groups)){
1196
- const namedKey = route.routeKeys[key];
1197
- params[namedKey] = value;
1198
- }
1199
- }
1200
- let modulePath = route.file;
1204
+ debug(`Matched ${location.pathname} to file: ${route.file}`);
1201
1205
  const appDir = _path().default.join(this.projectRoot, routerRoot);
1206
+ let modulePath = route.file;
1202
1207
  modulePath = _path().default.isAbsolute(modulePath) ? modulePath : _path().default.join(appDir, modulePath);
1203
1208
  modulePath = modulePath.replace(/\.(js|ts)x?$/, '');
1204
1209
  debug('Using loader module path: ', modulePath);
@@ -1209,7 +1214,7 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
1209
1214
  // Register this module for loader HMR
1210
1215
  this.setupLoaderHmr(modulePath);
1211
1216
  loaderData = await routeModule.loader({
1212
- params,
1217
+ params: route.params,
1213
1218
  // NOTE(@hassankhan): The `request` object should only be available when using SSR
1214
1219
  request: null
1215
1220
  });