astro 5.15.3 → 6.0.0-alpha.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 (111) hide show
  1. package/{astro.js → bin/astro.mjs} +7 -8
  2. package/client.d.ts +2 -4
  3. package/components/ClientRouter.astro +0 -5
  4. package/dist/actions/runtime/utils.d.ts +2 -8
  5. package/dist/assets/build/remote.js +4 -14
  6. package/dist/assets/fonts/implementations/font-metrics-resolver.js +15 -9
  7. package/dist/assets/fonts/logic/normalize-remote-font-faces.js +1 -1
  8. package/dist/assets/fonts/logic/optimize-fallbacks.js +1 -1
  9. package/dist/assets/services/sharp.js +5 -6
  10. package/dist/assets/utils/index.d.ts +1 -5
  11. package/dist/assets/utils/index.js +1 -5
  12. package/dist/assets/utils/node/emitAsset.d.ts +0 -14
  13. package/dist/assets/utils/node/emitAsset.js +0 -50
  14. package/dist/assets/vite-plugin-assets.js +3 -8
  15. package/dist/cli/add/index.js +0 -2
  16. package/dist/cli/db/index.js +0 -2
  17. package/dist/cli/info/index.js +0 -2
  18. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  19. package/dist/cli/preferences/index.js +0 -2
  20. package/dist/config/index.js +3 -12
  21. package/dist/container/index.d.ts +4 -2
  22. package/dist/container/index.js +0 -1
  23. package/dist/content/config.js +17 -13
  24. package/dist/content/content-layer.js +4 -6
  25. package/dist/content/data-store.d.ts +0 -2
  26. package/dist/content/loaders/glob.d.ts +0 -5
  27. package/dist/content/loaders/glob.js +3 -30
  28. package/dist/content/mutable-data-store.js +1 -14
  29. package/dist/content/runtime-assets.d.ts +1 -1
  30. package/dist/content/runtime-assets.js +3 -6
  31. package/dist/content/runtime.d.ts +19 -58
  32. package/dist/content/runtime.js +52 -218
  33. package/dist/content/server-listeners.js +25 -88
  34. package/dist/content/types-generator.d.ts +1 -6
  35. package/dist/content/types-generator.js +20 -116
  36. package/dist/content/utils.d.ts +31 -104
  37. package/dist/content/utils.js +48 -158
  38. package/dist/content/vite-plugin-content-imports.js +0 -4
  39. package/dist/content/vite-plugin-content-virtual-mod.js +3 -134
  40. package/dist/core/app/index.d.ts +1 -1
  41. package/dist/core/app/index.js +7 -10
  42. package/dist/core/app/node.d.ts +2 -8
  43. package/dist/core/app/node.js +4 -6
  44. package/dist/core/build/generate.js +0 -1
  45. package/dist/core/build/index.js +1 -4
  46. package/dist/core/build/internal.d.ts +1 -2
  47. package/dist/core/build/internal.js +0 -1
  48. package/dist/core/build/plugins/plugin-manifest.js +2 -4
  49. package/dist/core/compile/compile.js +0 -2
  50. package/dist/core/config/schemas/base.d.ts +4 -40
  51. package/dist/core/config/schemas/base.js +3 -16
  52. package/dist/core/config/schemas/refined.js +7 -0
  53. package/dist/core/config/schemas/relative.d.ts +5 -47
  54. package/dist/core/constants.d.ts +1 -0
  55. package/dist/core/constants.js +3 -1
  56. package/dist/core/create-vite.js +1 -4
  57. package/dist/core/dev/container.js +0 -2
  58. package/dist/core/dev/dev.js +1 -1
  59. package/dist/core/errors/dev/vite.js +1 -18
  60. package/dist/core/errors/errors-data.d.ts +71 -53
  61. package/dist/core/errors/errors-data.js +31 -25
  62. package/dist/core/errors/overlay.js +1 -1
  63. package/dist/core/messages.js +2 -2
  64. package/dist/core/middleware/index.d.ts +1 -1
  65. package/dist/core/middleware/index.js +5 -9
  66. package/dist/core/preview/index.js +0 -2
  67. package/dist/core/render/params-and-props.js +0 -1
  68. package/dist/core/render/route-cache.d.ts +1 -2
  69. package/dist/core/render/route-cache.js +1 -2
  70. package/dist/core/render-context.d.ts +3 -3
  71. package/dist/core/render-context.js +13 -27
  72. package/dist/core/routing/manifest/create.js +1 -1
  73. package/dist/core/routing/params.js +5 -6
  74. package/dist/core/routing/validation.d.ts +1 -2
  75. package/dist/core/routing/validation.js +2 -18
  76. package/dist/core/server-islands/endpoint.d.ts +1 -2
  77. package/dist/core/server-islands/endpoint.js +0 -1
  78. package/dist/core/sync/index.js +2 -10
  79. package/dist/env/env-loader.d.ts +0 -1
  80. package/dist/env/env-loader.js +4 -17
  81. package/dist/env/vite-plugin-env.js +41 -45
  82. package/dist/i18n/index.js +0 -3
  83. package/dist/integrations/hooks.d.ts +1 -2
  84. package/dist/integrations/hooks.js +0 -27
  85. package/dist/prefetch/index.d.ts +0 -10
  86. package/dist/prefetch/index.js +1 -1
  87. package/dist/runtime/server/astro-global.d.ts +2 -2
  88. package/dist/runtime/server/astro-global.js +86 -24
  89. package/dist/transitions/vite-plugin-transitions.js +1 -4
  90. package/dist/types/astro.d.ts +2 -2
  91. package/dist/types/public/common.d.ts +1 -3
  92. package/dist/types/public/config.d.ts +4 -127
  93. package/dist/types/public/context.d.ts +18 -39
  94. package/dist/types/public/integrations.d.ts +0 -17
  95. package/dist/types/public/internal.d.ts +2 -2
  96. package/dist/virtual-modules/i18n.d.ts +87 -5
  97. package/dist/virtual-modules/i18n.js +3 -1
  98. package/dist/virtual-modules/live-config.d.ts +0 -2
  99. package/dist/virtual-modules/live-config.js +0 -4
  100. package/dist/vite-plugin-markdown/index.js +0 -1
  101. package/package.json +8 -12
  102. package/templates/content/module.mjs +8 -63
  103. package/templates/content/types.d.ts +10 -69
  104. package/dist/config/vite-plugin-content-listen.d.ts +0 -17
  105. package/dist/config/vite-plugin-content-listen.js +0 -26
  106. package/dist/container/polyfill.d.ts +0 -1
  107. package/dist/container/polyfill.js +0 -2
  108. package/dist/core/polyfill.d.ts +0 -5
  109. package/dist/core/polyfill.js +0 -17
  110. package/dist/vite-plugin-astro-postprocess/index.d.ts +0 -2
  111. package/dist/vite-plugin-astro-postprocess/index.js +0 -48
@@ -8,7 +8,6 @@ import xxhash from "xxhash-wasm";
8
8
  import { z } from "zod";
9
9
  import { AstroError, AstroErrorData, errorMap, MarkdownError } from "../core/errors/index.js";
10
10
  import { isYAMLException } from "../core/errors/utils.js";
11
- import { appendForwardSlash } from "../core/path.js";
12
11
  import { normalizePath } from "../core/viteUtils.js";
13
12
  import {
14
13
  CONTENT_LAYER_TYPE,
@@ -18,7 +17,6 @@ import {
18
17
  LIVE_CONTENT_TYPE,
19
18
  PROPAGATED_ASSET_FLAG
20
19
  } from "./consts.js";
21
- import { glob } from "./loaders/glob.js";
22
20
  import { createImage } from "./runtime-assets.js";
23
21
  const entryTypeSchema = z.object({
24
22
  id: z.string({
@@ -38,14 +36,6 @@ const loaderReturnSchema = z.union([
38
36
  )
39
37
  ]);
40
38
  const collectionConfigParser = z.union([
41
- z.object({
42
- type: z.literal("content").optional().default("content"),
43
- schema: z.any().optional()
44
- }),
45
- z.object({
46
- type: z.literal("data"),
47
- schema: z.any().optional()
48
- }),
49
39
  z.object({
50
40
  type: z.literal(CONTENT_LAYER_TYPE),
51
41
  schema: z.any().optional(),
@@ -76,9 +66,7 @@ const collectionConfigParser = z.union([
76
66
  schema: z.any().optional(),
77
67
  render: z.function(z.tuple([z.any()], z.unknown())).optional()
78
68
  })
79
- ]),
80
- /** deprecated */
81
- _legacy: z.boolean().optional()
69
+ ])
82
70
  }),
83
71
  z.object({
84
72
  type: z.literal(LIVE_CONTENT_TYPE).optional().default(LIVE_CONTENT_TYPE),
@@ -104,25 +92,14 @@ function parseEntrySlug({
104
92
  });
105
93
  }
106
94
  }
107
- async function getEntryDataAndImages(entry, collectionConfig, shouldEmitFile, experimentalSvgEnabled, pluginContext) {
108
- let data;
109
- if (collectionConfig.type === "content" || collectionConfig._legacy) {
110
- const { slug, ...unvalidatedData } = entry.unvalidatedData;
111
- data = unvalidatedData;
112
- } else {
113
- data = entry.unvalidatedData;
114
- }
95
+ async function getEntryDataAndImages(entry, collectionConfig, shouldEmitFile, pluginContext) {
96
+ let data = entry.unvalidatedData;
115
97
  let schema = collectionConfig.schema;
116
98
  const imageImports = /* @__PURE__ */ new Set();
117
99
  if (typeof schema === "function") {
118
100
  if (pluginContext) {
119
101
  schema = schema({
120
- image: createImage(
121
- pluginContext,
122
- shouldEmitFile,
123
- entry._internal.filePath,
124
- experimentalSvgEnabled
125
- )
102
+ image: createImage(pluginContext, shouldEmitFile, entry._internal.filePath)
126
103
  });
127
104
  } else if (collectionConfig.type === CONTENT_LAYER_TYPE) {
128
105
  schema = schema({
@@ -138,12 +115,6 @@ async function getEntryDataAndImages(entry, collectionConfig, shouldEmitFile, ex
138
115
  }
139
116
  }
140
117
  if (schema) {
141
- if (collectionConfig.type === "content" && typeof schema === "object" && "shape" in schema && schema.shape.slug) {
142
- throw new AstroError({
143
- ...AstroErrorData.ContentSchemaContainsSlugError,
144
- message: AstroErrorData.ContentSchemaContainsSlugError.message(entry.collection)
145
- });
146
- }
147
118
  let formattedError;
148
119
  const parsed = await schema.safeParseAsync(data, {
149
120
  errorMap(error, ctx) {
@@ -157,10 +128,13 @@ async function getEntryDataAndImages(entry, collectionConfig, shouldEmitFile, ex
157
128
  data = parsed.data;
158
129
  } else {
159
130
  if (!formattedError) {
160
- const errorType = collectionConfig.type === "content" ? AstroErrorData.InvalidContentEntryFrontmatterError : AstroErrorData.InvalidContentEntryDataError;
161
131
  formattedError = new AstroError({
162
- ...errorType,
163
- message: errorType.message(entry.collection, entry.id, parsed.error),
132
+ ...AstroErrorData.InvalidContentEntryDataError,
133
+ message: AstroErrorData.InvalidContentEntryDataError.message(
134
+ entry.collection,
135
+ entry.id,
136
+ parsed.error
137
+ ),
164
138
  location: {
165
139
  file: entry._internal?.filePath,
166
140
  line: getYAMLErrorLine(
@@ -176,12 +150,11 @@ async function getEntryDataAndImages(entry, collectionConfig, shouldEmitFile, ex
176
150
  }
177
151
  return { data, imageImports: Array.from(imageImports) };
178
152
  }
179
- async function getEntryData(entry, collectionConfig, shouldEmitFile, experimentalSvgEnabled, pluginContext) {
153
+ async function getEntryData(entry, collectionConfig, shouldEmitFile, pluginContext) {
180
154
  const { data } = await getEntryDataAndImages(
181
155
  entry,
182
156
  collectionConfig,
183
157
  shouldEmitFile,
184
- experimentalSvgEnabled,
185
158
  pluginContext
186
159
  );
187
160
  return data;
@@ -392,96 +365,21 @@ async function loadContentConfig({
392
365
  ${message}
393
366
  `
394
367
  );
395
- if (settings.config.experimental.liveContentCollections) {
396
- const liveCollections = Object.entries(unparsedConfig.collections ?? {}).filter(
397
- ([, collection]) => collection?.type === LIVE_CONTENT_TYPE
398
- );
399
- if (liveCollections.length > 0) {
400
- throw new AstroError({
401
- ...AstroErrorData.LiveContentConfigError,
402
- message: AstroErrorData.LiveContentConfigError.message(
403
- "Live collections must be defined in a `src/live.config.ts` file.",
404
- path.relative(fileURLToPath(settings.config.root), configPathname)
405
- )
406
- });
407
- }
368
+ const liveCollections = Object.entries(unparsedConfig.collections ?? {}).filter(
369
+ ([, collection]) => collection?.type === LIVE_CONTENT_TYPE
370
+ );
371
+ if (liveCollections.length > 0) {
372
+ throw new AstroError({
373
+ ...AstroErrorData.LiveContentConfigError,
374
+ message: AstroErrorData.LiveContentConfigError.message(
375
+ "Live collections must be defined in a `src/live.config.ts` file.",
376
+ path.relative(fileURLToPath(settings.config.root), configPathname)
377
+ )
378
+ });
408
379
  }
409
380
  return void 0;
410
381
  }
411
382
  }
412
- async function autogenerateCollections({
413
- config,
414
- settings,
415
- fs
416
- }) {
417
- if (settings.config.legacy.collections) {
418
- return config;
419
- }
420
- const contentDir = new URL("./content/", settings.config.srcDir);
421
- const collections = config?.collections ?? {};
422
- const contentExts = getContentEntryExts(settings);
423
- const dataExts = getDataEntryExts(settings);
424
- const contentPattern = globWithUnderscoresIgnored("", contentExts);
425
- const dataPattern = globWithUnderscoresIgnored("", dataExts);
426
- let usesContentLayer = false;
427
- for (const collectionName of Object.keys(collections)) {
428
- if (collections[collectionName]?.type === "content_layer" || collections[collectionName]?.type === "live") {
429
- usesContentLayer = true;
430
- continue;
431
- }
432
- const isDataCollection = collections[collectionName]?.type === "data";
433
- const base = new URL(`${collectionName}/`, contentDir);
434
- const _legacy = !isDataCollection || void 0;
435
- collections[collectionName] = {
436
- ...collections[collectionName],
437
- type: "content_layer",
438
- _legacy,
439
- loader: glob({
440
- base,
441
- pattern: isDataCollection ? dataPattern : contentPattern,
442
- _legacy,
443
- // Legacy data collections IDs aren't slugified
444
- generateId: isDataCollection ? ({ entry }) => getDataEntryId({
445
- entry: new URL(entry, base),
446
- collection: collectionName,
447
- contentDir
448
- }) : void 0
449
- // Zod weirdness has trouble with typing the args to the load function
450
- })
451
- };
452
- }
453
- if (!usesContentLayer && fs.existsSync(contentDir)) {
454
- const orphanedCollections = [];
455
- for (const entry of await fs.promises.readdir(contentDir, { withFileTypes: true })) {
456
- const collectionName = entry.name;
457
- if (["_", "."].includes(collectionName.at(0) ?? "")) {
458
- continue;
459
- }
460
- if (entry.isDirectory() && !(collectionName in collections)) {
461
- orphanedCollections.push(collectionName);
462
- const base = new URL(`${collectionName}/`, contentDir);
463
- collections[collectionName] = {
464
- type: "content_layer",
465
- loader: glob({
466
- base,
467
- pattern: contentPattern,
468
- _legacy: true
469
- })
470
- };
471
- }
472
- }
473
- if (orphanedCollections.length > 0) {
474
- console.warn(
475
- `
476
- Auto-generating collections for folders in "src/content/" that are not defined as collections.
477
- This is deprecated, so you should define these collections yourself in "src/content.config.ts".
478
- The following collections have been auto-generated: ${orphanedCollections.map((name) => colors.green(name)).join(", ")}
479
- `
480
- );
481
- }
482
- }
483
- return { ...config, collections };
484
- }
485
383
  async function reloadContentConfigObserver({
486
384
  observer = globalContentConfigObserver,
487
385
  ...loadContentConfigOpts
@@ -489,10 +387,6 @@ async function reloadContentConfigObserver({
489
387
  observer.set({ status: "loading" });
490
388
  try {
491
389
  let config = await loadContentConfig(loadContentConfigOpts);
492
- config = await autogenerateCollections({
493
- config,
494
- ...loadContentConfigOpts
495
- });
496
390
  if (config) {
497
391
  observer.set({ status: "loaded", config });
498
392
  } else {
@@ -527,14 +421,19 @@ function contentObservable(initialCtx) {
527
421
  subscribe
528
422
  };
529
423
  }
530
- function getContentPaths({
531
- srcDir,
532
- legacy,
533
- root,
534
- experimental
535
- }, fs = fsMod) {
536
- const configStats = searchConfig(fs, srcDir, legacy?.collections);
537
- const liveConfigStats = experimental?.liveContentCollections ? searchLiveConfig(fs, srcDir) : { exists: false, url: new URL("./", srcDir) };
424
+ function getContentPaths({ srcDir, root }, fs = fsMod) {
425
+ const configStats = searchConfig(fs, srcDir);
426
+ if (!configStats.exists) {
427
+ const legacyConfigStats = searchLegacyConfig(fs, srcDir);
428
+ if (legacyConfigStats.exists) {
429
+ const relativePath = path.relative(fileURLToPath(root), fileURLToPath(legacyConfigStats.url));
430
+ throw new AstroError({
431
+ ...AstroErrorData.LegacyContentConfigError,
432
+ message: AstroErrorData.LegacyContentConfigError.message(relativePath)
433
+ });
434
+ }
435
+ }
436
+ const liveConfigStats = searchLiveConfig(fs, srcDir);
538
437
  const pkgBase = new URL("../../", import.meta.url);
539
438
  return {
540
439
  root: new URL("./", root),
@@ -546,13 +445,21 @@ function getContentPaths({
546
445
  liveConfig: liveConfigStats
547
446
  };
548
447
  }
549
- function searchConfig(fs, srcDir, legacy) {
448
+ function searchConfig(fs, srcDir) {
550
449
  const paths = [
551
- ...legacy ? [] : ["content.config.mjs", "content.config.js", "content.config.mts", "content.config.ts"],
552
- "content/config.mjs",
450
+ "content.config.mjs",
451
+ "content.config.js",
452
+ "content.config.mts",
453
+ "content.config.ts"
454
+ ];
455
+ return search(fs, srcDir, paths);
456
+ }
457
+ function searchLegacyConfig(fs, srcDir) {
458
+ const paths = [
459
+ "content/config.ts",
553
460
  "content/config.js",
554
- "content/config.mts",
555
- "content/config.ts"
461
+ "content/config.mjs",
462
+ "content/config.mts"
556
463
  ];
557
464
  return search(fs, srcDir, paths);
558
465
  }
@@ -589,12 +496,6 @@ async function getEntrySlug({
589
496
  });
590
497
  return parseEntrySlug({ generatedSlug, frontmatterSlug, id, collection });
591
498
  }
592
- function getExtGlob(exts) {
593
- return exts.length === 1 ? (
594
- // Wrapping {...} breaks when there is only one extension
595
- exts[0]
596
- ) : `{${exts.join(",")}}`;
597
- }
598
499
  function hasAssetPropagationFlag(id) {
599
500
  try {
600
501
  return new URL(id, "file://").searchParams.has(PROPAGATED_ASSET_FLAG);
@@ -602,15 +503,6 @@ function hasAssetPropagationFlag(id) {
602
503
  return false;
603
504
  }
604
505
  }
605
- function globWithUnderscoresIgnored(relContentDir, exts) {
606
- const extGlob = getExtGlob(exts);
607
- const contentDir = relContentDir.length > 0 ? appendForwardSlash(relContentDir) : relContentDir;
608
- return [
609
- `${contentDir}**/*${extGlob}`,
610
- `!${contentDir}**/_*/**/*${extGlob}`,
611
- `!${contentDir}**/_*${extGlob}`
612
- ];
613
- }
614
506
  function posixifyPath(filePath) {
615
507
  return filePath.split(path.sep).join("/");
616
508
  }
@@ -657,9 +549,7 @@ export {
657
549
  getEntryDataAndImages,
658
550
  getEntrySlug,
659
551
  getEntryType,
660
- getExtGlob,
661
552
  getSymlinkedContentCollections,
662
- globWithUnderscoresIgnored,
663
553
  globalContentConfigObserver,
664
554
  hasAssetPropagationFlag,
665
555
  hasContentFlag,
@@ -171,8 +171,6 @@ async function getContentEntryModule(params) {
171
171
  { id, collection, _internal, unvalidatedData },
172
172
  collectionConfig,
173
173
  params.shouldEmitFile,
174
- // FUTURE: Remove in this in v6
175
- id.endsWith(".svg"),
176
174
  pluginContext
177
175
  ) : unvalidatedData;
178
176
  const contentEntryModule = {
@@ -198,8 +196,6 @@ async function getDataEntryModule(params) {
198
196
  { id, collection, _internal, unvalidatedData },
199
197
  collectionConfig,
200
198
  params.shouldEmitFile,
201
- // FUTURE: Remove in this in v6
202
- id.endsWith(".svg"),
203
199
  pluginContext
204
200
  ) : unvalidatedData;
205
201
  const dataEntryModule = {
@@ -1,9 +1,6 @@
1
1
  import nodeFs from "node:fs";
2
- import { extname } from "node:path";
3
- import { fileURLToPath, pathToFileURL } from "node:url";
2
+ import { fileURLToPath } from "node:url";
4
3
  import { dataToEsm } from "@rollup/pluginutils";
5
- import pLimit from "p-limit";
6
- import { glob } from "tinyglobby";
7
4
  import { normalizePath } from "vite";
8
5
  import { AstroError, AstroErrorData } from "../core/errors/index.js";
9
6
  import { rootRelativePath } from "../core/viteUtils.js";
@@ -12,9 +9,7 @@ import {
12
9
  ASSET_IMPORTS_FILE,
13
10
  ASSET_IMPORTS_RESOLVED_STUB_ID,
14
11
  ASSET_IMPORTS_VIRTUAL_ID,
15
- CONTENT_FLAG,
16
12
  CONTENT_RENDER_FLAG,
17
- DATA_FLAG,
18
13
  DATA_STORE_VIRTUAL_ID,
19
14
  MODULES_IMPORTS_FILE,
20
15
  MODULES_MJS_ID,
@@ -24,19 +19,7 @@ import {
24
19
  VIRTUAL_MODULE_ID
25
20
  } from "./consts.js";
26
21
  import { getDataStoreFile } from "./content-layer.js";
27
- import {
28
- getContentEntryIdAndSlug,
29
- getContentPaths,
30
- getDataEntryExts,
31
- getDataEntryId,
32
- getEntryCollectionName,
33
- getEntryConfigByExtMap,
34
- getEntrySlug,
35
- getEntryType,
36
- getExtGlob,
37
- globWithUnderscoresIgnored,
38
- isDeferredModule
39
- } from "./utils.js";
22
+ import { getContentPaths, isDeferredModule } from "./utils.js";
40
23
  function invalidateDataStore(server) {
41
24
  const module = server.moduleGraph.getModuleById(RESOLVED_DATA_STORE_VIRTUAL_ID);
42
25
  if (module) {
@@ -111,15 +94,10 @@ function astroContentVirtualModPlugin({
111
94
  },
112
95
  async load(id, args) {
113
96
  if (id === RESOLVED_VIRTUAL_MODULE_ID) {
114
- const lookupMap = settings.config.legacy.collections ? await generateLookupMap({
115
- settings,
116
- fs
117
- }) : {};
118
97
  const isClient = !args?.ssr;
119
98
  const code = await generateContentEntryFile({
120
99
  settings,
121
100
  fs,
122
- lookupMap,
123
101
  isClient
124
102
  });
125
103
  const astro = createDefaultAstroMetadata();
@@ -180,32 +158,10 @@ function astroContentVirtualModPlugin({
180
158
  }
181
159
  async function generateContentEntryFile({
182
160
  settings,
183
- lookupMap,
184
161
  isClient
185
162
  }) {
186
163
  const contentPaths = getContentPaths(settings.config);
187
164
  const relContentDir = rootRelativePath(settings.config.root, contentPaths.contentDir);
188
- let contentEntryGlobResult = '""';
189
- let dataEntryGlobResult = '""';
190
- let renderEntryGlobResult = '""';
191
- if (settings.config.legacy.collections) {
192
- const contentEntryConfigByExt = getEntryConfigByExtMap(settings.contentEntryTypes);
193
- const contentEntryExts = [...contentEntryConfigByExt.keys()];
194
- const dataEntryExts = getDataEntryExts(settings);
195
- const createGlob = (value, flag) => `import.meta.glob(${JSON.stringify(value)}, { query: { ${flag}: true } })`;
196
- contentEntryGlobResult = createGlob(
197
- globWithUnderscoresIgnored(relContentDir, contentEntryExts),
198
- CONTENT_FLAG
199
- );
200
- dataEntryGlobResult = createGlob(
201
- globWithUnderscoresIgnored(relContentDir, dataEntryExts),
202
- DATA_FLAG
203
- );
204
- renderEntryGlobResult = createGlob(
205
- globWithUnderscoresIgnored(relContentDir, contentEntryExts),
206
- CONTENT_RENDER_FLAG
207
- );
208
- }
209
165
  let virtualModContents;
210
166
  if (isClient) {
211
167
  throw new AstroError({
@@ -213,7 +169,7 @@ async function generateContentEntryFile({
213
169
  message: AstroErrorData.ServerOnlyModule.message("astro:content")
214
170
  });
215
171
  } else {
216
- virtualModContents = nodeFs.readFileSync(contentPaths.virtualModTemplate, "utf-8").replace("@@CONTENT_DIR@@", relContentDir).replace("'@@CONTENT_ENTRY_GLOB_PATH@@'", contentEntryGlobResult).replace("'@@DATA_ENTRY_GLOB_PATH@@'", dataEntryGlobResult).replace("'@@RENDER_ENTRY_GLOB_PATH@@'", renderEntryGlobResult).replace("/* @@LOOKUP_MAP_ASSIGNMENT@@ */", `lookupMap = ${JSON.stringify(lookupMap)};`).replace(
172
+ virtualModContents = nodeFs.readFileSync(contentPaths.virtualModTemplate, "utf-8").replace("@@CONTENT_DIR@@", relContentDir).replace(
217
173
  "/* @@LIVE_CONTENT_CONFIG@@ */",
218
174
  contentPaths.liveConfig.exists ? (
219
175
  // Dynamic import so it extracts the chunk and avoids a circular import
@@ -223,93 +179,6 @@ async function generateContentEntryFile({
223
179
  }
224
180
  return virtualModContents;
225
181
  }
226
- async function generateLookupMap({ settings, fs }) {
227
- const { root } = settings.config;
228
- const contentPaths = getContentPaths(settings.config);
229
- const relContentDir = rootRelativePath(root, contentPaths.contentDir, false);
230
- const contentEntryConfigByExt = getEntryConfigByExtMap(settings.contentEntryTypes);
231
- const dataEntryExts = getDataEntryExts(settings);
232
- const { contentDir } = contentPaths;
233
- const contentEntryExts = [...contentEntryConfigByExt.keys()];
234
- let lookupMap = {};
235
- const contentGlob = await glob(
236
- `${relContentDir}**/*${getExtGlob([...dataEntryExts, ...contentEntryExts])}`,
237
- {
238
- absolute: true,
239
- cwd: fileURLToPath(root),
240
- expandDirectories: false
241
- }
242
- );
243
- const limit = pLimit(10);
244
- const promises = [];
245
- for (const filePath of contentGlob) {
246
- promises.push(
247
- limit(async () => {
248
- const entryType = getEntryType(filePath, contentPaths, contentEntryExts, dataEntryExts);
249
- if (entryType !== "content" && entryType !== "data") return;
250
- const collection = getEntryCollectionName({ contentDir, entry: pathToFileURL(filePath) });
251
- if (!collection) throw UnexpectedLookupMapError;
252
- if (lookupMap[collection]?.type && lookupMap[collection].type !== entryType) {
253
- throw new AstroError({
254
- ...AstroErrorData.MixedContentDataCollectionError,
255
- message: AstroErrorData.MixedContentDataCollectionError.message(collection)
256
- });
257
- }
258
- if (entryType === "content") {
259
- const contentEntryType = contentEntryConfigByExt.get(extname(filePath));
260
- if (!contentEntryType) throw UnexpectedLookupMapError;
261
- const { id, slug: generatedSlug } = getContentEntryIdAndSlug({
262
- entry: pathToFileURL(filePath),
263
- contentDir,
264
- collection
265
- });
266
- const slug = await getEntrySlug({
267
- id,
268
- collection,
269
- generatedSlug,
270
- fs,
271
- fileUrl: pathToFileURL(filePath),
272
- contentEntryType
273
- });
274
- if (lookupMap[collection]?.entries?.[slug]) {
275
- throw new AstroError({
276
- ...AstroErrorData.DuplicateContentEntrySlugError,
277
- message: AstroErrorData.DuplicateContentEntrySlugError.message(
278
- collection,
279
- slug,
280
- lookupMap[collection].entries[slug],
281
- rootRelativePath(root, filePath)
282
- ),
283
- hint: slug !== generatedSlug ? `Check the \`slug\` frontmatter property in **${id}**.` : void 0
284
- });
285
- }
286
- lookupMap[collection] = {
287
- type: "content",
288
- entries: {
289
- ...lookupMap[collection]?.entries,
290
- [slug]: rootRelativePath(root, filePath)
291
- }
292
- };
293
- } else {
294
- const id = getDataEntryId({ entry: pathToFileURL(filePath), contentDir, collection });
295
- lookupMap[collection] = {
296
- type: "data",
297
- entries: {
298
- ...lookupMap[collection]?.entries,
299
- [id]: rootRelativePath(root, filePath)
300
- }
301
- };
302
- }
303
- })
304
- );
305
- }
306
- await Promise.all(promises);
307
- return lookupMap;
308
- }
309
- const UnexpectedLookupMapError = new AstroError({
310
- ...AstroErrorData.UnknownContentCollectionError,
311
- message: `Unexpected error while parsing content entry IDs and slugs.`
312
- });
313
182
  export {
314
183
  astroContentVirtualModPlugin
315
184
  };
@@ -82,7 +82,7 @@ export declare class App {
82
82
  * @param allowPrerenderedRoutes
83
83
  */
84
84
  match(request: Request, allowPrerenderedRoutes?: boolean): RouteData | undefined;
85
- render(request: Request, renderOptions?: RenderOptions): Promise<Response>;
85
+ render(request: Request, { addCookieHeader, clientAddress, locals, prerenderedErrorPageFetch, routeData, }?: RenderOptions): Promise<Response>;
86
86
  setCookieHeaders(response: Response): Generator<string, string[], any>;
87
87
  /**
88
88
  * Reads all the cookies written by `Astro.cookie.set()` onto the passed response.
@@ -232,14 +232,15 @@ class App {
232
232
  }
233
233
  return pathname;
234
234
  }
235
- async render(request, renderOptions) {
236
- let routeData;
237
- let locals;
238
- let clientAddress;
239
- let addCookieHeader;
235
+ async render(request, {
236
+ addCookieHeader,
237
+ clientAddress = Reflect.get(request, clientAddressSymbol),
238
+ locals,
239
+ prerenderedErrorPageFetch = fetch,
240
+ routeData
241
+ } = {}) {
240
242
  const url = new URL(request.url);
241
243
  const redirect = this.#redirectTrailingSlash(url.pathname);
242
- const prerenderedErrorPageFetch = renderOptions?.prerenderedErrorPageFetch ?? fetch;
243
244
  if (redirect !== url.pathname) {
244
245
  const status = request.method === "GET" ? 301 : 308;
245
246
  return new Response(
@@ -257,10 +258,6 @@ class App {
257
258
  }
258
259
  );
259
260
  }
260
- addCookieHeader = renderOptions?.addCookieHeader;
261
- clientAddress = renderOptions?.clientAddress ?? Reflect.get(request, clientAddressSymbol);
262
- routeData = renderOptions?.routeData;
263
- locals = renderOptions?.locals;
264
261
  if (routeData) {
265
262
  this.#logger.debug(
266
263
  "router",
@@ -1,10 +1,8 @@
1
1
  import type { IncomingMessage, ServerResponse } from 'node:http';
2
2
  import type { RemotePattern } from '../../types/public/config.js';
3
- import type { RouteData } from '../../types/public/internal.js';
4
3
  import type { RenderOptions } from './index.js';
5
4
  import { App } from './index.js';
6
5
  import type { NodeAppHeadersJson, SSRManifest } from './types.js';
7
- export { apply as applyPolyfills } from '../polyfill.js';
8
6
  /**
9
7
  * Allow the request body to be explicitly overridden. For example, this
10
8
  * is used by the Express JSON middleware.
@@ -15,13 +13,8 @@ interface NodeRequest extends IncomingMessage {
15
13
  export declare class NodeApp extends App {
16
14
  headersMap: NodeAppHeadersJson | undefined;
17
15
  setHeadersMap(headers: NodeAppHeadersJson): void;
18
- match(req: NodeRequest | Request, allowPrerenderedRoutes?: boolean): RouteData | undefined;
16
+ match(req: NodeRequest | Request, allowPrerenderedRoutes?: boolean): import("../../index.js").RouteData | undefined;
19
17
  render(request: NodeRequest | Request, options?: RenderOptions): Promise<Response>;
20
- /**
21
- * @deprecated Instead of passing `RouteData` and locals individually, pass an object with `routeData` and `locals` properties.
22
- * See https://github.com/withastro/astro/pull/9199 for more information.
23
- */
24
- render(request: NodeRequest | Request, routeData?: RouteData, locals?: object): Promise<Response>;
25
18
  /**
26
19
  * Converts a NodeJS IncomingMessage into a web standard Request.
27
20
  * ```js
@@ -58,3 +51,4 @@ export declare class NodeApp extends App {
58
51
  }
59
52
  export declare function loadManifest(rootFolder: URL): Promise<SSRManifest>;
60
53
  export declare function loadApp(rootFolder: URL): Promise<NodeApp>;
54
+ export {};
@@ -4,7 +4,6 @@ import { clientAddressSymbol, nodeRequestAbortControllerCleanupSymbol } from "..
4
4
  import { deserializeManifest } from "./common.js";
5
5
  import { createOutgoingHttpHeaders } from "./createOutgoingHttpHeaders.js";
6
6
  import { App } from "./index.js";
7
- import { apply } from "../polyfill.js";
8
7
  class NodeApp extends App {
9
8
  headersMap = void 0;
10
9
  setHeadersMap(headers) {
@@ -19,13 +18,13 @@ class NodeApp extends App {
19
18
  }
20
19
  return super.match(req, allowPrerenderedRoutes);
21
20
  }
22
- render(req, routeDataOrOptions, maybeLocals) {
23
- if (!(req instanceof Request)) {
24
- req = NodeApp.createRequest(req, {
21
+ render(request, options) {
22
+ if (!(request instanceof Request)) {
23
+ request = NodeApp.createRequest(request, {
25
24
  allowedDomains: this.manifest.allowedDomains
26
25
  });
27
26
  }
28
- return super.render(req, routeDataOrOptions, maybeLocals);
27
+ return super.render(request, options);
29
28
  }
30
29
  /**
31
30
  * Converts a NodeJS IncomingMessage into a web standard Request.
@@ -258,7 +257,6 @@ async function loadApp(rootFolder) {
258
257
  }
259
258
  export {
260
259
  NodeApp,
261
- apply as applyPolyfills,
262
260
  loadApp,
263
261
  loadManifest
264
262
  };
@@ -214,7 +214,6 @@ async function getPathsForRoute(route, mod, pipeline, builtPaths) {
214
214
  mod,
215
215
  route,
216
216
  routeCache,
217
- logger,
218
217
  ssr: serverLike,
219
218
  base: config.base
220
219
  }).catch((err) => {
@@ -18,9 +18,7 @@ import { createVite } from "../create-vite.js";
18
18
  import { createKey, getEnvironmentKey, hasEnvironmentKey } from "../encryption.js";
19
19
  import { AstroError, AstroErrorData } from "../errors/index.js";
20
20
  import { levels, timerMessage } from "../logger/core.js";
21
- import { apply as applyPolyfill } from "../polyfill.js";
22
21
  import { createRoutesList } from "../routing/index.js";
23
- import { getServerIslandRouteData } from "../server-islands/endpoint.js";
24
22
  import { clearContentLayerCache } from "../sync/index.js";
25
23
  import { ensureProcessNodeEnv } from "../util.js";
26
24
  import { collectPagesData } from "./page-data.js";
@@ -28,7 +26,6 @@ import { staticBuild, viteBuild } from "./static-build.js";
28
26
  import { getTimeStat } from "./util.js";
29
27
  async function build(inlineConfig, options = {}) {
30
28
  ensureProcessNodeEnv(options.devOutput ? "development" : "production");
31
- applyPolyfill();
32
29
  const logger = createNodeLogger(inlineConfig);
33
30
  const { userConfig, astroConfig } = await resolveConfig(inlineConfig, "build");
34
31
  telemetry.record(eventCliSession("build", userConfig));
@@ -167,7 +164,7 @@ class AstroBuilder {
167
164
  await runHookBuildDone({
168
165
  settings: this.settings,
169
166
  pages: pageNames,
170
- routes: Object.values(allPages).flat().map((pageData) => pageData.route).concat(hasServerIslands ? getServerIslandRouteData(this.settings.config) : []),
167
+ routes: Object.values(allPages).flat().map((pageData) => pageData.route),
171
168
  logger: this.logger
172
169
  });
173
170
  if (this.logger.level && levels[this.logger.level()] <= levels["info"]) {