astro 5.1.9 → 5.2.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.
- package/client.d.ts +16 -3
- package/dist/assets/endpoint/config.d.ts +2 -2
- package/dist/cli/add/index.js +51 -25
- package/dist/config/index.js +4 -4
- package/dist/container/index.js +6 -0
- package/dist/content/content-layer.js +3 -3
- package/dist/core/app/index.d.ts +2 -2
- package/dist/core/app/index.js +33 -0
- package/dist/core/app/pipeline.d.ts +2 -2
- package/dist/core/app/types.d.ts +9 -3
- package/dist/core/build/generate.js +8 -2
- package/dist/core/build/index.js +13 -8
- package/dist/core/build/page-data.d.ts +2 -2
- package/dist/core/build/pipeline.d.ts +3 -3
- package/dist/core/build/pipeline.js +4 -4
- package/dist/core/build/plugins/plugin-manifest.js +9 -3
- package/dist/core/build/types.d.ts +2 -2
- package/dist/core/config/schema.d.ts +17 -0
- package/dist/core/config/schema.js +4 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.d.ts +6 -6
- package/dist/core/create-vite.js +6 -4
- package/dist/core/dev/container.js +6 -5
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.d.ts +22 -0
- package/dist/core/errors/errors-data.js +12 -0
- package/dist/core/messages.js +2 -2
- package/dist/core/preview/index.js +2 -2
- package/dist/core/redirects/render.d.ts +2 -0
- package/dist/core/redirects/render.js +24 -5
- package/dist/core/routing/astro-designed-error-pages.d.ts +2 -2
- package/dist/core/routing/index.d.ts +1 -1
- package/dist/core/routing/index.js +2 -2
- package/dist/core/routing/manifest/create.d.ts +3 -3
- package/dist/core/routing/manifest/create.js +12 -10
- package/dist/core/routing/match.d.ts +3 -3
- package/dist/core/server-islands/endpoint.d.ts +2 -2
- package/dist/core/sync/index.d.ts +5 -3
- package/dist/core/sync/index.js +13 -8
- package/dist/i18n/index.js +10 -3
- package/dist/i18n/utils.d.ts +2 -0
- package/dist/i18n/utils.js +24 -0
- package/dist/manifest/virtual-module.d.ts +9 -0
- package/dist/manifest/virtual-module.js +111 -0
- package/dist/template/4xx.d.ts +1 -0
- package/dist/template/4xx.js +14 -1
- package/dist/types/astro.d.ts +1 -1
- package/dist/types/public/config.d.ts +36 -18
- package/dist/types/public/index.d.ts +1 -0
- package/dist/types/public/manifest.d.ts +23 -0
- package/dist/types/public/manifest.js +0 -0
- package/dist/vite-plugin-astro-server/base.js +3 -13
- package/dist/vite-plugin-astro-server/pipeline.d.ts +4 -4
- package/dist/vite-plugin-astro-server/pipeline.js +5 -5
- package/dist/vite-plugin-astro-server/plugin.d.ts +4 -4
- package/dist/vite-plugin-astro-server/plugin.js +21 -10
- package/dist/vite-plugin-astro-server/request.d.ts +3 -3
- package/dist/vite-plugin-astro-server/request.js +3 -3
- package/dist/vite-plugin-astro-server/route.d.ts +4 -4
- package/dist/vite-plugin-astro-server/route.js +7 -7
- package/dist/vite-plugin-astro-server/trailing-slash.d.ts +3 -0
- package/dist/vite-plugin-astro-server/trailing-slash.js +27 -0
- package/dist/vite-plugin-config-alias/index.js +1 -1
- package/dist/vite-plugin-scanner/index.d.ts +3 -3
- package/dist/vite-plugin-scanner/index.js +3 -3
- package/package.json +4 -4
- package/templates/content/types.d.ts +25 -24
package/client.d.ts
CHANGED
|
@@ -168,9 +168,8 @@ declare module 'astro:transitions/client' {
|
|
|
168
168
|
export type TransitionBeforeSwapEvent = import('./dist/virtual-modules/transitions-events.js').TransitionBeforeSwapEvent;
|
|
169
169
|
export const isTransitionBeforePreparationEvent: EventModule['isTransitionBeforePreparationEvent'];
|
|
170
170
|
export const isTransitionBeforeSwapEvent: EventModule['isTransitionBeforeSwapEvent'];
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
);
|
|
171
|
+
// biome-ignore format: bug
|
|
172
|
+
type TransitionSwapFunctionModule = typeof import('./dist/virtual-modules/transitions-swap-functions.js');
|
|
174
173
|
export const swapFunctions: TransitionSwapFunctionModule['swapFunctions'];
|
|
175
174
|
}
|
|
176
175
|
|
|
@@ -190,6 +189,20 @@ declare module 'astro:middleware' {
|
|
|
190
189
|
export * from 'astro/virtual-modules/middleware.js';
|
|
191
190
|
}
|
|
192
191
|
|
|
192
|
+
declare module 'astro:config/server' {
|
|
193
|
+
// biome-ignore format: bug
|
|
194
|
+
type ServerConfigSerialized = import('./dist/types/public/manifest.js').ServerDeserializedManifest;
|
|
195
|
+
const manifest: ServerConfigSerialized;
|
|
196
|
+
export default manifest;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
declare module 'astro:config/client' {
|
|
200
|
+
// biome-ignore format: bug
|
|
201
|
+
type ClientConfigSerialized = import('./dist/types/public/manifest.js').ClientDeserializedManifest;
|
|
202
|
+
const manifest: ClientConfigSerialized;
|
|
203
|
+
export default manifest;
|
|
204
|
+
}
|
|
205
|
+
|
|
193
206
|
declare module 'astro:components' {
|
|
194
207
|
export * from 'astro/components';
|
|
195
208
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { AstroSettings,
|
|
2
|
-
export declare function injectImageEndpoint(settings: AstroSettings, manifest:
|
|
1
|
+
import type { AstroSettings, RoutesList } from '../../types/astro.js';
|
|
2
|
+
export declare function injectImageEndpoint(settings: AstroSettings, manifest: RoutesList, mode: 'dev' | 'build', cwd?: string): void;
|
package/dist/cli/add/index.js
CHANGED
|
@@ -38,15 +38,7 @@ const STUBS = {
|
|
|
38
38
|
ASTRO_CONFIG: `import { defineConfig } from 'astro/config';
|
|
39
39
|
// https://astro.build/config
|
|
40
40
|
export default defineConfig({});`,
|
|
41
|
-
|
|
42
|
-
export default {
|
|
43
|
-
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
|
|
44
|
-
theme: {
|
|
45
|
-
extend: {},
|
|
46
|
-
},
|
|
47
|
-
plugins: [],
|
|
48
|
-
}
|
|
49
|
-
`,
|
|
41
|
+
TAILWIND_GLOBAL_CSS: `@import "tailwindcss";`,
|
|
50
42
|
SVELTE_CONFIG: `import { vitePreprocess } from '@astrojs/svelte';
|
|
51
43
|
|
|
52
44
|
export default {
|
|
@@ -133,22 +125,30 @@ async function add(names, { flags }) {
|
|
|
133
125
|
switch (installResult) {
|
|
134
126
|
case 1 /* updated */: {
|
|
135
127
|
if (integrations.find((integration) => integration.id === "tailwind")) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
128
|
+
const dir = new URL("./styles/", new URL(userConfig.srcDir ?? "./src/", root));
|
|
129
|
+
const styles = new URL("./global.css", dir);
|
|
130
|
+
if (!existsSync(styles)) {
|
|
131
|
+
logger.info(
|
|
132
|
+
"SKIP_FORMAT",
|
|
133
|
+
`
|
|
134
|
+
${magenta(`Astro will scaffold ${green("./src/styles/global.css")}.`)}
|
|
135
|
+
`
|
|
136
|
+
);
|
|
137
|
+
if (await askToContinue({ flags })) {
|
|
138
|
+
if (!existsSync(dir)) {
|
|
139
|
+
await fs.mkdir(dir);
|
|
140
|
+
}
|
|
141
|
+
await fs.writeFile(styles, STUBS.TAILWIND_GLOBAL_CSS, "utf-8");
|
|
142
|
+
} else {
|
|
143
|
+
logger.info(
|
|
144
|
+
"SKIP_FORMAT",
|
|
145
|
+
`
|
|
146
|
+
@astrojs/tailwind requires additional configuration. Please refer to https://docs.astro.build/en/guides/integrations-guide/tailwind/`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
logger.debug("add", `Using existing tailwind configuration`);
|
|
151
|
+
}
|
|
152
152
|
}
|
|
153
153
|
if (integrations.find((integration) => integration.id === "svelte")) {
|
|
154
154
|
await setupIntegrationConfig({
|
|
@@ -259,6 +259,8 @@ async function add(names, { flags }) {
|
|
|
259
259
|
)}`
|
|
260
260
|
);
|
|
261
261
|
}
|
|
262
|
+
} else if (integration.id === "tailwind") {
|
|
263
|
+
addVitePlugin(mod, "tailwindcss", "@tailwindcss/vite");
|
|
262
264
|
} else {
|
|
263
265
|
addIntegration(mod, integration);
|
|
264
266
|
}
|
|
@@ -320,6 +322,7 @@ async function add(names, { flags }) {
|
|
|
320
322
|
${list}`
|
|
321
323
|
)
|
|
322
324
|
);
|
|
325
|
+
logger.info("SKIP_FORMAT", msg.success("Import './src/styles/global.css' in a layout"));
|
|
323
326
|
}
|
|
324
327
|
}
|
|
325
328
|
const updateTSConfigResult = await updateTSConfig(cwd, logger, integrations, flags);
|
|
@@ -375,6 +378,23 @@ function addIntegration(mod, integration) {
|
|
|
375
378
|
config.integrations.push(builders.functionCall(integrationId));
|
|
376
379
|
}
|
|
377
380
|
}
|
|
381
|
+
function addVitePlugin(mod, pluginId, packageName) {
|
|
382
|
+
const config = getDefaultExportOptions(mod);
|
|
383
|
+
if (!mod.imports.$items.some((imp) => imp.local === pluginId)) {
|
|
384
|
+
mod.imports.$append({
|
|
385
|
+
imported: "default",
|
|
386
|
+
local: pluginId,
|
|
387
|
+
from: packageName
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
config.vite ??= {};
|
|
391
|
+
config.vite.plugins ??= [];
|
|
392
|
+
if (!config.vite.plugins.$ast.elements.some(
|
|
393
|
+
(el) => el.type === "CallExpression" && el.callee.type === "Identifier" && el.callee.name === pluginId
|
|
394
|
+
)) {
|
|
395
|
+
config.vite.plugins.push(builders.functionCall(pluginId));
|
|
396
|
+
}
|
|
397
|
+
}
|
|
378
398
|
function setAdapter(mod, adapter, exportName) {
|
|
379
399
|
const config = getDefaultExportOptions(mod);
|
|
380
400
|
const adapterId = toIdent(adapter.id);
|
|
@@ -660,6 +680,12 @@ async function validateIntegrations(integrations) {
|
|
|
660
680
|
)}`
|
|
661
681
|
);
|
|
662
682
|
}
|
|
683
|
+
if (integration === "tailwind") {
|
|
684
|
+
dependencies = [
|
|
685
|
+
["@tailwindcss/vite", "^4.0.0"],
|
|
686
|
+
["tailwindcss", "^4.0.0"]
|
|
687
|
+
];
|
|
688
|
+
}
|
|
663
689
|
return { id: integration, packageName, dependencies, type: integrationType };
|
|
664
690
|
})
|
|
665
691
|
);
|
package/dist/config/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRoutesList } from "../core/routing/index.js";
|
|
2
2
|
import { createDevelopmentManifest } from "../vite-plugin-astro-server/plugin.js";
|
|
3
3
|
function defineConfig(config) {
|
|
4
4
|
return config;
|
|
@@ -27,8 +27,8 @@ function getViteConfig(userViteConfig, inlineAstroConfig = {}) {
|
|
|
27
27
|
const { astroConfig: config } = await resolveConfig(inlineAstroConfig, cmd);
|
|
28
28
|
let settings = await createSettings(config, userViteConfig.root);
|
|
29
29
|
settings = await runHookConfigSetup({ settings, command: cmd, logger });
|
|
30
|
-
const
|
|
31
|
-
const
|
|
30
|
+
const routesList = await createRoutesList({ settings }, logger);
|
|
31
|
+
const manifest = createDevelopmentManifest(settings);
|
|
32
32
|
const viteConfig = await createVite(
|
|
33
33
|
{
|
|
34
34
|
plugins: config.legacy.collections ? [
|
|
@@ -36,7 +36,7 @@ function getViteConfig(userViteConfig, inlineAstroConfig = {}) {
|
|
|
36
36
|
astroContentListenPlugin({ settings, logger, fs })
|
|
37
37
|
] : []
|
|
38
38
|
},
|
|
39
|
-
{ settings, command: cmd, logger, mode, sync: false, manifest,
|
|
39
|
+
{ settings, command: cmd, logger, mode, sync: false, manifest, routesList }
|
|
40
40
|
);
|
|
41
41
|
await runHookConfigDone({ settings, logger });
|
|
42
42
|
return mergeConfig(viteConfig, userViteConfig);
|
package/dist/container/index.js
CHANGED
|
@@ -21,6 +21,12 @@ function createManifest(manifest, renderers, middleware) {
|
|
|
21
21
|
}
|
|
22
22
|
return {
|
|
23
23
|
hrefRoot: import.meta.url,
|
|
24
|
+
srcDir: manifest?.srcDir ?? ASTRO_CONFIG_DEFAULTS.srcDir,
|
|
25
|
+
buildClientDir: manifest?.buildClientDir ?? ASTRO_CONFIG_DEFAULTS.build.client,
|
|
26
|
+
buildServerDir: manifest?.buildServerDir ?? ASTRO_CONFIG_DEFAULTS.build.server,
|
|
27
|
+
publicDir: manifest?.publicDir ?? ASTRO_CONFIG_DEFAULTS.publicDir,
|
|
28
|
+
outDir: manifest?.outDir ?? ASTRO_CONFIG_DEFAULTS.outDir,
|
|
29
|
+
cacheDir: manifest?.cacheDir ?? ASTRO_CONFIG_DEFAULTS.cacheDir,
|
|
24
30
|
trailingSlash: manifest?.trailingSlash ?? ASTRO_CONFIG_DEFAULTS.trailingSlash,
|
|
25
31
|
buildFormat: manifest?.buildFormat ?? ASTRO_CONFIG_DEFAULTS.build.format,
|
|
26
32
|
compressHTML: manifest?.compressHTML ?? ASTRO_CONFIG_DEFAULTS.compressHTML,
|
|
@@ -153,7 +153,7 @@ ${contentConfig.error.message}`);
|
|
|
153
153
|
logger.info("Content config changed");
|
|
154
154
|
shouldClear = true;
|
|
155
155
|
}
|
|
156
|
-
if (previousAstroVersion && previousAstroVersion !== "5.
|
|
156
|
+
if (previousAstroVersion && previousAstroVersion !== "5.2.0") {
|
|
157
157
|
logger.info("Astro version changed");
|
|
158
158
|
shouldClear = true;
|
|
159
159
|
}
|
|
@@ -161,8 +161,8 @@ ${contentConfig.error.message}`);
|
|
|
161
161
|
logger.info("Clearing content store");
|
|
162
162
|
this.#store.clearAll();
|
|
163
163
|
}
|
|
164
|
-
if ("5.
|
|
165
|
-
await this.#store.metaStore().set("astro-version", "5.
|
|
164
|
+
if ("5.2.0") {
|
|
165
|
+
await this.#store.metaStore().set("astro-version", "5.2.0");
|
|
166
166
|
}
|
|
167
167
|
if (currentConfigDigest) {
|
|
168
168
|
await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
package/dist/core/app/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RoutesList } from '../../types/astro.js';
|
|
2
2
|
import type { RouteData, SSRManifest } from '../../types/public/internal.js';
|
|
3
3
|
import { getSetCookiesFromResponse } from '../cookies/index.js';
|
|
4
4
|
import { AstroIntegrationLogger } from '../logger/core.js';
|
|
@@ -50,7 +50,7 @@ export declare class App {
|
|
|
50
50
|
#private;
|
|
51
51
|
constructor(manifest: SSRManifest, streaming?: boolean);
|
|
52
52
|
getAdapterLogger(): AstroIntegrationLogger;
|
|
53
|
-
set setManifestData(newManifestData:
|
|
53
|
+
set setManifestData(newManifestData: RoutesList);
|
|
54
54
|
removeBase(pathname: string): string;
|
|
55
55
|
match(request: Request): RouteData | undefined;
|
|
56
56
|
render(request: Request, renderOptions?: RenderOptions): Promise<Response>;
|
package/dist/core/app/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { collapseDuplicateTrailingSlashes, hasFileExtension } from "@astrojs/internal-helpers/path";
|
|
1
2
|
import { normalizeTheLocale } from "../../i18n/index.js";
|
|
2
3
|
import {
|
|
3
4
|
REROUTABLE_STATUS_CODES,
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
} from "../path.js";
|
|
19
20
|
import { RenderContext } from "../render-context.js";
|
|
20
21
|
import { createAssetLink } from "../render/ssr-element.js";
|
|
22
|
+
import { redirectTemplate } from "../routing/3xx.js";
|
|
21
23
|
import { ensure404Route } from "../routing/astro-designed-error-pages.js";
|
|
22
24
|
import { createDefaultRoutes } from "../routing/default.js";
|
|
23
25
|
import { matchRoute } from "../routing/match.js";
|
|
@@ -164,11 +166,42 @@ class App {
|
|
|
164
166
|
}
|
|
165
167
|
return pathname;
|
|
166
168
|
}
|
|
169
|
+
#redirectTrailingSlash(pathname) {
|
|
170
|
+
const { trailingSlash } = this.#manifest;
|
|
171
|
+
if (pathname === "/" || pathname.startsWith("/_")) {
|
|
172
|
+
return pathname;
|
|
173
|
+
}
|
|
174
|
+
const path = collapseDuplicateTrailingSlashes(pathname, trailingSlash !== "never");
|
|
175
|
+
if (path !== pathname) {
|
|
176
|
+
return path;
|
|
177
|
+
}
|
|
178
|
+
if (trailingSlash === "ignore") {
|
|
179
|
+
return pathname;
|
|
180
|
+
}
|
|
181
|
+
if (trailingSlash === "always" && !hasFileExtension(pathname)) {
|
|
182
|
+
return appendForwardSlash(pathname);
|
|
183
|
+
}
|
|
184
|
+
if (trailingSlash === "never") {
|
|
185
|
+
return removeTrailingForwardSlash(pathname);
|
|
186
|
+
}
|
|
187
|
+
return pathname;
|
|
188
|
+
}
|
|
167
189
|
async render(request, renderOptions) {
|
|
168
190
|
let routeData;
|
|
169
191
|
let locals;
|
|
170
192
|
let clientAddress;
|
|
171
193
|
let addCookieHeader;
|
|
194
|
+
const url = new URL(request.url);
|
|
195
|
+
const redirect = this.#redirectTrailingSlash(url.pathname);
|
|
196
|
+
if (redirect !== url.pathname) {
|
|
197
|
+
const status = request.method === "GET" ? 301 : 308;
|
|
198
|
+
return new Response(redirectTemplate({ status, location: redirect, from: request.url }), {
|
|
199
|
+
status,
|
|
200
|
+
headers: {
|
|
201
|
+
location: redirect + url.search
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
172
205
|
addCookieHeader = renderOptions?.addCookieHeader;
|
|
173
206
|
clientAddress = renderOptions?.clientAddress ?? Reflect.get(request, clientAddressSymbol);
|
|
174
207
|
routeData = renderOptions?.routeData;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ComponentInstance,
|
|
1
|
+
import type { ComponentInstance, RoutesList } from '../../types/astro.js';
|
|
2
2
|
import type { RewritePayload } from '../../types/public/common.js';
|
|
3
3
|
import type { RouteData, SSRResult } from '../../types/public/internal.js';
|
|
4
4
|
import { Pipeline, type TryRewriteResult } from '../base-pipeline.js';
|
|
5
5
|
import type { SinglePageBuiltModule } from '../build/types.js';
|
|
6
6
|
export declare class AppPipeline extends Pipeline {
|
|
7
7
|
#private;
|
|
8
|
-
static create(manifestData:
|
|
8
|
+
static create(manifestData: RoutesList, { logger, manifest, runtimeMode, renderers, resolve, serverLike, streaming, defaultRoutes, }: Pick<AppPipeline, 'logger' | 'manifest' | 'runtimeMode' | 'renderers' | 'resolve' | 'serverLike' | 'streaming' | 'defaultRoutes'>): AppPipeline;
|
|
9
9
|
headElements(routeData: RouteData): Pick<SSRResult, 'scripts' | 'styles' | 'links'>;
|
|
10
10
|
componentMetadata(): void;
|
|
11
11
|
getComponentByRoute(routeData: RouteData): Promise<ComponentInstance>;
|
package/dist/core/app/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RoutingStrategies } from '../../i18n/utils.js';
|
|
2
2
|
import type { ComponentInstance, SerializedRouteData } from '../../types/astro.js';
|
|
3
3
|
import type { AstroMiddlewareInstance } from '../../types/public/common.js';
|
|
4
|
-
import type { Locales, ResolvedSessionConfig } from '../../types/public/config.js';
|
|
4
|
+
import type { AstroConfig, Locales, ResolvedSessionConfig } from '../../types/public/config.js';
|
|
5
5
|
import type { RouteData, SSRComponentMetadata, SSRLoadedRenderer, SSRResult } from '../../types/public/internal.js';
|
|
6
6
|
import type { SinglePageBuiltModule } from '../build/types.js';
|
|
7
7
|
export type ComponentPath = string;
|
|
@@ -38,8 +38,8 @@ export type SSRManifest = {
|
|
|
38
38
|
routes: RouteInfo[];
|
|
39
39
|
site?: string;
|
|
40
40
|
base: string;
|
|
41
|
-
trailingSlash: '
|
|
42
|
-
buildFormat: '
|
|
41
|
+
trailingSlash: AstroConfig['trailingSlash'];
|
|
42
|
+
buildFormat: NonNullable<AstroConfig['build']>['format'];
|
|
43
43
|
compressHTML: boolean;
|
|
44
44
|
assetsPrefix?: AssetsPrefix;
|
|
45
45
|
renderers: SSRLoadedRenderer[];
|
|
@@ -60,6 +60,12 @@ export type SSRManifest = {
|
|
|
60
60
|
middleware?: () => Promise<AstroMiddlewareInstance> | AstroMiddlewareInstance;
|
|
61
61
|
checkOrigin: boolean;
|
|
62
62
|
sessionConfig?: ResolvedSessionConfig<any>;
|
|
63
|
+
cacheDir: string | URL;
|
|
64
|
+
srcDir: string | URL;
|
|
65
|
+
outDir: string | URL;
|
|
66
|
+
publicDir: string | URL;
|
|
67
|
+
buildClientDir: string | URL;
|
|
68
|
+
buildServerDir: string | URL;
|
|
63
69
|
};
|
|
64
70
|
export type SSRManifestI18n = {
|
|
65
71
|
fallback: Record<string, string> | undefined;
|
|
@@ -38,7 +38,7 @@ async function generatePages(options, internals) {
|
|
|
38
38
|
const ssr = options.settings.buildOutput === "server";
|
|
39
39
|
let manifest;
|
|
40
40
|
if (ssr) {
|
|
41
|
-
manifest = await BuildPipeline.retrieveManifest(options, internals);
|
|
41
|
+
manifest = await BuildPipeline.retrieveManifest(options.settings, internals);
|
|
42
42
|
} else {
|
|
43
43
|
const baseDirectory = getOutputDirectory(options.settings);
|
|
44
44
|
const renderersEntryUrl = new URL("renderers.mjs", baseDirectory);
|
|
@@ -208,7 +208,7 @@ async function getPathsForRoute(route, mod, pipeline, builtPaths) {
|
|
|
208
208
|
if (!builtPaths.has(removeTrailingForwardSlash(staticPath))) {
|
|
209
209
|
return true;
|
|
210
210
|
}
|
|
211
|
-
const matchedRoute = matchRoute(staticPath, options.
|
|
211
|
+
const matchedRoute = matchRoute(staticPath, options.routesList);
|
|
212
212
|
return matchedRoute === route;
|
|
213
213
|
});
|
|
214
214
|
for (const staticPath of paths) {
|
|
@@ -372,6 +372,12 @@ function createBuildManifest(settings, internals, renderers, middleware, key) {
|
|
|
372
372
|
}
|
|
373
373
|
return {
|
|
374
374
|
hrefRoot: settings.config.root.toString(),
|
|
375
|
+
srcDir: settings.config.srcDir,
|
|
376
|
+
buildClientDir: settings.config.build.client,
|
|
377
|
+
buildServerDir: settings.config.build.server,
|
|
378
|
+
publicDir: settings.config.publicDir,
|
|
379
|
+
outDir: settings.config.outDir,
|
|
380
|
+
cacheDir: settings.config.cacheDir,
|
|
375
381
|
trailingSlash: settings.config.trailingSlash,
|
|
376
382
|
assets: /* @__PURE__ */ new Set(),
|
|
377
383
|
entryModules: Object.fromEntries(internals.entrySpecifierToBundleMap.entries()),
|
package/dist/core/build/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
runHookConfigDone,
|
|
11
11
|
runHookConfigSetup
|
|
12
12
|
} from "../../integrations/hooks.js";
|
|
13
|
+
import { createDevelopmentManifest } from "../../vite-plugin-astro-server/plugin.js";
|
|
13
14
|
import { resolveConfig } from "../config/config.js";
|
|
14
15
|
import { createNodeLogger } from "../config/logging.js";
|
|
15
16
|
import { createSettings } from "../config/settings.js";
|
|
@@ -18,7 +19,7 @@ import { createKey, getEnvironmentKey, hasEnvironmentKey } from "../encryption.j
|
|
|
18
19
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
19
20
|
import { levels, timerMessage } from "../logger/core.js";
|
|
20
21
|
import { apply as applyPolyfill } from "../polyfill.js";
|
|
21
|
-
import {
|
|
22
|
+
import { createRoutesList } from "../routing/index.js";
|
|
22
23
|
import { getServerIslandRouteData } from "../server-islands/endpoint.js";
|
|
23
24
|
import { clearContentLayerCache } from "../sync/index.js";
|
|
24
25
|
import { ensureProcessNodeEnv } from "../util.js";
|
|
@@ -49,9 +50,10 @@ class AstroBuilder {
|
|
|
49
50
|
mode;
|
|
50
51
|
runtimeMode;
|
|
51
52
|
origin;
|
|
52
|
-
|
|
53
|
+
routesList;
|
|
53
54
|
timer;
|
|
54
55
|
teardownCompiler;
|
|
56
|
+
manifest;
|
|
55
57
|
constructor(settings, options) {
|
|
56
58
|
this.mode = options.mode;
|
|
57
59
|
this.runtimeMode = options.runtimeMode;
|
|
@@ -59,7 +61,8 @@ class AstroBuilder {
|
|
|
59
61
|
this.logger = options.logger;
|
|
60
62
|
this.teardownCompiler = options.teardownCompiler ?? true;
|
|
61
63
|
this.origin = settings.config.site ? new URL(settings.config.site).origin : `http://localhost:${settings.config.server.port}`;
|
|
62
|
-
this.
|
|
64
|
+
this.routesList = { routes: [] };
|
|
65
|
+
this.manifest = createDevelopmentManifest(settings);
|
|
63
66
|
this.timer = {};
|
|
64
67
|
}
|
|
65
68
|
/** Setup Vite and run any async setup logic that couldn't run inside of the constructor. */
|
|
@@ -72,7 +75,7 @@ class AstroBuilder {
|
|
|
72
75
|
command: "build",
|
|
73
76
|
logger
|
|
74
77
|
});
|
|
75
|
-
this.
|
|
78
|
+
this.routesList = await createRoutesList({ settings: this.settings }, this.logger);
|
|
76
79
|
await runHookConfigDone({ settings: this.settings, logger, command: "build" });
|
|
77
80
|
if (!this.settings.config.adapter && this.settings.buildOutput === "server") {
|
|
78
81
|
throw new AstroError(AstroErrorData.NoAdapterInstalled);
|
|
@@ -90,6 +93,7 @@ class AstroBuilder {
|
|
|
90
93
|
mode: this.mode,
|
|
91
94
|
command: "build",
|
|
92
95
|
sync: false,
|
|
96
|
+
routesList: this.routesList,
|
|
93
97
|
manifest: this.manifest
|
|
94
98
|
}
|
|
95
99
|
);
|
|
@@ -99,8 +103,9 @@ class AstroBuilder {
|
|
|
99
103
|
settings: this.settings,
|
|
100
104
|
logger,
|
|
101
105
|
fs,
|
|
102
|
-
|
|
103
|
-
command: "build"
|
|
106
|
+
routesList: this.routesList,
|
|
107
|
+
command: "build",
|
|
108
|
+
manifest: this.manifest
|
|
104
109
|
});
|
|
105
110
|
return { viteConfig };
|
|
106
111
|
}
|
|
@@ -118,7 +123,7 @@ class AstroBuilder {
|
|
|
118
123
|
const { assets, allPages } = collectPagesData({
|
|
119
124
|
settings: this.settings,
|
|
120
125
|
logger: this.logger,
|
|
121
|
-
manifest: this.
|
|
126
|
+
manifest: this.routesList
|
|
122
127
|
});
|
|
123
128
|
this.logger.debug("build", timerMessage("All pages loaded", this.timer.loadStart));
|
|
124
129
|
const pageNames = [];
|
|
@@ -133,7 +138,7 @@ class AstroBuilder {
|
|
|
133
138
|
allPages,
|
|
134
139
|
settings: this.settings,
|
|
135
140
|
logger: this.logger,
|
|
136
|
-
|
|
141
|
+
routesList: this.routesList,
|
|
137
142
|
runtimeMode: this.runtimeMode,
|
|
138
143
|
origin: this.origin,
|
|
139
144
|
pageNames,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { AstroSettings,
|
|
1
|
+
import type { AstroSettings, RoutesList } from '../../types/astro.js';
|
|
2
2
|
import type { Logger } from '../logger/core.js';
|
|
3
3
|
import type { AllPagesData } from './types.js';
|
|
4
4
|
export interface CollectPagesDataOptions {
|
|
5
5
|
settings: AstroSettings;
|
|
6
6
|
logger: Logger;
|
|
7
|
-
manifest:
|
|
7
|
+
manifest: RoutesList;
|
|
8
8
|
}
|
|
9
9
|
export interface CollectPagesDataResult {
|
|
10
10
|
assets: Record<string, string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentInstance } from '../../types/astro.js';
|
|
1
|
+
import type { AstroSettings, ComponentInstance } from '../../types/astro.js';
|
|
2
2
|
import type { RewritePayload } from '../../types/public/common.js';
|
|
3
3
|
import type { RouteData, SSRResult } from '../../types/public/internal.js';
|
|
4
4
|
import type { SSRManifest } from '../app/types.js';
|
|
@@ -15,7 +15,7 @@ export declare class BuildPipeline extends Pipeline {
|
|
|
15
15
|
readonly manifest: SSRManifest;
|
|
16
16
|
readonly options: StaticBuildOptions;
|
|
17
17
|
readonly config: import("../../types/public/config.js").AstroConfig;
|
|
18
|
-
readonly settings:
|
|
18
|
+
readonly settings: AstroSettings;
|
|
19
19
|
readonly defaultRoutes: {
|
|
20
20
|
instance: ComponentInstance;
|
|
21
21
|
matchesComponent(filePath: URL): boolean;
|
|
@@ -39,7 +39,7 @@ export declare class BuildPipeline extends Pipeline {
|
|
|
39
39
|
*
|
|
40
40
|
* @param staticBuildOptions
|
|
41
41
|
*/
|
|
42
|
-
static retrieveManifest(
|
|
42
|
+
static retrieveManifest(settings: AstroSettings, internals: BuildInternals): Promise<SSRManifest>;
|
|
43
43
|
headElements(routeData: RouteData): Pick<SSRResult, 'scripts' | 'styles' | 'links'>;
|
|
44
44
|
componentMetadata(): void;
|
|
45
45
|
/**
|
|
@@ -58,7 +58,7 @@ class BuildPipeline extends Pipeline {
|
|
|
58
58
|
return this.settings.buildOutput === "server" ? this.settings.config.build.server : getOutDirWithinCwd(this.settings.config.outDir);
|
|
59
59
|
}
|
|
60
60
|
getRoutes() {
|
|
61
|
-
return this.options.
|
|
61
|
+
return this.options.routesList.routes;
|
|
62
62
|
}
|
|
63
63
|
static create({
|
|
64
64
|
internals,
|
|
@@ -80,8 +80,8 @@ class BuildPipeline extends Pipeline {
|
|
|
80
80
|
*
|
|
81
81
|
* @param staticBuildOptions
|
|
82
82
|
*/
|
|
83
|
-
static async retrieveManifest(
|
|
84
|
-
const baseDirectory = getOutputDirectory(
|
|
83
|
+
static async retrieveManifest(settings, internals) {
|
|
84
|
+
const baseDirectory = getOutputDirectory(settings);
|
|
85
85
|
const manifestEntryUrl = new URL(
|
|
86
86
|
`${internals.manifestFileName}?time=${Date.now()}`,
|
|
87
87
|
baseDirectory
|
|
@@ -198,7 +198,7 @@ class BuildPipeline extends Pipeline {
|
|
|
198
198
|
const { routeData, pathname, newUrl } = findRouteToRewrite({
|
|
199
199
|
payload,
|
|
200
200
|
request,
|
|
201
|
-
routes: this.options.
|
|
201
|
+
routes: this.options.routesList.routes,
|
|
202
202
|
trailingSlash: this.config.trailingSlash,
|
|
203
203
|
buildFormat: this.config.build.format,
|
|
204
204
|
base: this.config.base
|
|
@@ -135,7 +135,7 @@ function buildManifest(opts, internals, staticFiles, encodedKey) {
|
|
|
135
135
|
return prependForwardSlash(joinPaths(settings.config.base, pth));
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
|
-
for (const route of opts.
|
|
138
|
+
for (const route of opts.routesList.routes) {
|
|
139
139
|
if (!DEFAULT_COMPONENTS.find((component) => route.component === component)) {
|
|
140
140
|
continue;
|
|
141
141
|
}
|
|
@@ -147,7 +147,7 @@ function buildManifest(opts, internals, staticFiles, encodedKey) {
|
|
|
147
147
|
routeData: serializeRouteData(route, settings.config.trailingSlash)
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
|
-
for (const route of opts.
|
|
150
|
+
for (const route of opts.routesList.routes) {
|
|
151
151
|
if (!route.prerender) continue;
|
|
152
152
|
if (!route.pathname) continue;
|
|
153
153
|
const outFolder = getOutFolder(opts.settings, route.pathname, route);
|
|
@@ -162,7 +162,7 @@ function buildManifest(opts, internals, staticFiles, encodedKey) {
|
|
|
162
162
|
});
|
|
163
163
|
staticFiles.push(file);
|
|
164
164
|
}
|
|
165
|
-
for (const route of opts.
|
|
165
|
+
for (const route of opts.routesList.routes) {
|
|
166
166
|
const pageData = internals.pagesByKeys.get(makePageDataKey(route.route, route.component));
|
|
167
167
|
if (route.prerender || !pageData) continue;
|
|
168
168
|
const scripts = [];
|
|
@@ -208,6 +208,12 @@ function buildManifest(opts, internals, staticFiles, encodedKey) {
|
|
|
208
208
|
}
|
|
209
209
|
return {
|
|
210
210
|
hrefRoot: opts.settings.config.root.toString(),
|
|
211
|
+
cacheDir: opts.settings.config.cacheDir.toString(),
|
|
212
|
+
outDir: opts.settings.config.outDir.toString(),
|
|
213
|
+
srcDir: opts.settings.config.srcDir.toString(),
|
|
214
|
+
publicDir: opts.settings.config.publicDir.toString(),
|
|
215
|
+
buildClientDir: opts.settings.config.build.client.toString(),
|
|
216
|
+
buildServerDir: opts.settings.config.build.server.toString(),
|
|
211
217
|
adapterName: opts.settings.adapter?.name ?? "",
|
|
212
218
|
routes,
|
|
213
219
|
site: settings.config.site,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as vite from 'vite';
|
|
2
2
|
import type { InlineConfig } from 'vite';
|
|
3
|
-
import type { AstroSettings, ComponentInstance,
|
|
3
|
+
import type { AstroSettings, ComponentInstance, RoutesList } from '../../types/astro.js';
|
|
4
4
|
import type { MiddlewareHandler } from '../../types/public/common.js';
|
|
5
5
|
import type { RuntimeMode } from '../../types/public/config.js';
|
|
6
6
|
import type { RouteData, SSRLoadedRenderer } from '../../types/public/internal.js';
|
|
@@ -32,7 +32,7 @@ export interface StaticBuildOptions {
|
|
|
32
32
|
allPages: AllPagesData;
|
|
33
33
|
settings: AstroSettings;
|
|
34
34
|
logger: Logger;
|
|
35
|
-
|
|
35
|
+
routesList: RoutesList;
|
|
36
36
|
runtimeMode: RuntimeMode;
|
|
37
37
|
origin: string;
|
|
38
38
|
pageNames: string[];
|