astro 4.11.6 → 4.12.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 (100) hide show
  1. package/client.d.ts +1 -0
  2. package/components/Code.astro +12 -0
  3. package/dist/@types/astro.d.ts +154 -74
  4. package/dist/actions/index.d.ts +4 -1
  5. package/dist/actions/index.js +15 -10
  6. package/dist/assets/internal.js +5 -12
  7. package/dist/assets/utils/index.d.ts +2 -1
  8. package/dist/assets/utils/index.js +3 -1
  9. package/dist/assets/utils/{emitAsset.d.ts → node/emitAsset.d.ts} +1 -1
  10. package/dist/assets/utils/{emitAsset.js → node/emitAsset.js} +2 -2
  11. package/dist/assets/utils/remoteProbe.d.ts +2 -2
  12. package/dist/assets/utils/remoteProbe.js +13 -6
  13. package/dist/assets/vite-plugin-assets.js +2 -1
  14. package/dist/cli/check/index.js +7 -5
  15. package/dist/cli/sync/index.d.ts +1 -1
  16. package/dist/cli/sync/index.js +6 -3
  17. package/dist/container/index.js +3 -1
  18. package/dist/content/runtime-assets.js +1 -1
  19. package/dist/content/vite-plugin-content-virtual-mod.js +4 -8
  20. package/dist/core/app/common.js +3 -1
  21. package/dist/core/app/index.js +3 -2
  22. package/dist/core/app/pipeline.d.ts +1 -1
  23. package/dist/core/app/pipeline.js +11 -11
  24. package/dist/core/app/types.d.ts +6 -2
  25. package/dist/core/base-pipeline.d.ts +21 -1
  26. package/dist/core/base-pipeline.js +3 -1
  27. package/dist/core/build/generate.js +1 -0
  28. package/dist/core/build/index.js +10 -6
  29. package/dist/core/build/pipeline.d.ts +6 -0
  30. package/dist/core/build/pipeline.js +11 -8
  31. package/dist/core/build/plugins/plugin-manifest.js +3 -1
  32. package/dist/core/build/plugins/plugin-ssr.js +8 -4
  33. package/dist/core/build/static-build.js +5 -5
  34. package/dist/core/config/schema.d.ts +37 -0
  35. package/dist/core/config/schema.js +5 -2
  36. package/dist/core/config/settings.js +2 -0
  37. package/dist/core/constants.d.ts +7 -0
  38. package/dist/core/constants.js +5 -1
  39. package/dist/core/create-vite.js +2 -2
  40. package/dist/core/dev/container.js +8 -0
  41. package/dist/core/dev/dev.js +1 -1
  42. package/dist/core/errors/dev/vite.js +1 -2
  43. package/dist/core/errors/errors-data.d.ts +2 -10
  44. package/dist/core/errors/errors-data.js +0 -6
  45. package/dist/core/errors/overlay.js +6 -7
  46. package/dist/core/index.d.ts +1 -1
  47. package/dist/core/index.js +1 -1
  48. package/dist/core/messages.js +2 -2
  49. package/dist/core/middleware/callMiddleware.js +6 -6
  50. package/dist/core/redirects/render.js +1 -2
  51. package/dist/core/render/paginate.js +8 -1
  52. package/dist/core/render-context.js +8 -1
  53. package/dist/core/routing/astro-designed-error-pages.d.ts +2 -7
  54. package/dist/core/routing/astro-designed-error-pages.js +4 -1
  55. package/dist/core/routing/default.d.ts +10 -0
  56. package/dist/core/routing/default.js +38 -0
  57. package/dist/core/routing/manifest/create.d.ts +1 -2
  58. package/dist/core/routing/manifest/create.js +2 -34
  59. package/dist/core/routing/manifest/pattern.d.ts +2 -0
  60. package/dist/core/routing/manifest/pattern.js +35 -0
  61. package/dist/core/server-islands/endpoint.d.ts +8 -0
  62. package/dist/core/server-islands/endpoint.js +76 -0
  63. package/dist/core/server-islands/vite-plugin-server-islands.d.ts +7 -0
  64. package/dist/core/server-islands/vite-plugin-server-islands.js +82 -0
  65. package/dist/core/sync/index.d.ts +13 -5
  66. package/dist/core/sync/index.js +36 -23
  67. package/dist/core/sync/setup-env-ts.d.ts +8 -0
  68. package/dist/{vite-plugin-inject-env-ts/index.js → core/sync/setup-env-ts.js} +11 -28
  69. package/dist/env/errors.d.ts +7 -0
  70. package/dist/env/errors.js +16 -0
  71. package/dist/env/runtime.d.ts +4 -3
  72. package/dist/env/runtime.js +9 -5
  73. package/dist/env/validators.d.ts +5 -3
  74. package/dist/env/vite-plugin-env.js +2 -11
  75. package/dist/integrations/hooks.d.ts +3 -1
  76. package/dist/integrations/hooks.js +5 -4
  77. package/dist/jsx/babel.js +6 -8
  78. package/dist/jsx/rehype.js +4 -8
  79. package/dist/jsx-runtime/index.js +1 -2
  80. package/dist/runtime/client/dev-toolbar/entrypoint.js +3 -2
  81. package/dist/runtime/server/render/component.d.ts +2 -1
  82. package/dist/runtime/server/render/component.js +4 -0
  83. package/dist/runtime/server/render/server-islands.d.ts +5 -0
  84. package/dist/runtime/server/render/server-islands.js +73 -0
  85. package/dist/runtime/server/render/slot.d.ts +2 -1
  86. package/dist/runtime/server/render/slot.js +8 -1
  87. package/dist/vite-plugin-astro/index.js +3 -1
  88. package/dist/vite-plugin-astro/metadata.d.ts +1 -0
  89. package/dist/vite-plugin-astro/metadata.js +12 -0
  90. package/dist/vite-plugin-astro/types.d.ts +1 -0
  91. package/dist/vite-plugin-astro-server/pipeline.d.ts +7 -0
  92. package/dist/vite-plugin-astro-server/pipeline.js +20 -5
  93. package/dist/vite-plugin-astro-server/plugin.js +5 -3
  94. package/dist/vite-plugin-astro-server/route.js +13 -14
  95. package/dist/vite-plugin-markdown/index.js +2 -8
  96. package/dist/vite-plugin-utils/index.d.ts +5 -0
  97. package/dist/vite-plugin-utils/index.js +5 -0
  98. package/package.json +5 -4
  99. package/templates/env/module.mjs +5 -2
  100. package/dist/vite-plugin-inject-env-ts/index.d.ts +0 -17
@@ -13,6 +13,7 @@ function deserializeManifest(serializedManifest) {
13
13
  const componentMetadata = new Map(serializedManifest.componentMetadata);
14
14
  const inlinedScripts = new Map(serializedManifest.inlinedScripts);
15
15
  const clientDirectives = new Map(serializedManifest.clientDirectives);
16
+ const serverIslandNameMap = new Map(serializedManifest.serverIslandNameMap);
16
17
  return {
17
18
  // in case user middleware exists, this no-op middleware will be reassigned (see plugin-ssr.ts)
18
19
  middleware(_, next) {
@@ -23,7 +24,8 @@ function deserializeManifest(serializedManifest) {
23
24
  componentMetadata,
24
25
  inlinedScripts,
25
26
  clientDirectives,
26
- routes
27
+ routes,
28
+ serverIslandNameMap
27
29
  };
28
30
  }
29
31
  export {
@@ -19,7 +19,7 @@ import {
19
19
  } from "../path.js";
20
20
  import { RenderContext } from "../render-context.js";
21
21
  import { createAssetLink } from "../render/ssr-element.js";
22
- import { ensure404Route } from "../routing/astro-designed-error-pages.js";
22
+ import { createDefaultRoutes, injectDefaultRoutes } from "../routing/default.js";
23
23
  import { matchRoute } from "../routing/match.js";
24
24
  import { createOriginCheckMiddleware } from "./middlewares.js";
25
25
  import { AppPipeline } from "./pipeline.js";
@@ -37,7 +37,7 @@ class App {
37
37
  #renderOptionsDeprecationWarningShown = false;
38
38
  constructor(manifest, streaming = true) {
39
39
  this.#manifest = manifest;
40
- this.#manifestData = ensure404Route({
40
+ this.#manifestData = injectDefaultRoutes(manifest, {
41
41
  routes: manifest.routes.map((route) => route.routeData)
42
42
  });
43
43
  this.#baseWithoutTrailingSlash = removeTrailingForwardSlash(this.#manifest.base);
@@ -69,6 +69,7 @@ class App {
69
69
  manifest: this.#manifest,
70
70
  mode: "production",
71
71
  renderers: this.#manifest.renderers,
72
+ defaultRoutes: createDefaultRoutes(this.#manifest),
72
73
  resolve: async (specifier) => {
73
74
  if (!(specifier in this.#manifest.entryModules)) {
74
75
  throw new Error(`Unable to resolve [${specifier}]`);
@@ -3,7 +3,7 @@ import { Pipeline } from '../base-pipeline.js';
3
3
  import type { SinglePageBuiltModule } from '../build/types.js';
4
4
  export declare class AppPipeline extends Pipeline {
5
5
  #private;
6
- static create(manifestData: ManifestData, { logger, manifest, mode, renderers, resolve, serverLike, streaming, }: Pick<AppPipeline, 'logger' | 'manifest' | 'mode' | 'renderers' | 'resolve' | 'serverLike' | 'streaming'>): AppPipeline;
6
+ static create(manifestData: ManifestData, { logger, manifest, mode, renderers, resolve, serverLike, streaming, defaultRoutes, }: Pick<AppPipeline, 'logger' | 'manifest' | 'mode' | 'renderers' | 'resolve' | 'serverLike' | 'streaming' | 'defaultRoutes'>): AppPipeline;
7
7
  headElements(routeData: RouteData): Pick<SSRResult, 'scripts' | 'styles' | 'links'>;
8
8
  componentMetadata(): void;
9
9
  getComponentByRoute(routeData: RouteData): Promise<ComponentInstance>;
@@ -1,10 +1,6 @@
1
1
  import { Pipeline } from "../base-pipeline.js";
2
- import { DEFAULT_404_COMPONENT } from "../constants.js";
3
- import { RewriteEncounteredAnError } from "../errors/errors-data.js";
4
- import { AstroError } from "../errors/index.js";
5
2
  import { RedirectSinglePageBuiltModule } from "../redirects/component.js";
6
3
  import { createModuleScriptElement, createStylesheetElementSet } from "../render/ssr-element.js";
7
- import { DEFAULT_404_ROUTE } from "../routing/astro-designed-error-pages.js";
8
4
  import { findRouteToRewrite } from "../routing/rewrite.js";
9
5
  class AppPipeline extends Pipeline {
10
6
  #manifestData;
@@ -15,7 +11,8 @@ class AppPipeline extends Pipeline {
15
11
  renderers,
16
12
  resolve,
17
13
  serverLike,
18
- streaming
14
+ streaming,
15
+ defaultRoutes
19
16
  }) {
20
17
  const pipeline = new AppPipeline(
21
18
  logger,
@@ -33,7 +30,8 @@ class AppPipeline extends Pipeline {
33
30
  void 0,
34
31
  void 0,
35
32
  void 0,
36
- false
33
+ false,
34
+ defaultRoutes
37
35
  );
38
36
  pipeline.#manifestData = manifestData;
39
37
  return pipeline;
@@ -76,11 +74,13 @@ class AppPipeline extends Pipeline {
76
74
  return [foundRoute, componentInstance, finalUrl];
77
75
  }
78
76
  async getModuleForRoute(route) {
79
- if (route.component === DEFAULT_404_COMPONENT) {
80
- return {
81
- page: async () => ({ default: () => new Response(null, { status: 404 }) }),
82
- renderers: []
83
- };
77
+ for (const defaultRoute of this.defaultRoutes) {
78
+ if (route.component === defaultRoute.component) {
79
+ return {
80
+ page: () => Promise.resolve(defaultRoute.instance),
81
+ renderers: []
82
+ };
83
+ }
84
84
  }
85
85
  if (route.type === "redirect") {
86
86
  return RedirectSinglePageBuiltModule;
@@ -1,4 +1,4 @@
1
- import type { Locales, MiddlewareHandler, RouteData, SSRComponentMetadata, SSRLoadedRenderer, SSRResult, SerializedRouteData } from '../../@types/astro.js';
1
+ import type { ComponentInstance, Locales, MiddlewareHandler, RouteData, SSRComponentMetadata, SSRLoadedRenderer, SSRResult, SerializedRouteData } from '../../@types/astro.js';
2
2
  import type { RoutingStrategies } from '../../i18n/utils.js';
3
3
  import type { SinglePageBuiltModule } from '../build/types.js';
4
4
  export type ComponentPath = string;
@@ -30,6 +30,7 @@ export type AssetsPrefix = string | ({
30
30
  fallback: string;
31
31
  } & Record<string, string>) | undefined;
32
32
  export type SSRManifest = {
33
+ hrefRoot: string;
33
34
  adapterName: string;
34
35
  routes: RouteInfo[];
35
36
  site?: string;
@@ -49,6 +50,8 @@ export type SSRManifest = {
49
50
  componentMetadata: SSRResult['componentMetadata'];
50
51
  pageModule?: SinglePageBuiltModule;
51
52
  pageMap?: Map<ComponentPath, ImportComponentInstance>;
53
+ serverIslandMap?: Map<string, () => Promise<ComponentInstance>>;
54
+ serverIslandNameMap?: Map<string, string>;
52
55
  i18n: SSRManifestI18n | undefined;
53
56
  middleware: MiddlewareHandler;
54
57
  checkOrigin: boolean;
@@ -62,10 +65,11 @@ export type SSRManifestI18n = {
62
65
  defaultLocale: string;
63
66
  domainLookupTable: Record<string, string>;
64
67
  };
65
- export type SerializedSSRManifest = Omit<SSRManifest, 'middleware' | 'routes' | 'assets' | 'componentMetadata' | 'inlinedScripts' | 'clientDirectives'> & {
68
+ export type SerializedSSRManifest = Omit<SSRManifest, 'middleware' | 'routes' | 'assets' | 'componentMetadata' | 'inlinedScripts' | 'clientDirectives' | 'serverIslandNameMap'> & {
66
69
  routes: SerializedRouteInfo[];
67
70
  assets: string[];
68
71
  componentMetadata: [string, SSRComponentMetadata][];
69
72
  inlinedScripts: [string, string][];
70
73
  clientDirectives: [string, string][];
74
+ serverIslandNameMap: [string, string][];
71
75
  };
@@ -36,6 +36,16 @@ export declare abstract class Pipeline {
36
36
  */
37
37
  readonly site: URL | undefined;
38
38
  readonly callSetGetEnv: boolean;
39
+ /**
40
+ * Array of built-in, internal, routes.
41
+ * Used to find the route module
42
+ */
43
+ readonly defaultRoutes: {
44
+ instance: ComponentInstance;
45
+ matchesComponent(filePath: URL): boolean;
46
+ route: string;
47
+ component: string;
48
+ }[];
39
49
  readonly internalMiddleware: MiddlewareHandler[];
40
50
  constructor(logger: Logger, manifest: SSRManifest,
41
51
  /**
@@ -53,7 +63,17 @@ export declare abstract class Pipeline {
53
63
  /**
54
64
  * Used for `Astro.site`.
55
65
  */
56
- site?: URL | undefined, callSetGetEnv?: boolean);
66
+ site?: URL | undefined, callSetGetEnv?: boolean,
67
+ /**
68
+ * Array of built-in, internal, routes.
69
+ * Used to find the route module
70
+ */
71
+ defaultRoutes?: {
72
+ instance: ComponentInstance;
73
+ matchesComponent(filePath: URL): boolean;
74
+ route: string;
75
+ component: string;
76
+ }[]);
57
77
  abstract headElements(routeData: RouteData): Promise<HeadElements> | HeadElements;
58
78
  abstract componentMetadata(routeData: RouteData): Promise<SSRResult['componentMetadata']> | void;
59
79
  /**
@@ -3,8 +3,9 @@ import { createI18nMiddleware } from "../i18n/middleware.js";
3
3
  import { AstroError } from "./errors/errors.js";
4
4
  import { AstroErrorData } from "./errors/index.js";
5
5
  import { RouteCache } from "./render/route-cache.js";
6
+ import { createDefaultRoutes } from "./routing/default.js";
6
7
  class Pipeline {
7
- constructor(logger, manifest, mode, renderers, resolve, serverLike, streaming, adapterName = manifest.adapterName, clientDirectives = manifest.clientDirectives, inlinedScripts = manifest.inlinedScripts, compressHTML = manifest.compressHTML, i18n = manifest.i18n, middleware = manifest.middleware, routeCache = new RouteCache(logger, mode), site = manifest.site ? new URL(manifest.site) : void 0, callSetGetEnv = true) {
8
+ constructor(logger, manifest, mode, renderers, resolve, serverLike, streaming, adapterName = manifest.adapterName, clientDirectives = manifest.clientDirectives, inlinedScripts = manifest.inlinedScripts, compressHTML = manifest.compressHTML, i18n = manifest.i18n, middleware = manifest.middleware, routeCache = new RouteCache(logger, mode), site = manifest.site ? new URL(manifest.site) : void 0, callSetGetEnv = true, defaultRoutes = createDefaultRoutes(manifest)) {
8
9
  this.logger = logger;
9
10
  this.manifest = manifest;
10
11
  this.mode = mode;
@@ -21,6 +22,7 @@ class Pipeline {
21
22
  this.routeCache = routeCache;
22
23
  this.site = site;
23
24
  this.callSetGetEnv = callSetGetEnv;
25
+ this.defaultRoutes = defaultRoutes;
24
26
  this.internalMiddleware = [];
25
27
  if (i18n?.strategy !== "manual") {
26
28
  this.internalMiddleware.push(
@@ -381,6 +381,7 @@ function createBuildManifest(settings, internals, renderers, middleware) {
381
381
  };
382
382
  }
383
383
  return {
384
+ hrefRoot: settings.config.root.toString(),
384
385
  trailingSlash: settings.config.trailingSlash,
385
386
  assets: /* @__PURE__ */ new Set(),
386
387
  entryModules: Object.fromEntries(internals.entrySpecifierToBundleMap.entries()),
@@ -18,6 +18,7 @@ import { createVite } from "../create-vite.js";
18
18
  import { levels, timerMessage } from "../logger/core.js";
19
19
  import { apply as applyPolyfill } from "../polyfill.js";
20
20
  import { createRouteManifest } from "../routing/index.js";
21
+ import { getServerIslandRouteData } from "../server-islands/endpoint.js";
21
22
  import { ensureProcessNodeEnv, isServerLikeOutput } from "../util.js";
22
23
  import { collectPagesData } from "./page-data.js";
23
24
  import { staticBuild, viteBuild } from "./static-build.js";
@@ -88,11 +89,12 @@ class AstroBuilder {
88
89
  { settings: this.settings, logger: this.logger, mode: "build", command: "build", sync: false }
89
90
  );
90
91
  await runHookConfigDone({ settings: this.settings, logger });
91
- const { syncContentCollections } = await import("../sync/index.js");
92
- const syncRet = await syncContentCollections(this.settings, { logger, fs });
93
- if (syncRet !== 0) {
94
- return process.exit(syncRet);
95
- }
92
+ const { syncInternal } = await import("../sync/index.js");
93
+ await syncInternal({
94
+ settings: this.settings,
95
+ logger,
96
+ fs
97
+ });
96
98
  return { viteConfig };
97
99
  }
98
100
  /** Run the build logic. build() is marked private because usage should go through ".run()" */
@@ -143,7 +145,9 @@ class AstroBuilder {
143
145
  await runHookBuildDone({
144
146
  config: this.settings.config,
145
147
  pages: pageNames,
146
- routes: Object.values(allPages).flat().map((pageData) => pageData.route),
148
+ routes: Object.values(allPages).flat().map((pageData) => pageData.route).concat(
149
+ this.settings.config.experimental.serverIslands ? [getServerIslandRouteData(this.settings.config)] : []
150
+ ),
147
151
  logging: this.logger,
148
152
  cacheManifest: internals.cacheManifestUsed
149
153
  });
@@ -13,6 +13,12 @@ export declare class BuildPipeline extends Pipeline {
13
13
  readonly options: StaticBuildOptions;
14
14
  readonly config: import("../../@types/astro.js").AstroConfig;
15
15
  readonly settings: import("../../@types/astro.js").AstroSettings;
16
+ readonly defaultRoutes: {
17
+ instance: ComponentInstance;
18
+ matchesComponent(filePath: URL): boolean;
19
+ route: string;
20
+ component: string;
21
+ }[];
16
22
  get outFolder(): URL;
17
23
  private constructor();
18
24
  static create({ internals, manifest, options, }: Pick<BuildPipeline, 'internals' | 'manifest' | 'options'>): BuildPipeline;
@@ -9,7 +9,7 @@ import {
9
9
  createModuleScriptsSet,
10
10
  createStylesheetElementSet
11
11
  } from "../render/ssr-element.js";
12
- import { default404Page } from "../routing/astro-designed-error-pages.js";
12
+ import { createDefaultRoutes } from "../routing/default.js";
13
13
  import { findRouteToRewrite } from "../routing/rewrite.js";
14
14
  import { isServerLikeOutput } from "../util.js";
15
15
  import { getOutDirWithinCwd } from "./common.js";
@@ -19,7 +19,7 @@ import { RESOLVED_SPLIT_MODULE_ID } from "./plugins/plugin-ssr.js";
19
19
  import { getPagesFromVirtualModulePageName, getVirtualModulePageName } from "./plugins/util.js";
20
20
  import { i18nHasFallback } from "./util.js";
21
21
  class BuildPipeline extends Pipeline {
22
- constructor(internals, manifest, options, config = options.settings.config, settings = options.settings) {
22
+ constructor(internals, manifest, options, config = options.settings.config, settings = options.settings, defaultRoutes = createDefaultRoutes(manifest)) {
23
23
  const resolveCache = /* @__PURE__ */ new Map();
24
24
  async function resolve(specifier) {
25
25
  if (resolveCache.has(specifier)) {
@@ -53,6 +53,7 @@ class BuildPipeline extends Pipeline {
53
53
  this.options = options;
54
54
  this.config = config;
55
55
  this.settings = settings;
56
+ this.defaultRoutes = defaultRoutes;
56
57
  }
57
58
  #componentsInterner = /* @__PURE__ */ new WeakMap();
58
59
  /**
@@ -201,13 +202,15 @@ class BuildPipeline extends Pipeline {
201
202
  if (this.#componentsInterner.has(routeData)) {
202
203
  const entry = this.#componentsInterner.get(routeData);
203
204
  return await entry.page();
204
- } else if (routeData.component === DEFAULT_404_COMPONENT) {
205
- return { default: default404Page };
206
- } else {
207
- const filePath = this.#routesByFilePath.get(routeData);
208
- const module = await this.retrieveSsrEntry(routeData, filePath);
209
- return module.page();
210
205
  }
206
+ for (const route of this.defaultRoutes) {
207
+ if (route.component === routeData.component) {
208
+ return route.instance;
209
+ }
210
+ }
211
+ const filePath = this.#routesByFilePath.get(routeData);
212
+ const module = await this.retrieveSsrEntry(routeData, filePath);
213
+ return module.page();
211
214
  }
212
215
  async tryRewrite(payload, request, _sourceRoute) {
213
216
  const [foundRoute, finalUrl] = findRouteToRewrite({
@@ -15,7 +15,7 @@ const manifestReplace = "@@ASTRO_MANIFEST_REPLACE@@";
15
15
  const replaceExp = new RegExp(`['"]${manifestReplace}['"]`, "g");
16
16
  const SSR_MANIFEST_VIRTUAL_MODULE_ID = "@astrojs-manifest";
17
17
  const RESOLVED_SSR_MANIFEST_VIRTUAL_MODULE_ID = "\0" + SSR_MANIFEST_VIRTUAL_MODULE_ID;
18
- function vitePluginManifest(options, internals) {
18
+ function vitePluginManifest(_options, internals) {
19
19
  return {
20
20
  name: "@astro/plugin-build-manifest",
21
21
  enforce: "post",
@@ -196,6 +196,7 @@ function buildManifest(opts, internals, staticFiles) {
196
196
  };
197
197
  }
198
198
  return {
199
+ hrefRoot: opts.settings.config.root.toString(),
199
200
  adapterName: opts.settings.adapter?.name ?? "",
200
201
  routes,
201
202
  site: settings.config.site,
@@ -213,6 +214,7 @@ function buildManifest(opts, internals, staticFiles) {
213
214
  buildFormat: settings.config.build.format,
214
215
  checkOrigin: settings.config.security?.checkOrigin ?? false,
215
216
  rewritingEnabled: settings.config.experimental.rewriting,
217
+ serverIslandNameMap: Array.from(settings.serverIslandNameMap),
216
218
  experimentalEnvGetSecretEnabled: settings.config.experimental.env !== void 0 && (settings.adapter?.supportedAstroFeatures.envGetSecret ?? "unsupported") !== "unsupported"
217
219
  };
218
220
  }
@@ -2,6 +2,7 @@ import { join } from "node:path";
2
2
  import { fileURLToPath, pathToFileURL } from "node:url";
3
3
  import { isFunctionPerRouteEnabled } from "../../../integrations/hooks.js";
4
4
  import { routeIsRedirect } from "../../redirects/index.js";
5
+ import { VIRTUAL_ISLAND_MAP_ID } from "../../server-islands/vite-plugin-server-islands.js";
5
6
  import { isServerLikeOutput } from "../../util.js";
6
7
  import { addRollupInput } from "../add-rollup-input.js";
7
8
  import { SSR_MANIFEST_VIRTUAL_MODULE_ID } from "./plugin-manifest.js";
@@ -63,7 +64,7 @@ function vitePluginSSR(internals, adapter, options) {
63
64
  ]);`);
64
65
  exports.push(`export { pageMap }`);
65
66
  const middleware = await this.resolve(MIDDLEWARE_MODULE_ID);
66
- const ssrCode = generateSSRCode(adapter, middleware.id);
67
+ const ssrCode = generateSSRCode(options.settings, adapter, middleware.id);
67
68
  imports.push(...ssrCode.imports);
68
69
  contents.push(...ssrCode.contents);
69
70
  return [...imports, ...contents, ...exports].join("\n");
@@ -147,7 +148,7 @@ function vitePluginSSRSplit(internals, adapter, options) {
147
148
  imports.push(`import * as pageModule from "${virtualModuleName}";`);
148
149
  }
149
150
  const middleware = await this.resolve(MIDDLEWARE_MODULE_ID);
150
- const ssrCode = generateSSRCode(adapter, middleware.id);
151
+ const ssrCode = generateSSRCode(options.settings, adapter, middleware.id);
151
152
  imports.push(...ssrCode.imports);
152
153
  contents.push(...ssrCode.contents);
153
154
  exports.push("export { pageModule }");
@@ -190,19 +191,22 @@ function pluginSSRSplit(options, internals) {
190
191
  }
191
192
  };
192
193
  }
193
- function generateSSRCode(adapter, middlewareId) {
194
+ function generateSSRCode(settings, adapter, middlewareId) {
194
195
  const edgeMiddleware = adapter?.adapterFeatures?.edgeMiddleware ?? false;
195
196
  const pageMap = isFunctionPerRouteEnabled(adapter) ? "pageModule" : "pageMap";
196
197
  const imports = [
197
198
  `import { renderers } from '${RENDERERS_MODULE_ID}';`,
198
199
  `import { manifest as defaultManifest } from '${SSR_MANIFEST_VIRTUAL_MODULE_ID}';`,
199
200
  `import * as serverEntrypointModule from '${adapter.serverEntrypoint}';`,
200
- edgeMiddleware ? `` : `import { onRequest as middleware } from '${middlewareId}';`
201
+ edgeMiddleware ? `` : `import { onRequest as middleware } from '${middlewareId}';`,
202
+ settings.config.experimental.serverIslands ? `import { serverIslandMap } from '${VIRTUAL_ISLAND_MAP_ID}';` : ""
201
203
  ];
202
204
  const contents = [
205
+ settings.config.experimental.serverIslands ? "" : `const serverIslandMap = new Map()`,
203
206
  edgeMiddleware ? `const middleware = (_, next) => next()` : "",
204
207
  `const _manifest = Object.assign(defaultManifest, {`,
205
208
  ` ${pageMap},`,
209
+ ` serverIslandMap,`,
206
210
  ` renderers,`,
207
211
  ` middleware`,
208
212
  `});`,
@@ -164,11 +164,11 @@ async function ssrBuild(opts, internals, input, container, logger) {
164
164
  if (isContentCache) {
165
165
  prefix += `${buildID}/`;
166
166
  suffix = ".mjs";
167
- }
168
- if (isContentCache && name.includes("/content/")) {
169
- const parts = name.split("/");
170
- if (parts.at(1) === "content") {
171
- return encodeName(parts.slice(1).join("/"));
167
+ if (name.includes("/content/")) {
168
+ const parts = name.split("/");
169
+ if (parts.at(1) === "content") {
170
+ return encodeName(parts.slice(1).join("/"));
171
+ }
172
172
  }
173
173
  }
174
174
  if (name.includes(ASTRO_PAGE_EXTENSION_POST_PATTERN)) {