@expo/cli 0.19.6 → 0.19.8

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 CHANGED
@@ -120,7 +120,7 @@ const args = (0, _arg().default)({
120
120
  });
121
121
  if (args["--version"]) {
122
122
  // Version is added in the build script.
123
- console.log("0.19.6");
123
+ console.log("0.19.8");
124
124
  process.exit(0);
125
125
  }
126
126
  if (args["--non-interactive"]) {
@@ -523,13 +523,13 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
523
523
  }
524
524
  async singlePageReactServerComponentExportAsync(options, files, extraOptions = {}) {
525
525
  // NOTE(EvanBacon): This will not support any code elimination since it's a static pass.
526
- const { reactClientReferences: clientBoundaries , reactServerReferences: serverActionReferencesInServer , cssModules , } = await this.rscRenderer.getExpoRouterClientReferencesAsync({
526
+ let { reactClientReferences: clientBoundaries , reactServerReferences: serverActionReferencesInServer , cssModules , } = await this.rscRenderer.getExpoRouterClientReferencesAsync({
527
527
  platform: options.platform
528
528
  }, files);
529
529
  // TODO: The output keys should be in production format or use a lookup manifest.
530
530
  debug("Evaluated client boundaries:", clientBoundaries);
531
531
  // Run metro bundler and create the JS bundles/source maps.
532
- const bundle = await this.legacySinglePageExportBundleAsync({
532
+ let bundle = await this.legacySinglePageExportBundleAsync({
533
533
  ...options,
534
534
  clientBoundaries
535
535
  }, extraOptions);
@@ -544,13 +544,30 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
544
544
  throw new Error("Static server action references were not returned from the Metro client bundle");
545
545
  }
546
546
  debug("React server action boundaries from client:", reactServerReferences);
547
- await this.rscRenderer.exportServerActionsAsync({
547
+ // When we export the server actions that were imported from the client, we may need to re-bundle the client with the new client boundaries.
548
+ const { clientBoundaries: nestedClientBoundaries } = await this.rscRenderer.exportServerActionsAsync({
548
549
  platform: options.platform,
549
550
  entryPoints: [
550
551
  ...serverActionReferencesInServer,
551
552
  ...reactServerReferences
552
553
  ]
553
554
  }, files);
555
+ const hasUniqueClientBoundaries = nestedClientBoundaries.some((boundary)=>!clientBoundaries.includes(boundary));
556
+ if (hasUniqueClientBoundaries) {
557
+ debug("Re-bundling client with nested client boundaries:", nestedClientBoundaries);
558
+ clientBoundaries = [
559
+ ...new Set(clientBoundaries.concat(nestedClientBoundaries))
560
+ ];
561
+ // Re-bundle the client with the new client boundaries that only exist in server actions that were imported from the client.
562
+ // Run metro bundler and create the JS bundles/source maps.
563
+ bundle = await this.legacySinglePageExportBundleAsync({
564
+ ...options,
565
+ clientBoundaries: [
566
+ ...clientBoundaries,
567
+ ...nestedClientBoundaries
568
+ ]
569
+ }, extraOptions);
570
+ }
554
571
  // Inject the global CSS that was imported during the server render.
555
572
  bundle.artifacts.push(...cssModules);
556
573
  const serverRoot = (0, _paths().getMetroServerRoot)(this.projectRoot);
@@ -651,7 +668,7 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
651
668
  }
652
669
  rscRenderer = null;
653
670
  async startImplementationAsync(options) {
654
- var ref, ref1, ref2, ref3;
671
+ var ref, ref1, ref2, ref3, ref4, ref5, ref6;
655
672
  options.port = await this.resolvePortAsync(options);
656
673
  this.urlCreator = this.getUrlCreator(options);
657
674
  const config = (0, _config().getConfig)(this.projectRoot, {
@@ -659,17 +676,18 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
659
676
  });
660
677
  const { exp } = config;
661
678
  // NOTE: This will change in the future when it's less experimental, we enable React 19, and turn on more RSC flags by default.
662
- const isReactServerComponentsEnabled = !!((ref = exp.experiments) == null ? void 0 : ref.reactServerComponents);
679
+ const isReactServerComponentsEnabled = !!((ref = exp.experiments) == null ? void 0 : ref.reactServerComponents) || !!((ref1 = exp.experiments) == null ? void 0 : ref1.reactServerActions);
680
+ const isReactServerActionsOnlyEnabled = !((ref2 = exp.experiments) == null ? void 0 : ref2.reactServerComponents) && !!((ref3 = exp.experiments) == null ? void 0 : ref3.reactServerActions);
663
681
  this.isReactServerComponentsEnabled = isReactServerComponentsEnabled;
664
682
  const useServerRendering = [
665
683
  "static",
666
684
  "server"
667
- ].includes(((ref1 = exp.web) == null ? void 0 : ref1.output) ?? "");
668
- const hasApiRoutes = isReactServerComponentsEnabled || ((ref2 = exp.web) == null ? void 0 : ref2.output) === "server";
685
+ ].includes(((ref4 = exp.web) == null ? void 0 : ref4.output) ?? "");
686
+ const hasApiRoutes = isReactServerComponentsEnabled || ((ref5 = exp.web) == null ? void 0 : ref5.output) === "server";
669
687
  const baseUrl = (0, _metroOptions.getBaseUrlFromExpoConfig)(exp);
670
688
  const asyncRoutes = (0, _metroOptions.getAsyncRoutesFromExpoConfig)(exp, options.mode ?? "development", "web");
671
689
  const routerRoot = (0, _router.getRouterDirectoryModuleIdWithManifest)(this.projectRoot, exp);
672
- const reactCompiler = !!((ref3 = exp.experiments) == null ? void 0 : ref3.reactCompiler);
690
+ const reactCompiler = !!((ref6 = exp.experiments) == null ? void 0 : ref6.reactCompiler);
673
691
  const appDir = _path().default.join(this.projectRoot, routerRoot);
674
692
  const mode = options.mode ?? "development";
675
693
  if (isReactServerComponentsEnabled && useServerRendering) {
@@ -775,7 +793,8 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
775
793
  instanceMetroOptions: this.instanceMetroOptions,
776
794
  rscPath: "/_flight",
777
795
  ssrLoadModule: this.ssrLoadModule.bind(this),
778
- ssrLoadModuleArtifacts: this.metroImportAsArtifactsAsync.bind(this)
796
+ ssrLoadModuleArtifacts: this.metroImportAsArtifactsAsync.bind(this),
797
+ useClientRouter: isReactServerActionsOnlyEnabled
779
798
  });
780
799
  this.rscRenderer = rscMiddleware;
781
800
  middleware.use(rscMiddleware.middleware);
@@ -787,12 +806,12 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
787
806
  // This MUST run last since it's the fallback.
788
807
  middleware.use(new _historyFallbackMiddleware.HistoryFallbackMiddleware(manifestMiddleware.getHandler().internal).getHandler());
789
808
  } else {
790
- var ref4;
809
+ var ref7;
791
810
  middleware.use((0, _createServerRouteMiddleware.createRouteHandlerMiddleware)(this.projectRoot, {
792
811
  appDir,
793
812
  routerRoot,
794
813
  config,
795
- ...(ref4 = config.exp.extra) == null ? void 0 : ref4.router,
814
+ ...(ref7 = config.exp.extra) == null ? void 0 : ref7.router,
796
815
  bundleApiRoute: (functionFilePath)=>this.ssrImportApiRoute(functionFilePath, {
797
816
  platform: "web"
798
817
  }),
@@ -810,7 +829,8 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
810
829
  instanceMetroOptions: this.instanceMetroOptions,
811
830
  rscPath: "/_flight",
812
831
  ssrLoadModule: this.ssrLoadModule.bind(this),
813
- ssrLoadModuleArtifacts: this.metroImportAsArtifactsAsync.bind(this)
832
+ ssrLoadModuleArtifacts: this.metroImportAsArtifactsAsync.bind(this),
833
+ useClientRouter: isReactServerActionsOnlyEnabled
814
834
  });
815
835
  this.rscRenderer = rscMiddleware1;
816
836
  }