astro 4.13.3 → 4.14.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 (107) hide show
  1. package/components/Code.astro +9 -0
  2. package/dist/@types/astro.d.ts +251 -2
  3. package/dist/actions/consts.d.ts +1 -1
  4. package/dist/actions/consts.js +1 -1
  5. package/dist/actions/index.js +12 -21
  6. package/dist/actions/runtime/virtual/server.js +9 -3
  7. package/dist/actions/runtime/virtual/shared.js +25 -3
  8. package/dist/assets/utils/resolveImports.d.ts +9 -0
  9. package/dist/assets/utils/resolveImports.js +22 -0
  10. package/dist/cli/add/index.d.ts +2 -2
  11. package/dist/cli/add/index.js +2 -2
  12. package/dist/cli/build/index.d.ts +2 -2
  13. package/dist/cli/build/index.js +5 -1
  14. package/dist/cli/check/index.d.ts +2 -2
  15. package/dist/cli/check/index.js +5 -2
  16. package/dist/cli/db/index.d.ts +4 -3
  17. package/dist/cli/db/index.js +10 -3
  18. package/dist/cli/dev/index.d.ts +2 -2
  19. package/dist/cli/dev/index.js +1 -0
  20. package/dist/cli/docs/index.d.ts +2 -2
  21. package/dist/cli/flags.d.ts +3 -1
  22. package/dist/cli/flags.js +2 -1
  23. package/dist/cli/index.d.ts +1 -1
  24. package/dist/cli/index.js +26 -13
  25. package/dist/cli/info/index.d.ts +2 -2
  26. package/dist/cli/preferences/index.d.ts +2 -2
  27. package/dist/cli/preferences/index.js +1 -1
  28. package/dist/cli/preview/index.d.ts +2 -2
  29. package/dist/cli/sync/index.d.ts +2 -2
  30. package/dist/cli/sync/index.js +5 -2
  31. package/dist/cli/telemetry/index.d.ts +2 -2
  32. package/dist/container/index.js +3 -1
  33. package/dist/content/consts.d.ts +16 -2
  34. package/dist/content/consts.js +32 -2
  35. package/dist/content/content-layer.d.ts +40 -0
  36. package/dist/content/content-layer.js +253 -0
  37. package/dist/content/data-store.d.ts +114 -0
  38. package/dist/content/data-store.js +323 -0
  39. package/dist/content/loaders/file.d.ts +7 -0
  40. package/dist/content/loaders/file.js +72 -0
  41. package/dist/content/loaders/glob.d.ts +25 -0
  42. package/dist/content/loaders/glob.js +218 -0
  43. package/dist/content/loaders/index.d.ts +3 -0
  44. package/dist/content/loaders/index.js +7 -0
  45. package/dist/content/loaders/types.d.ts +36 -0
  46. package/dist/content/loaders/types.js +0 -0
  47. package/dist/content/runtime.d.ts +46 -8
  48. package/dist/content/runtime.js +225 -31
  49. package/dist/content/types-generator.js +125 -35
  50. package/dist/content/utils.d.ts +306 -2
  51. package/dist/content/utils.js +93 -7
  52. package/dist/content/vite-plugin-content-assets.js +9 -1
  53. package/dist/content/vite-plugin-content-virtual-mod.js +94 -2
  54. package/dist/core/app/common.js +4 -1
  55. package/dist/core/app/index.js +5 -3
  56. package/dist/core/app/types.d.ts +3 -1
  57. package/dist/core/build/generate.js +4 -2
  58. package/dist/core/build/index.js +17 -8
  59. package/dist/core/build/plugins/plugin-manifest.js +5 -2
  60. package/dist/core/build/plugins/plugin-ssr.js +35 -3
  61. package/dist/core/build/static-build.js +2 -0
  62. package/dist/core/build/types.d.ts +1 -0
  63. package/dist/core/config/config.d.ts +2 -5
  64. package/dist/core/config/config.js +0 -12
  65. package/dist/core/config/index.d.ts +1 -1
  66. package/dist/core/config/index.js +0 -2
  67. package/dist/core/config/schema.d.ts +34 -0
  68. package/dist/core/config/schema.js +6 -2
  69. package/dist/core/config/settings.js +5 -3
  70. package/dist/core/constants.js +1 -1
  71. package/dist/core/create-vite.js +1 -1
  72. package/dist/core/dev/container.js +2 -1
  73. package/dist/core/dev/dev.js +34 -2
  74. package/dist/core/dev/restart.js +25 -10
  75. package/dist/core/encryption.d.ts +24 -0
  76. package/dist/core/encryption.js +64 -0
  77. package/dist/core/errors/errors-data.d.ts +21 -0
  78. package/dist/core/errors/errors-data.js +13 -0
  79. package/dist/core/index.js +1 -1
  80. package/dist/core/messages.js +2 -2
  81. package/dist/core/render-context.js +1 -0
  82. package/dist/core/server-islands/endpoint.js +5 -1
  83. package/dist/core/sync/constants.d.ts +1 -0
  84. package/dist/core/sync/constants.js +4 -0
  85. package/dist/core/sync/index.d.ts +12 -4
  86. package/dist/core/sync/index.js +56 -25
  87. package/dist/core/sync/write-files.d.ts +4 -0
  88. package/dist/core/sync/write-files.js +69 -0
  89. package/dist/core/util.js +1 -1
  90. package/dist/env/sync.js +6 -4
  91. package/dist/integrations/hooks.d.ts +7 -1
  92. package/dist/integrations/hooks.js +54 -0
  93. package/dist/preferences/index.d.ts +1 -1
  94. package/dist/preferences/index.js +2 -2
  95. package/dist/runtime/server/render/server-islands.js +9 -5
  96. package/dist/vite-plugin-astro-server/plugin.js +2 -0
  97. package/dist/vite-plugin-env/index.d.ts +3 -1
  98. package/dist/vite-plugin-env/index.js +11 -1
  99. package/dist/vite-plugin-markdown/content-entry-type.js +25 -2
  100. package/dist/vite-plugin-scanner/index.js +15 -5
  101. package/dist/vite-plugin-scanner/scan.js +1 -1
  102. package/package.json +15 -9
  103. package/templates/content/module.mjs +6 -1
  104. package/templates/content/types.d.ts +18 -5
  105. package/types/content.d.ts +34 -1
  106. package/dist/core/sync/setup-env-ts.d.ts +0 -8
  107. package/dist/core/sync/setup-env-ts.js +0 -79
@@ -1,6 +1,7 @@
1
1
  import nodeFs from "node:fs";
2
2
  import { extname } from "node:path";
3
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
+ import { dataToEsm } from "@rollup/pluginutils";
4
5
  import glob from "fast-glob";
5
6
  import pLimit from "p-limit";
6
7
  import { encodeName } from "../core/build/util.js";
@@ -10,9 +11,18 @@ import { isServerLikeOutput } from "../core/util.js";
10
11
  import { rootRelativePath } from "../core/viteUtils.js";
11
12
  import { createDefaultAstroMetadata } from "../vite-plugin-astro/metadata.js";
12
13
  import {
14
+ ASSET_IMPORTS_FILE,
15
+ ASSET_IMPORTS_RESOLVED_STUB_ID,
16
+ ASSET_IMPORTS_VIRTUAL_ID,
13
17
  CONTENT_FLAG,
14
18
  CONTENT_RENDER_FLAG,
15
19
  DATA_FLAG,
20
+ DATA_STORE_FILE,
21
+ DATA_STORE_VIRTUAL_ID,
22
+ MODULES_IMPORTS_FILE,
23
+ MODULES_MJS_ID,
24
+ MODULES_MJS_VIRTUAL_ID,
25
+ RESOLVED_DATA_STORE_VIRTUAL_ID,
16
26
  RESOLVED_VIRTUAL_MODULE_ID,
17
27
  VIRTUAL_MODULE_ID
18
28
  } from "./consts.js";
@@ -25,7 +35,8 @@ import {
25
35
  getEntryConfigByExtMap,
26
36
  getEntrySlug,
27
37
  getEntryType,
28
- getExtGlob
38
+ getExtGlob,
39
+ isDeferredModule
29
40
  } from "./utils.js";
30
41
  function astroContentVirtualModPlugin({
31
42
  settings,
@@ -33,13 +44,14 @@ function astroContentVirtualModPlugin({
33
44
  }) {
34
45
  let IS_DEV = false;
35
46
  const IS_SERVER = isServerLikeOutput(settings.config);
47
+ const dataStoreFile = new URL(DATA_STORE_FILE, settings.config.cacheDir);
36
48
  return {
37
49
  name: "astro-content-virtual-mod-plugin",
38
50
  enforce: "pre",
39
51
  configResolved(config) {
40
52
  IS_DEV = config.mode === "development";
41
53
  },
42
- resolveId(id) {
54
+ async resolveId(id) {
43
55
  if (id === VIRTUAL_MODULE_ID) {
44
56
  if (!settings.config.experimental.contentCollectionCache) {
45
57
  return RESOLVED_VIRTUAL_MODULE_ID;
@@ -50,6 +62,35 @@ function astroContentVirtualModPlugin({
50
62
  return { id: RESOLVED_VIRTUAL_MODULE_ID, external: true };
51
63
  }
52
64
  }
65
+ if (id === DATA_STORE_VIRTUAL_ID) {
66
+ return RESOLVED_DATA_STORE_VIRTUAL_ID;
67
+ }
68
+ if (isDeferredModule(id)) {
69
+ const [, query] = id.split("?");
70
+ const params = new URLSearchParams(query);
71
+ const fileName = params.get("fileName");
72
+ let importerPath = void 0;
73
+ if (fileName && URL.canParse(fileName, settings.config.root.toString())) {
74
+ importerPath = fileURLToPath(new URL(fileName, settings.config.root));
75
+ }
76
+ if (importerPath) {
77
+ return await this.resolve(importerPath);
78
+ }
79
+ }
80
+ if (id === MODULES_MJS_ID) {
81
+ const modules = new URL(MODULES_IMPORTS_FILE, settings.dotAstroDir);
82
+ if (fs.existsSync(modules)) {
83
+ return fileURLToPath(modules);
84
+ }
85
+ return MODULES_MJS_VIRTUAL_ID;
86
+ }
87
+ if (id === ASSET_IMPORTS_VIRTUAL_ID) {
88
+ const assetImportsFile = new URL(ASSET_IMPORTS_FILE, settings.dotAstroDir);
89
+ if (fs.existsSync(assetImportsFile)) {
90
+ return fileURLToPath(assetImportsFile);
91
+ }
92
+ return ASSET_IMPORTS_RESOLVED_STUB_ID;
93
+ }
53
94
  },
54
95
  async load(id, args) {
55
96
  if (id === RESOLVED_VIRTUAL_MODULE_ID) {
@@ -75,6 +116,38 @@ function astroContentVirtualModPlugin({
75
116
  }
76
117
  };
77
118
  }
119
+ if (id === RESOLVED_DATA_STORE_VIRTUAL_ID) {
120
+ if (!fs.existsSync(dataStoreFile)) {
121
+ return "export default new Map()";
122
+ }
123
+ const jsonData = await fs.promises.readFile(dataStoreFile, "utf-8");
124
+ try {
125
+ const parsed = JSON.parse(jsonData);
126
+ return {
127
+ code: dataToEsm(parsed, {
128
+ compact: true
129
+ }),
130
+ map: { mappings: "" }
131
+ };
132
+ } catch (err) {
133
+ const message = "Could not parse JSON file";
134
+ this.error({ message, id, cause: err });
135
+ }
136
+ }
137
+ if (id === ASSET_IMPORTS_RESOLVED_STUB_ID) {
138
+ const assetImportsFile = new URL(ASSET_IMPORTS_FILE, settings.dotAstroDir);
139
+ if (!fs.existsSync(assetImportsFile)) {
140
+ return "export default new Map()";
141
+ }
142
+ return fs.readFileSync(assetImportsFile, "utf-8");
143
+ }
144
+ if (id === MODULES_MJS_VIRTUAL_ID) {
145
+ const modules = new URL(MODULES_IMPORTS_FILE, settings.dotAstroDir);
146
+ if (!fs.existsSync(modules)) {
147
+ return "export default new Map()";
148
+ }
149
+ return fs.readFileSync(modules, "utf-8");
150
+ }
78
151
  },
79
152
  renderChunk(code, chunk) {
80
153
  if (!settings.config.experimental.contentCollectionCache) {
@@ -85,6 +158,25 @@ function astroContentVirtualModPlugin({
85
158
  const prefix = depth > 0 ? "../".repeat(depth) : "./";
86
159
  return code.replaceAll(RESOLVED_VIRTUAL_MODULE_ID, `${prefix}content/entry.mjs`);
87
160
  }
161
+ },
162
+ configureServer(server) {
163
+ const dataStorePath = fileURLToPath(dataStoreFile);
164
+ if (Array.isArray(server.watcher.options.ignored)) {
165
+ server.watcher.options.ignored.push(`!${dataStorePath}`);
166
+ }
167
+ server.watcher.add(dataStorePath);
168
+ server.watcher.on("change", (changedPath) => {
169
+ if (changedPath === dataStorePath) {
170
+ const module = server.moduleGraph.getModuleById(RESOLVED_DATA_STORE_VIRTUAL_ID);
171
+ if (module) {
172
+ server.moduleGraph.invalidateModule(module);
173
+ }
174
+ server.ws.send({
175
+ type: "full-reload",
176
+ path: "*"
177
+ });
178
+ }
179
+ });
88
180
  }
89
181
  };
90
182
  }
@@ -1,3 +1,4 @@
1
+ import { decodeKey } from "../encryption.js";
1
2
  import { deserializeRouteData } from "../routing/manifest/serialization.js";
2
3
  function deserializeManifest(serializedManifest) {
3
4
  const routes = [];
@@ -14,6 +15,7 @@ function deserializeManifest(serializedManifest) {
14
15
  const inlinedScripts = new Map(serializedManifest.inlinedScripts);
15
16
  const clientDirectives = new Map(serializedManifest.clientDirectives);
16
17
  const serverIslandNameMap = new Map(serializedManifest.serverIslandNameMap);
18
+ const key = decodeKey(serializedManifest.key);
17
19
  return {
18
20
  // in case user middleware exists, this no-op middleware will be reassigned (see plugin-ssr.ts)
19
21
  middleware(_, next) {
@@ -25,7 +27,8 @@ function deserializeManifest(serializedManifest) {
25
27
  inlinedScripts,
26
28
  clientDirectives,
27
29
  routes,
28
- serverIslandNameMap
30
+ serverIslandNameMap,
31
+ key
29
32
  };
30
33
  }
31
34
  export {
@@ -298,9 +298,11 @@ class App {
298
298
  `${this.#baseWithoutTrailingSlash}/${status}${maybeDotHtml}`,
299
299
  url
300
300
  );
301
- const response2 = await fetch(statusURL.toString());
302
- const override = { status };
303
- return this.#mergeResponses(response2, originalResponse, override);
301
+ if (statusURL.toString() !== request.url) {
302
+ const response2 = await fetch(statusURL.toString());
303
+ const override = { status };
304
+ return this.#mergeResponses(response2, originalResponse, override);
305
+ }
304
306
  }
305
307
  const mod = await this.#pipeline.getModuleForRoute(errorRouteData);
306
308
  try {
@@ -52,6 +52,7 @@ export type SSRManifest = {
52
52
  pageMap?: Map<ComponentPath, ImportComponentInstance>;
53
53
  serverIslandMap?: Map<string, () => Promise<ComponentInstance>>;
54
54
  serverIslandNameMap?: Map<string, string>;
55
+ key: Promise<CryptoKey>;
55
56
  i18n: SSRManifestI18n | undefined;
56
57
  middleware: MiddlewareHandler;
57
58
  checkOrigin: boolean;
@@ -64,11 +65,12 @@ export type SSRManifestI18n = {
64
65
  defaultLocale: string;
65
66
  domainLookupTable: Record<string, string>;
66
67
  };
67
- export type SerializedSSRManifest = Omit<SSRManifest, 'middleware' | 'routes' | 'assets' | 'componentMetadata' | 'inlinedScripts' | 'clientDirectives' | 'serverIslandNameMap'> & {
68
+ export type SerializedSSRManifest = Omit<SSRManifest, 'middleware' | 'routes' | 'assets' | 'componentMetadata' | 'inlinedScripts' | 'clientDirectives' | 'serverIslandNameMap' | 'key'> & {
68
69
  routes: SerializedRouteInfo[];
69
70
  assets: string[];
70
71
  componentMetadata: [string, SSRComponentMetadata][];
71
72
  inlinedScripts: [string, string][];
72
73
  clientDirectives: [string, string][];
73
74
  serverIslandNameMap: [string, string][];
75
+ key: string;
74
76
  };
@@ -54,7 +54,8 @@ async function generatePages(options, internals) {
54
54
  options.settings,
55
55
  internals,
56
56
  renderers.renderers,
57
- middleware
57
+ middleware,
58
+ options.key
58
59
  );
59
60
  }
60
61
  const pipeline = BuildPipeline.create({ internals, manifest, options });
@@ -358,7 +359,7 @@ function getPrettyRouteName(route) {
358
359
  return route.component;
359
360
  }
360
361
  }
361
- function createBuildManifest(settings, internals, renderers, middleware) {
362
+ function createBuildManifest(settings, internals, renderers, middleware, key) {
362
363
  let i18nManifest = void 0;
363
364
  if (settings.config.i18n) {
364
365
  i18nManifest = {
@@ -388,6 +389,7 @@ function createBuildManifest(settings, internals, renderers, middleware) {
388
389
  buildFormat: settings.config.build.format,
389
390
  middleware,
390
391
  checkOrigin: settings.config.security?.checkOrigin ?? false,
392
+ key,
391
393
  experimentalEnvGetSecretEnabled: false
392
394
  };
393
395
  }
@@ -15,10 +15,12 @@ import { resolveConfig } from "../config/config.js";
15
15
  import { createNodeLogger } from "../config/logging.js";
16
16
  import { createSettings } from "../config/settings.js";
17
17
  import { createVite } from "../create-vite.js";
18
+ import { createKey } from "../encryption.js";
18
19
  import { levels, timerMessage } from "../logger/core.js";
19
20
  import { apply as applyPolyfill } from "../polyfill.js";
20
21
  import { createRouteManifest } from "../routing/index.js";
21
22
  import { getServerIslandRouteData } from "../server-islands/endpoint.js";
23
+ import { clearContentLayerCache } from "../sync/index.js";
22
24
  import { ensureProcessNodeEnv, isServerLikeOutput } from "../util.js";
23
25
  import { collectPagesData } from "./page-data.js";
24
26
  import { staticBuild, viteBuild } from "./static-build.js";
@@ -29,13 +31,16 @@ async function build(inlineConfig, options = {}) {
29
31
  const logger = createNodeLogger(inlineConfig);
30
32
  const { userConfig, astroConfig } = await resolveConfig(inlineConfig, "build");
31
33
  telemetry.record(eventCliSession("build", userConfig));
32
- if (astroConfig.experimental.contentCollectionCache && options.force) {
33
- const contentCacheDir = new URL("./content/", astroConfig.cacheDir);
34
- if (fs.existsSync(contentCacheDir)) {
35
- logger.debug("content", "clearing content cache");
36
- await fs.promises.rm(contentCacheDir, { force: true, recursive: true });
37
- logger.warn("content", "content cache cleared (force)");
34
+ if (inlineConfig.force) {
35
+ if (astroConfig.experimental.contentCollectionCache) {
36
+ const contentCacheDir = new URL("./content/", astroConfig.cacheDir);
37
+ if (fs.existsSync(contentCacheDir)) {
38
+ logger.debug("content", "clearing content cache");
39
+ await fs.promises.rm(contentCacheDir, { force: true, recursive: true });
40
+ logger.warn("content", "content cache cleared (force)");
41
+ }
38
42
  }
43
+ await clearContentLayerCache({ astroConfig, logger, fs });
39
44
  }
40
45
  const settings = await createSettings(astroConfig, fileURLToPath(astroConfig.root));
41
46
  const builder = new AstroBuilder(settings, {
@@ -135,7 +140,8 @@ class AstroBuilder {
135
140
  origin: this.origin,
136
141
  pageNames,
137
142
  teardownCompiler: this.teardownCompiler,
138
- viteConfig
143
+ viteConfig,
144
+ key: createKey()
139
145
  };
140
146
  const { internals, ssrOutputChunkNames, contentFileNames } = await viteBuild(opts);
141
147
  await staticBuild(opts, internals, ssrOutputChunkNames, contentFileNames);
@@ -165,15 +171,18 @@ class AstroBuilder {
165
171
  buildMode: this.settings.config.output
166
172
  });
167
173
  }
168
- this.settings.timer.writeStats();
169
174
  }
170
175
  /** Build the given Astro project. */
171
176
  async run() {
177
+ this.settings.timer.start("Total build");
172
178
  const setupData = await this.setup();
173
179
  try {
174
180
  await this.build(setupData);
175
181
  } catch (_err) {
176
182
  throw _err;
183
+ } finally {
184
+ this.settings.timer.end("Total build");
185
+ this.settings.timer.writeStats();
177
186
  }
178
187
  }
179
188
  validateConfig() {
@@ -5,6 +5,7 @@ import { normalizeTheLocale } from "../../../i18n/index.js";
5
5
  import { toRoutingStrategy } from "../../../i18n/utils.js";
6
6
  import { runHookBuildSsr } from "../../../integrations/hooks.js";
7
7
  import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from "../../../vite-plugin-scripts/index.js";
8
+ import { encodeKey } from "../../encryption.js";
8
9
  import { fileExtension, joinPaths, prependForwardSlash } from "../../path.js";
9
10
  import { serializeRouteData } from "../../routing/index.js";
10
11
  import { addRollupInput } from "../add-rollup-input.js";
@@ -103,7 +104,8 @@ async function createManifest(buildOpts, internals) {
103
104
  internals.staticFiles.add(file);
104
105
  }
105
106
  const staticFiles = internals.staticFiles;
106
- return buildManifest(buildOpts, internals, Array.from(staticFiles));
107
+ const encodedKey = await encodeKey(await buildOpts.key);
108
+ return buildManifest(buildOpts, internals, Array.from(staticFiles), encodedKey);
107
109
  }
108
110
  function injectManifest(manifest, chunk) {
109
111
  const code = chunk.code;
@@ -111,7 +113,7 @@ function injectManifest(manifest, chunk) {
111
113
  return JSON.stringify(manifest);
112
114
  });
113
115
  }
114
- function buildManifest(opts, internals, staticFiles) {
116
+ function buildManifest(opts, internals, staticFiles, encodedKey) {
115
117
  const { settings } = opts;
116
118
  const routes = [];
117
119
  const domainLookupTable = {};
@@ -214,6 +216,7 @@ function buildManifest(opts, internals, staticFiles) {
214
216
  buildFormat: settings.config.build.format,
215
217
  checkOrigin: settings.config.security?.checkOrigin ?? false,
216
218
  serverIslandNameMap: Array.from(settings.serverIslandNameMap),
219
+ key: encodedKey,
217
220
  experimentalEnvGetSecretEnabled: settings.config.experimental.env !== void 0 && (settings.adapter?.supportedAstroFeatures.envGetSecret ?? "unsupported") !== "unsupported"
218
221
  };
219
222
  }
@@ -12,6 +12,24 @@ import { RENDERERS_MODULE_ID } from "./plugin-renderers.js";
12
12
  import { getComponentFromVirtualModulePageName, getVirtualModulePageName } from "./util.js";
13
13
  const SSR_VIRTUAL_MODULE_ID = "@astrojs-ssr-virtual-entry";
14
14
  const RESOLVED_SSR_VIRTUAL_MODULE_ID = "\0" + SSR_VIRTUAL_MODULE_ID;
15
+ const ADAPTER_VIRTUAL_MODULE_ID = "@astrojs-ssr-adapter";
16
+ const RESOLVED_ADAPTER_VIRTUAL_MODULE_ID = "\0" + ADAPTER_VIRTUAL_MODULE_ID;
17
+ function vitePluginAdapter(adapter) {
18
+ return {
19
+ name: "@astrojs/vite-plugin-astro-adapter",
20
+ enforce: "post",
21
+ resolveId(id) {
22
+ if (id === ADAPTER_VIRTUAL_MODULE_ID) {
23
+ return RESOLVED_ADAPTER_VIRTUAL_MODULE_ID;
24
+ }
25
+ },
26
+ async load(id) {
27
+ if (id === RESOLVED_ADAPTER_VIRTUAL_MODULE_ID) {
28
+ return `export * from '${adapter.serverEntrypoint}';`;
29
+ }
30
+ }
31
+ };
32
+ }
15
33
  function vitePluginSSR(internals, adapter, options) {
16
34
  return {
17
35
  name: "@astrojs/vite-plugin-astro-ssr-server",
@@ -24,6 +42,10 @@ function vitePluginSSR(internals, adapter, options) {
24
42
  }
25
43
  inputs.add(getVirtualModulePageName(ASTRO_PAGE_MODULE_ID, pageData.component));
26
44
  }
45
+ const adapterServerEntrypoint = options.settings.adapter?.serverEntrypoint;
46
+ if (adapterServerEntrypoint) {
47
+ inputs.add(ADAPTER_VIRTUAL_MODULE_ID);
48
+ }
27
49
  inputs.add(SSR_VIRTUAL_MODULE_ID);
28
50
  return addRollupInput(opts, Array.from(inputs));
29
51
  },
@@ -94,7 +116,12 @@ function pluginSSR(options, internals) {
94
116
  targets: ["server"],
95
117
  hooks: {
96
118
  "build:before": () => {
97
- let vitePlugin = ssr && functionPerRouteEnabled === false ? vitePluginSSR(internals, options.settings.adapter, options) : void 0;
119
+ const adapter = options.settings.adapter;
120
+ let ssrPlugin = ssr && functionPerRouteEnabled === false ? vitePluginSSR(internals, adapter, options) : void 0;
121
+ const vitePlugin = [vitePluginAdapter(adapter)];
122
+ if (ssrPlugin) {
123
+ vitePlugin.unshift(ssrPlugin);
124
+ }
98
125
  return {
99
126
  enforce: "after-user-plugins",
100
127
  vitePlugin
@@ -181,7 +208,12 @@ function pluginSSRSplit(options, internals) {
181
208
  targets: ["server"],
182
209
  hooks: {
183
210
  "build:before": () => {
184
- let vitePlugin = ssr && functionPerRouteEnabled ? vitePluginSSRSplit(internals, options.settings.adapter, options) : void 0;
211
+ const adapter = options.settings.adapter;
212
+ let ssrPlugin = ssr && functionPerRouteEnabled ? vitePluginSSRSplit(internals, adapter, options) : void 0;
213
+ const vitePlugin = [vitePluginAdapter(adapter)];
214
+ if (ssrPlugin) {
215
+ vitePlugin.unshift(ssrPlugin);
216
+ }
185
217
  return {
186
218
  enforce: "after-user-plugins",
187
219
  vitePlugin
@@ -195,8 +227,8 @@ function generateSSRCode(settings, adapter, middlewareId) {
195
227
  const pageMap = isFunctionPerRouteEnabled(adapter) ? "pageModule" : "pageMap";
196
228
  const imports = [
197
229
  `import { renderers } from '${RENDERERS_MODULE_ID}';`,
230
+ `import * as serverEntrypointModule from '${ADAPTER_VIRTUAL_MODULE_ID}';`,
198
231
  `import { manifest as defaultManifest } from '${SSR_MANIFEST_VIRTUAL_MODULE_ID}';`,
199
- `import * as serverEntrypointModule from '${adapter.serverEntrypoint}';`,
200
232
  edgeMiddleware ? `` : `import { onRequest as middleware } from '${middlewareId}';`,
201
233
  settings.config.experimental.serverIslands ? `import { serverIslandMap } from '${VIRTUAL_ISLAND_MAP_ID}';` : ""
202
234
  ];
@@ -199,6 +199,8 @@ async function ssrBuild(opts, internals, input, container, logger) {
199
199
  return "renderers.mjs";
200
200
  } else if (chunkInfo.facadeModuleId === RESOLVED_SSR_MANIFEST_VIRTUAL_MODULE_ID) {
201
201
  return "manifest_[hash].mjs";
202
+ } else if (chunkInfo.facadeModuleId === settings.adapter?.serverEntrypoint) {
203
+ return "adapter_[hash].mjs";
202
204
  } else if (settings.config.experimental.contentCollectionCache && chunkInfo.facadeModuleId && hasAnyContentFlag(chunkInfo.facadeModuleId)) {
203
205
  const moduleId = reverseSymlink({
204
206
  symlinks,
@@ -39,6 +39,7 @@ export interface StaticBuildOptions {
39
39
  pageNames: string[];
40
40
  viteConfig: InlineConfig;
41
41
  teardownCompiler: boolean;
42
+ key: Promise<CryptoKey>;
42
43
  }
43
44
  type ImportComponentInstance = () => Promise<ComponentInstance>;
44
45
  export interface SinglePageBuiltModule {
@@ -1,13 +1,10 @@
1
1
  import fs from 'node:fs';
2
- import type { Arguments as Flags } from 'yargs-parser';
3
- import type { AstroConfig, AstroInlineConfig, AstroUserConfig, CLIFlags } from '../../@types/astro.js';
4
- /** Convert the generic "yargs" flag object into our own, custom TypeScript object. */
5
- export declare function resolveFlags(flags: Partial<Flags>): CLIFlags;
2
+ import type { AstroConfig, AstroInlineConfig, AstroUserConfig } from '../../@types/astro.js';
6
3
  export declare function resolveRoot(cwd?: string | URL): string;
7
4
  export declare const configPaths: readonly string[];
8
5
  interface ResolveConfigPathOptions {
9
6
  root: string;
10
- configFile?: string;
7
+ configFile?: string | false;
11
8
  fs: typeof fs;
12
9
  }
13
10
  /**
@@ -10,17 +10,6 @@ import { formatConfigErrorMessage } from "../messages.js";
10
10
  import { mergeConfig } from "./merge.js";
11
11
  import { validateConfig } from "./validate.js";
12
12
  import { loadConfigWithVite } from "./vite-load.js";
13
- function resolveFlags(flags) {
14
- return {
15
- root: typeof flags.root === "string" ? flags.root : void 0,
16
- site: typeof flags.site === "string" ? flags.site : void 0,
17
- base: typeof flags.base === "string" ? flags.base : void 0,
18
- port: typeof flags.port === "number" ? flags.port : void 0,
19
- config: typeof flags.config === "string" ? flags.config : void 0,
20
- host: typeof flags.host === "string" || typeof flags.host === "boolean" ? flags.host : void 0,
21
- open: typeof flags.open === "string" || typeof flags.open === "boolean" ? flags.open : void 0
22
- };
23
- }
24
13
  function resolveRoot(cwd) {
25
14
  if (cwd instanceof URL) {
26
15
  cwd = fileURLToPath(cwd);
@@ -115,6 +104,5 @@ export {
115
104
  configPaths,
116
105
  resolveConfig,
117
106
  resolveConfigPath,
118
- resolveFlags,
119
107
  resolveRoot
120
108
  };
@@ -1,4 +1,4 @@
1
- export { configPaths, resolveConfig, resolveConfigPath, resolveFlags, resolveRoot, } from './config.js';
1
+ export { configPaths, resolveConfig, resolveConfigPath, resolveRoot, } from './config.js';
2
2
  export { createNodeLogger } from './logging.js';
3
3
  export { mergeConfig } from './merge.js';
4
4
  export type { AstroConfigType } from './schema.js';
@@ -2,7 +2,6 @@ import {
2
2
  configPaths,
3
3
  resolveConfig,
4
4
  resolveConfigPath,
5
- resolveFlags,
6
5
  resolveRoot
7
6
  } from "./config.js";
8
7
  import { createNodeLogger } from "./logging.js";
@@ -17,7 +16,6 @@ export {
17
16
  mergeConfig,
18
17
  resolveConfig,
19
18
  resolveConfigPath,
20
- resolveFlags,
21
19
  resolveRoot,
22
20
  updateTSConfigForFramework
23
21
  };
@@ -57,9 +57,11 @@ export declare const ASTRO_CONFIG_DEFAULTS: {
57
57
  clientPrerender: false;
58
58
  globalRoutePriority: false;
59
59
  serverIslands: false;
60
+ contentIntellisense: false;
60
61
  env: {
61
62
  validateSecrets: false;
62
63
  };
64
+ contentLayer: false;
63
65
  };
64
66
  };
65
67
  export declare const AstroConfigSchema: z.ZodObject<{
@@ -613,6 +615,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
613
615
  })> | undefined;
614
616
  }>>;
615
617
  serverIslands: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
618
+ contentIntellisense: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
619
+ contentLayer: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
616
620
  }, "strict", z.ZodTypeAny, {
617
621
  actions: boolean;
618
622
  directRenderScript: boolean;
@@ -620,6 +624,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
620
624
  clientPrerender: boolean;
621
625
  globalRoutePriority: boolean;
622
626
  serverIslands: boolean;
627
+ contentIntellisense: boolean;
628
+ contentLayer: boolean;
623
629
  env?: {
624
630
  validateSecrets: boolean;
625
631
  schema?: Record<string, ({
@@ -669,6 +675,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
669
675
  clientPrerender?: boolean | undefined;
670
676
  globalRoutePriority?: boolean | undefined;
671
677
  serverIslands?: boolean | undefined;
678
+ contentIntellisense?: boolean | undefined;
679
+ contentLayer?: boolean | undefined;
672
680
  env?: {
673
681
  validateSecrets?: boolean | undefined;
674
682
  schema?: Record<string, ({
@@ -796,6 +804,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
796
804
  clientPrerender: boolean;
797
805
  globalRoutePriority: boolean;
798
806
  serverIslands: boolean;
807
+ contentIntellisense: boolean;
808
+ contentLayer: boolean;
799
809
  env?: {
800
810
  validateSecrets: boolean;
801
811
  schema?: Record<string, ({
@@ -959,6 +969,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
959
969
  clientPrerender?: boolean | undefined;
960
970
  globalRoutePriority?: boolean | undefined;
961
971
  serverIslands?: boolean | undefined;
972
+ contentIntellisense?: boolean | undefined;
973
+ contentLayer?: boolean | undefined;
962
974
  env?: {
963
975
  validateSecrets?: boolean | undefined;
964
976
  schema?: Record<string, ({
@@ -1556,6 +1568,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1556
1568
  })> | undefined;
1557
1569
  }>>;
1558
1570
  serverIslands: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1571
+ contentIntellisense: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1572
+ contentLayer: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1559
1573
  }, "strict", z.ZodTypeAny, {
1560
1574
  actions: boolean;
1561
1575
  directRenderScript: boolean;
@@ -1563,6 +1577,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1563
1577
  clientPrerender: boolean;
1564
1578
  globalRoutePriority: boolean;
1565
1579
  serverIslands: boolean;
1580
+ contentIntellisense: boolean;
1581
+ contentLayer: boolean;
1566
1582
  env?: {
1567
1583
  validateSecrets: boolean;
1568
1584
  schema?: Record<string, ({
@@ -1612,6 +1628,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1612
1628
  clientPrerender?: boolean | undefined;
1613
1629
  globalRoutePriority?: boolean | undefined;
1614
1630
  serverIslands?: boolean | undefined;
1631
+ contentIntellisense?: boolean | undefined;
1632
+ contentLayer?: boolean | undefined;
1615
1633
  env?: {
1616
1634
  validateSecrets?: boolean | undefined;
1617
1635
  schema?: Record<string, ({
@@ -1814,6 +1832,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1814
1832
  clientPrerender: boolean;
1815
1833
  globalRoutePriority: boolean;
1816
1834
  serverIslands: boolean;
1835
+ contentIntellisense: boolean;
1836
+ contentLayer: boolean;
1817
1837
  env?: {
1818
1838
  validateSecrets: boolean;
1819
1839
  schema?: Record<string, ({
@@ -1977,6 +1997,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1977
1997
  clientPrerender?: boolean | undefined;
1978
1998
  globalRoutePriority?: boolean | undefined;
1979
1999
  serverIslands?: boolean | undefined;
2000
+ contentIntellisense?: boolean | undefined;
2001
+ contentLayer?: boolean | undefined;
1980
2002
  env?: {
1981
2003
  validateSecrets?: boolean | undefined;
1982
2004
  schema?: Record<string, ({
@@ -2105,6 +2127,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2105
2127
  clientPrerender: boolean;
2106
2128
  globalRoutePriority: boolean;
2107
2129
  serverIslands: boolean;
2130
+ contentIntellisense: boolean;
2131
+ contentLayer: boolean;
2108
2132
  env?: {
2109
2133
  validateSecrets: boolean;
2110
2134
  schema?: Record<string, ({
@@ -2268,6 +2292,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2268
2292
  clientPrerender?: boolean | undefined;
2269
2293
  globalRoutePriority?: boolean | undefined;
2270
2294
  serverIslands?: boolean | undefined;
2295
+ contentIntellisense?: boolean | undefined;
2296
+ contentLayer?: boolean | undefined;
2271
2297
  env?: {
2272
2298
  validateSecrets?: boolean | undefined;
2273
2299
  schema?: Record<string, ({
@@ -2396,6 +2422,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2396
2422
  clientPrerender: boolean;
2397
2423
  globalRoutePriority: boolean;
2398
2424
  serverIslands: boolean;
2425
+ contentIntellisense: boolean;
2426
+ contentLayer: boolean;
2399
2427
  env?: {
2400
2428
  validateSecrets: boolean;
2401
2429
  schema?: Record<string, ({
@@ -2559,6 +2587,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2559
2587
  clientPrerender?: boolean | undefined;
2560
2588
  globalRoutePriority?: boolean | undefined;
2561
2589
  serverIslands?: boolean | undefined;
2590
+ contentIntellisense?: boolean | undefined;
2591
+ contentLayer?: boolean | undefined;
2562
2592
  env?: {
2563
2593
  validateSecrets?: boolean | undefined;
2564
2594
  schema?: Record<string, ({
@@ -2687,6 +2717,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2687
2717
  clientPrerender: boolean;
2688
2718
  globalRoutePriority: boolean;
2689
2719
  serverIslands: boolean;
2720
+ contentIntellisense: boolean;
2721
+ contentLayer: boolean;
2690
2722
  env?: {
2691
2723
  validateSecrets: boolean;
2692
2724
  schema?: Record<string, ({
@@ -2850,6 +2882,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2850
2882
  clientPrerender?: boolean | undefined;
2851
2883
  globalRoutePriority?: boolean | undefined;
2852
2884
  serverIslands?: boolean | undefined;
2885
+ contentIntellisense?: boolean | undefined;
2886
+ contentLayer?: boolean | undefined;
2853
2887
  env?: {
2854
2888
  validateSecrets?: boolean | undefined;
2855
2889
  schema?: Record<string, ({