astro 5.5.6 → 5.6.1
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 +1 -16
- package/dist/actions/plugins.js +1 -1
- package/dist/assets/runtime.js +5 -29
- package/dist/assets/utils/svg.d.ts +1 -4
- package/dist/assets/utils/svg.js +2 -2
- package/dist/assets/vite-plugin-assets.js +31 -30
- package/dist/container/index.js +1 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/content/vite-plugin-content-virtual-mod.js +7 -9
- package/dist/core/app/index.d.ts +15 -0
- package/dist/core/app/index.js +27 -7
- package/dist/core/build/index.js +2 -2
- package/dist/core/build/plugins/plugin-component-entry.js +3 -1
- package/dist/core/build/plugins/plugin-manifest.js +1 -1
- package/dist/core/build/plugins/plugin-pages.js +1 -1
- package/dist/core/build/plugins/plugin-prerender.js +3 -0
- package/dist/core/build/plugins/plugin-renderers.js +3 -3
- package/dist/core/build/plugins/plugin-ssr.js +2 -2
- package/dist/core/config/index.d.ts +1 -1
- package/dist/core/config/schemas/base.d.ts +1110 -0
- package/dist/core/config/{schema.js → schemas/base.js} +9 -254
- package/dist/core/config/schemas/index.d.ts +3 -0
- package/dist/core/config/schemas/index.js +9 -0
- package/dist/core/config/schemas/refined.d.ts +3 -0
- package/dist/core/config/schemas/refined.js +141 -0
- package/dist/core/config/schemas/relative.d.ts +1462 -0
- package/dist/core/config/schemas/relative.js +93 -0
- package/dist/core/config/validate.d.ts +6 -0
- package/dist/core/config/validate.js +9 -3
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/vite-plugin.js +3 -3
- package/dist/core/server-islands/vite-plugin-server-islands.js +1 -1
- package/dist/core/session.d.ts +8 -0
- package/dist/core/session.js +13 -0
- package/dist/env/vite-plugin-env.js +3 -3
- package/dist/events/session.js +1 -1
- package/dist/integrations/hooks.d.ts +4 -4
- package/dist/integrations/hooks.js +276 -280
- package/dist/manifest/virtual-module.js +2 -2
- package/dist/prefetch/index.d.ts +8 -0
- package/dist/prefetch/index.js +6 -4
- package/dist/prefetch/vite-plugin-prefetch.js +1 -1
- package/dist/toolbar/vite-plugin-dev-toolbar.js +41 -39
- package/dist/transitions/vite-plugin-transitions.js +22 -18
- package/dist/types/public/config.d.ts +3 -25
- package/dist/vite-plugin-load-fallback/index.js +4 -2
- package/dist/vite-plugin-scripts/index.js +9 -3
- package/dist/vite-plugin-ssr-manifest/index.js +4 -3
- package/package.json +4 -4
- package/dist/core/config/schema.d.ts +0 -3402
package/client.d.ts
CHANGED
|
@@ -108,22 +108,7 @@ declare module '*.avif' {
|
|
|
108
108
|
export default metadata;
|
|
109
109
|
}
|
|
110
110
|
declare module '*.svg' {
|
|
111
|
-
type Props =
|
|
112
|
-
/**
|
|
113
|
-
* Accessible, short-text description
|
|
114
|
-
*
|
|
115
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title|MDN Reference}
|
|
116
|
-
*/
|
|
117
|
-
title?: string;
|
|
118
|
-
/**
|
|
119
|
-
* Shorthand for setting the `height` and `width` properties
|
|
120
|
-
*/
|
|
121
|
-
size?: number | string;
|
|
122
|
-
/**
|
|
123
|
-
* Override the default rendering mode for SVGs
|
|
124
|
-
*/
|
|
125
|
-
mode?: import('./dist/assets/utils/svg.js').SvgRenderMode;
|
|
126
|
-
} & astroHTML.JSX.SVGAttributes;
|
|
111
|
+
type Props = astroHTML.JSX.SVGAttributes;
|
|
127
112
|
|
|
128
113
|
const Component: ((_props: Props) => any) & ImageMetadata;
|
|
129
114
|
export default Component;
|
package/dist/actions/plugins.js
CHANGED
package/dist/assets/runtime.js
CHANGED
|
@@ -4,30 +4,10 @@ import {
|
|
|
4
4
|
spreadAttributes,
|
|
5
5
|
unescapeHTML
|
|
6
6
|
} from "../runtime/server/index.js";
|
|
7
|
-
const countersByPage = /* @__PURE__ */ new WeakMap();
|
|
8
7
|
function createSvgComponent({ meta, attributes, children }) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const {
|
|
13
|
-
title: titleProp,
|
|
14
|
-
viewBox,
|
|
15
|
-
mode,
|
|
16
|
-
...normalizedProps
|
|
17
|
-
} = normalizeProps(attributes, props);
|
|
18
|
-
const title = titleProp ? unescapeHTML(`<title>${titleProp}</title>`) : "";
|
|
19
|
-
if (mode === "sprite") {
|
|
20
|
-
let symbol = "";
|
|
21
|
-
let id = renderedIds.get(result);
|
|
22
|
-
if (!id) {
|
|
23
|
-
countersByPage.set(result, ++counter);
|
|
24
|
-
id = `a:${counter}`;
|
|
25
|
-
symbol = unescapeHTML(`<symbol${spreadAttributes({ viewBox, id })}>${children}</symbol>`);
|
|
26
|
-
renderedIds.set(result, id);
|
|
27
|
-
}
|
|
28
|
-
return render`<svg${spreadAttributes(normalizedProps)}>${title}${symbol}<use href="#${id}" /></svg>`;
|
|
29
|
-
}
|
|
30
|
-
return render`<svg${spreadAttributes({ viewBox, ...normalizedProps })}>${title}${unescapeHTML(children)}</svg>`;
|
|
8
|
+
const Component = createComponent((_, props) => {
|
|
9
|
+
const normalizedProps = normalizeProps(attributes, props);
|
|
10
|
+
return render`<svg${spreadAttributes(normalizedProps)}>${unescapeHTML(children)}</svg>`;
|
|
31
11
|
});
|
|
32
12
|
if (import.meta.env.DEV) {
|
|
33
13
|
makeNonEnumerable(Component);
|
|
@@ -38,18 +18,14 @@ function createSvgComponent({ meta, attributes, children }) {
|
|
|
38
18
|
return Object.assign(Component, meta);
|
|
39
19
|
}
|
|
40
20
|
const ATTRS_TO_DROP = ["xmlns", "xmlns:xlink", "version"];
|
|
41
|
-
const DEFAULT_ATTRS = {
|
|
21
|
+
const DEFAULT_ATTRS = {};
|
|
42
22
|
function dropAttributes(attributes) {
|
|
43
23
|
for (const attr of ATTRS_TO_DROP) {
|
|
44
24
|
delete attributes[attr];
|
|
45
25
|
}
|
|
46
26
|
return attributes;
|
|
47
27
|
}
|
|
48
|
-
function normalizeProps(attributes,
|
|
49
|
-
if (size !== void 0 && props.width === void 0 && props.height === void 0) {
|
|
50
|
-
props.height = size;
|
|
51
|
-
props.width = size;
|
|
52
|
-
}
|
|
28
|
+
function normalizeProps(attributes, props) {
|
|
53
29
|
return dropAttributes({ ...DEFAULT_ATTRS, ...attributes, ...props });
|
|
54
30
|
}
|
|
55
31
|
function makeNonEnumerable(object) {
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import type { ImageMetadata } from '../types.js';
|
|
2
|
-
export
|
|
3
|
-
export declare function makeSvgComponent(meta: ImageMetadata, contents: Buffer | string, options?: {
|
|
4
|
-
mode?: SvgRenderMode;
|
|
5
|
-
}): string;
|
|
2
|
+
export declare function makeSvgComponent(meta: ImageMetadata, contents: Buffer | string): string;
|
package/dist/assets/utils/svg.js
CHANGED
|
@@ -12,12 +12,12 @@ function parseSvg(contents) {
|
|
|
12
12
|
const body = renderSync({ ...root, children });
|
|
13
13
|
return { attributes, body };
|
|
14
14
|
}
|
|
15
|
-
function makeSvgComponent(meta, contents
|
|
15
|
+
function makeSvgComponent(meta, contents) {
|
|
16
16
|
const file = typeof contents === "string" ? contents : contents.toString("utf-8");
|
|
17
17
|
const { attributes, body: children } = parseSvg(file);
|
|
18
18
|
const props = {
|
|
19
19
|
meta,
|
|
20
|
-
attributes: dropAttributes(
|
|
20
|
+
attributes: dropAttributes(attributes),
|
|
21
21
|
children
|
|
22
22
|
};
|
|
23
23
|
return `import { createSvgComponent } from 'astro/assets/runtime';
|
|
@@ -88,33 +88,32 @@ function assets({ settings }) {
|
|
|
88
88
|
},
|
|
89
89
|
load(id) {
|
|
90
90
|
if (id === resolvedVirtualModuleId) {
|
|
91
|
-
return
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
export { inferRemoteSize } from "astro/assets/utils/inferRemoteSize.js";
|
|
91
|
+
return {
|
|
92
|
+
code: `
|
|
93
|
+
export { getConfiguredImageService, isLocalService } from "astro/assets";
|
|
94
|
+
import { getImage as getImageInternal } from "astro/assets";
|
|
95
|
+
export { default as Image } from "astro/components/${imageComponentPrefix}Image.astro";
|
|
96
|
+
export { default as Picture } from "astro/components/${imageComponentPrefix}Picture.astro";
|
|
97
|
+
export { inferRemoteSize } from "astro/assets/utils/inferRemoteSize.js";
|
|
99
98
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
99
|
+
export const imageConfig = ${JSON.stringify({ ...settings.config.image, experimentalResponsiveImages: settings.config.experimental.responsiveImages })};
|
|
100
|
+
// This is used by the @astrojs/node integration to locate images.
|
|
101
|
+
// It's unused on other platforms, but on some platforms like Netlify (and presumably also Vercel)
|
|
102
|
+
// new URL("dist/...") is interpreted by the bundler as a signal to include that directory
|
|
103
|
+
// in the Lambda bundle, which would bloat the bundle with images.
|
|
104
|
+
// To prevent this, we mark the URL construction as pure,
|
|
105
|
+
// so that it's tree-shaken away for all platforms that don't need it.
|
|
106
|
+
export const outDir = /* #__PURE__ */ new URL(${JSON.stringify(
|
|
108
107
|
new URL(
|
|
109
108
|
settings.buildOutput === "server" ? settings.config.build.client : settings.config.outDir
|
|
110
109
|
)
|
|
111
110
|
)});
|
|
112
|
-
|
|
111
|
+
export const assetsDir = /* #__PURE__ */ new URL(${JSON.stringify(
|
|
113
112
|
settings.config.build.assets
|
|
114
113
|
)}, outDir);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
export const getImage = async (options) => await getImageInternal(options, imageConfig);
|
|
115
|
+
`
|
|
116
|
+
};
|
|
118
117
|
}
|
|
119
118
|
},
|
|
120
119
|
buildStart() {
|
|
@@ -123,7 +122,7 @@ function assets({ settings }) {
|
|
|
123
122
|
},
|
|
124
123
|
// In build, rewrite paths to ESM imported images in code to their final location
|
|
125
124
|
async renderChunk(code) {
|
|
126
|
-
const assetUrlRE = /__ASTRO_ASSET_IMAGE__([\w$]
|
|
125
|
+
const assetUrlRE = /__ASTRO_ASSET_IMAGE__([\w$]+)__(?:_(.*?)__)?/g;
|
|
127
126
|
let match;
|
|
128
127
|
let s;
|
|
129
128
|
while (match = assetUrlRE.exec(code)) {
|
|
@@ -167,7 +166,7 @@ function assets({ settings }) {
|
|
|
167
166
|
if (!assetRegexEnds.test(id)) {
|
|
168
167
|
return;
|
|
169
168
|
}
|
|
170
|
-
const emitFile = shouldEmitFile ? this.emitFile : void 0;
|
|
169
|
+
const emitFile = shouldEmitFile ? this.emitFile.bind(this) : void 0;
|
|
171
170
|
const imageMetadata = await emitESMImage(
|
|
172
171
|
id,
|
|
173
172
|
this.meta.watchMode,
|
|
@@ -182,18 +181,20 @@ function assets({ settings }) {
|
|
|
182
181
|
}
|
|
183
182
|
if (settings.config.experimental.svg && /\.svg$/.test(id)) {
|
|
184
183
|
const { contents, ...metadata } = imageMetadata;
|
|
185
|
-
return makeSvgComponent(metadata, contents
|
|
186
|
-
mode: settings.config.experimental.svg.mode
|
|
187
|
-
});
|
|
184
|
+
return { code: makeSvgComponent(metadata, contents) };
|
|
188
185
|
}
|
|
189
186
|
if (options?.ssr) {
|
|
190
|
-
return
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
return {
|
|
188
|
+
code: `export default ${getProxyCode(
|
|
189
|
+
imageMetadata,
|
|
190
|
+
settings.buildOutput === "server"
|
|
191
|
+
)}`
|
|
192
|
+
};
|
|
194
193
|
} else {
|
|
195
194
|
globalThis.astroAsset.referencedImages.add(imageMetadata.fsPath);
|
|
196
|
-
return
|
|
195
|
+
return {
|
|
196
|
+
code: `export default ${JSON.stringify(imageMetadata)}`
|
|
197
|
+
};
|
|
197
198
|
}
|
|
198
199
|
}
|
|
199
200
|
}
|
package/dist/container/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./polyfill.js";
|
|
2
2
|
import { posix } from "node:path";
|
|
3
3
|
import { getDefaultClientDirectives } from "../core/client-directive/index.js";
|
|
4
|
-
import { ASTRO_CONFIG_DEFAULTS } from "../core/config/
|
|
4
|
+
import { ASTRO_CONFIG_DEFAULTS } from "../core/config/schemas/index.js";
|
|
5
5
|
import { validateConfig } from "../core/config/validate.js";
|
|
6
6
|
import { createKey } from "../core/encryption.js";
|
|
7
7
|
import { Logger } from "../core/logger/core.js";
|
|
@@ -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.6.1") {
|
|
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.6.1") {
|
|
165
|
+
await this.#store.metaStore().set("astro-version", "5.6.1");
|
|
166
166
|
}
|
|
167
167
|
if (currentConfigDigest) {
|
|
168
168
|
await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
|
@@ -122,7 +122,7 @@ function astroContentVirtualModPlugin({
|
|
|
122
122
|
}
|
|
123
123
|
if (id === RESOLVED_DATA_STORE_VIRTUAL_ID) {
|
|
124
124
|
if (!fs.existsSync(dataStoreFile)) {
|
|
125
|
-
return "export default new Map()";
|
|
125
|
+
return { code: "export default new Map()" };
|
|
126
126
|
}
|
|
127
127
|
const jsonData = await fs.promises.readFile(dataStoreFile, "utf-8");
|
|
128
128
|
try {
|
|
@@ -140,17 +140,15 @@ function astroContentVirtualModPlugin({
|
|
|
140
140
|
}
|
|
141
141
|
if (id === ASSET_IMPORTS_RESOLVED_STUB_ID) {
|
|
142
142
|
const assetImportsFile = new URL(ASSET_IMPORTS_FILE, settings.dotAstroDir);
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
return fs.readFileSync(assetImportsFile, "utf-8");
|
|
143
|
+
return {
|
|
144
|
+
code: fs.existsSync(assetImportsFile) ? fs.readFileSync(assetImportsFile, "utf-8") : "export default new Map()"
|
|
145
|
+
};
|
|
147
146
|
}
|
|
148
147
|
if (id === MODULES_MJS_VIRTUAL_ID) {
|
|
149
148
|
const modules = new URL(MODULES_IMPORTS_FILE, settings.dotAstroDir);
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
return fs.readFileSync(modules, "utf-8");
|
|
149
|
+
return {
|
|
150
|
+
code: fs.existsSync(modules) ? fs.readFileSync(modules, "utf-8") : "export default new Map()"
|
|
151
|
+
};
|
|
154
152
|
}
|
|
155
153
|
},
|
|
156
154
|
configureServer(server) {
|
package/dist/core/app/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ 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';
|
|
5
5
|
export { deserializeManifest } from './common.js';
|
|
6
|
+
type ErrorPagePath = `${string}/404` | `${string}/500` | `${string}/404/` | `${string}/500/` | `${string}404.html` | `${string}500.html`;
|
|
6
7
|
export interface RenderOptions {
|
|
7
8
|
/**
|
|
8
9
|
* Whether to automatically add all cookies written by `Astro.cookie.set()` to the response headers.
|
|
@@ -24,6 +25,19 @@ export interface RenderOptions {
|
|
|
24
25
|
* The mutable object that will be made available as `Astro.locals` in pages, and as `ctx.locals` in API routes and middleware.
|
|
25
26
|
*/
|
|
26
27
|
locals?: object;
|
|
28
|
+
/**
|
|
29
|
+
* A custom fetch function for retrieving prerendered pages - 404 or 500.
|
|
30
|
+
*
|
|
31
|
+
* If not provided, Astro will fallback to its default behavior for fetching error pages.
|
|
32
|
+
*
|
|
33
|
+
* When a dynamic route is matched but ultimately results in a 404, this function will be used
|
|
34
|
+
* to fetch the prerendered 404 page if available. Similarly, it may be used to fetch a
|
|
35
|
+
* prerendered 500 error page when necessary.
|
|
36
|
+
*
|
|
37
|
+
* @param {ErrorPagePath} url - The URL of the prerendered 404 or 500 error page to fetch.
|
|
38
|
+
* @returns {Promise<Response>} A promise resolving to the prerendered response.
|
|
39
|
+
*/
|
|
40
|
+
prerenderedErrorPageFetch?: (url: ErrorPagePath) => Promise<Response>;
|
|
27
41
|
/**
|
|
28
42
|
* **Advanced API**: you probably do not need to use this.
|
|
29
43
|
*
|
|
@@ -45,6 +59,7 @@ export interface RenderErrorOptions {
|
|
|
45
59
|
*/
|
|
46
60
|
error?: unknown;
|
|
47
61
|
clientAddress: string | undefined;
|
|
62
|
+
prerenderedErrorPageFetch: (url: ErrorPagePath) => Promise<Response>;
|
|
48
63
|
}
|
|
49
64
|
export declare class App {
|
|
50
65
|
#private;
|
package/dist/core/app/index.js
CHANGED
|
@@ -193,6 +193,7 @@ class App {
|
|
|
193
193
|
let addCookieHeader;
|
|
194
194
|
const url = new URL(request.url);
|
|
195
195
|
const redirect = this.#redirectTrailingSlash(url.pathname);
|
|
196
|
+
const prerenderedErrorPageFetch = renderOptions?.prerenderedErrorPageFetch ?? fetch;
|
|
196
197
|
if (redirect !== url.pathname) {
|
|
197
198
|
const status = request.method === "GET" ? 301 : 308;
|
|
198
199
|
return new Response(
|
|
@@ -226,7 +227,12 @@ class App {
|
|
|
226
227
|
if (typeof locals !== "object") {
|
|
227
228
|
const error = new AstroError(AstroErrorData.LocalsNotAnObject);
|
|
228
229
|
this.#logger.error(null, error.stack);
|
|
229
|
-
return this.#renderError(request, {
|
|
230
|
+
return this.#renderError(request, {
|
|
231
|
+
status: 500,
|
|
232
|
+
error,
|
|
233
|
+
clientAddress,
|
|
234
|
+
prerenderedErrorPageFetch
|
|
235
|
+
});
|
|
230
236
|
}
|
|
231
237
|
}
|
|
232
238
|
if (!routeData) {
|
|
@@ -242,7 +248,12 @@ class App {
|
|
|
242
248
|
if (!routeData) {
|
|
243
249
|
this.#logger.debug("router", "Astro hasn't found routes that match " + request.url);
|
|
244
250
|
this.#logger.debug("router", "Here's the available routes:\n", this.#manifestData);
|
|
245
|
-
return this.#renderError(request, {
|
|
251
|
+
return this.#renderError(request, {
|
|
252
|
+
locals,
|
|
253
|
+
status: 404,
|
|
254
|
+
clientAddress,
|
|
255
|
+
prerenderedErrorPageFetch
|
|
256
|
+
});
|
|
246
257
|
}
|
|
247
258
|
const pathname = this.#getPathnameFromRequest(request);
|
|
248
259
|
const defaultStatus = this.#getDefaultStatusCode(routeData, pathname);
|
|
@@ -263,7 +274,13 @@ class App {
|
|
|
263
274
|
response = await renderContext.render(await mod.page());
|
|
264
275
|
} catch (err) {
|
|
265
276
|
this.#logger.error(null, err.stack || err.message || String(err));
|
|
266
|
-
return this.#renderError(request, {
|
|
277
|
+
return this.#renderError(request, {
|
|
278
|
+
locals,
|
|
279
|
+
status: 500,
|
|
280
|
+
error: err,
|
|
281
|
+
clientAddress,
|
|
282
|
+
prerenderedErrorPageFetch
|
|
283
|
+
});
|
|
267
284
|
} finally {
|
|
268
285
|
await session?.[PERSIST_SYMBOL]();
|
|
269
286
|
}
|
|
@@ -275,7 +292,8 @@ class App {
|
|
|
275
292
|
// We don't have an error to report here. Passing null means we pass nothing intentionally
|
|
276
293
|
// while undefined means there's no error
|
|
277
294
|
error: response.status === 500 ? null : void 0,
|
|
278
|
-
clientAddress
|
|
295
|
+
clientAddress,
|
|
296
|
+
prerenderedErrorPageFetch
|
|
279
297
|
});
|
|
280
298
|
}
|
|
281
299
|
if (response.headers.has(REROUTE_DIRECTIVE_HEADER)) {
|
|
@@ -314,7 +332,8 @@ class App {
|
|
|
314
332
|
response: originalResponse,
|
|
315
333
|
skipMiddleware = false,
|
|
316
334
|
error,
|
|
317
|
-
clientAddress
|
|
335
|
+
clientAddress,
|
|
336
|
+
prerenderedErrorPageFetch
|
|
318
337
|
}) {
|
|
319
338
|
const errorRoutePath = `/${status}${this.#manifest.trailingSlash === "always" ? "/" : ""}`;
|
|
320
339
|
const errorRouteData = matchRoute(errorRoutePath, this.#manifestData);
|
|
@@ -327,7 +346,7 @@ class App {
|
|
|
327
346
|
url
|
|
328
347
|
);
|
|
329
348
|
if (statusURL.toString() !== request.url) {
|
|
330
|
-
const response2 = await
|
|
349
|
+
const response2 = await prerenderedErrorPageFetch(statusURL.toString());
|
|
331
350
|
const override = { status };
|
|
332
351
|
return this.#mergeResponses(response2, originalResponse, override);
|
|
333
352
|
}
|
|
@@ -356,7 +375,8 @@ class App {
|
|
|
356
375
|
status,
|
|
357
376
|
response: originalResponse,
|
|
358
377
|
skipMiddleware: true,
|
|
359
|
-
clientAddress
|
|
378
|
+
clientAddress,
|
|
379
|
+
prerenderedErrorPageFetch
|
|
360
380
|
});
|
|
361
381
|
}
|
|
362
382
|
} finally {
|
package/dist/core/build/index.js
CHANGED
|
@@ -111,7 +111,7 @@ class AstroBuilder {
|
|
|
111
111
|
}
|
|
112
112
|
/** Run the build logic. build() is marked private because usage should go through ".run()" */
|
|
113
113
|
async build({ viteConfig }) {
|
|
114
|
-
await runHookBuildStart({ config: this.settings.config,
|
|
114
|
+
await runHookBuildStart({ config: this.settings.config, logger: this.logger });
|
|
115
115
|
this.validateConfig();
|
|
116
116
|
this.logger.info("build", `output: ${blue('"' + this.settings.config.output + '"')}`);
|
|
117
117
|
this.logger.info("build", `mode: ${blue('"' + this.settings.buildOutput + '"')}`);
|
|
@@ -166,7 +166,7 @@ class AstroBuilder {
|
|
|
166
166
|
settings: this.settings,
|
|
167
167
|
pages: pageNames,
|
|
168
168
|
routes: Object.values(allPages).flat().map((pageData) => pageData.route).concat(hasServerIslands ? getServerIslandRouteData(this.settings.config) : []),
|
|
169
|
-
|
|
169
|
+
logger: this.logger
|
|
170
170
|
});
|
|
171
171
|
if (this.logger.level && levels[this.logger.level()] <= levels["info"]) {
|
|
172
172
|
await this.printStats({
|
|
@@ -44,7 +44,9 @@ function vitePluginComponentEntry(internals) {
|
|
|
44
44
|
const componentId = id.slice(astroEntryPrefix.length);
|
|
45
45
|
const exportNames = componentToExportNames.get(componentId);
|
|
46
46
|
if (exportNames) {
|
|
47
|
-
return
|
|
47
|
+
return {
|
|
48
|
+
code: `export { ${exportNames.join(", ")} } from ${JSON.stringify(componentId)}`
|
|
49
|
+
};
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
}
|
|
@@ -48,7 +48,7 @@ function vitePluginManifest(options, internals) {
|
|
|
48
48
|
`_privateSetManifestDontUseThis(manifest);`
|
|
49
49
|
];
|
|
50
50
|
const exports = [`export { manifest }`];
|
|
51
|
-
return [...imports, ...contents, ...exports].join("\n");
|
|
51
|
+
return { code: [...imports, ...contents, ...exports].join("\n") };
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
async generateBundle(_opts, bundle) {
|
|
@@ -40,7 +40,7 @@ function vitePluginPages(opts, internals) {
|
|
|
40
40
|
exports.push(`export const page = () => _page`);
|
|
41
41
|
imports.push(`import { renderers } from "${RENDERERS_MODULE_ID}";`);
|
|
42
42
|
exports.push(`export { renderers };`);
|
|
43
|
-
return `${imports.join("\n")}${exports.join("\n")}
|
|
43
|
+
return { code: `${imports.join("\n")}${exports.join("\n")}` };
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -41,6 +41,9 @@ function getNonPrerenderOnlyChunks(bundle, internals) {
|
|
|
41
41
|
}
|
|
42
42
|
nonPrerenderOnlyEntryChunks.add(chunk);
|
|
43
43
|
}
|
|
44
|
+
if (chunk.type === "chunk" && chunk.isDynamicEntry) {
|
|
45
|
+
nonPrerenderOnlyEntryChunks.add(chunk);
|
|
46
|
+
}
|
|
44
47
|
}
|
|
45
48
|
const nonPrerenderOnlyChunks = new Set(nonPrerenderOnlyEntryChunks);
|
|
46
49
|
for (const chunk of nonPrerenderOnlyChunks) {
|
|
@@ -26,10 +26,10 @@ function vitePluginRenderers(opts) {
|
|
|
26
26
|
i++;
|
|
27
27
|
}
|
|
28
28
|
exports.push(`export const renderers = [${rendererItems}];`);
|
|
29
|
-
return `${imports.join("\n")}
|
|
30
|
-
${exports.join("\n")}
|
|
29
|
+
return { code: `${imports.join("\n")}
|
|
30
|
+
${exports.join("\n")}` };
|
|
31
31
|
} else {
|
|
32
|
-
return `export const renderers = []
|
|
32
|
+
return { code: `export const renderers = [];` };
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -22,7 +22,7 @@ function vitePluginAdapter(adapter) {
|
|
|
22
22
|
},
|
|
23
23
|
async load(id) {
|
|
24
24
|
if (id === RESOLVED_ADAPTER_VIRTUAL_MODULE_ID) {
|
|
25
|
-
return `export * from ${JSON.stringify(adapter.serverEntrypoint)}
|
|
25
|
+
return { code: `export * from ${JSON.stringify(adapter.serverEntrypoint)};` };
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
};
|
|
@@ -86,7 +86,7 @@ function vitePluginSSR(internals, adapter, options) {
|
|
|
86
86
|
const ssrCode = generateSSRCode(adapter, middleware.id);
|
|
87
87
|
imports.push(...ssrCode.imports);
|
|
88
88
|
contents.push(...ssrCode.contents);
|
|
89
|
-
return [...imports, ...contents, ...exports].join("\n");
|
|
89
|
+
return { code: [...imports, ...contents, ...exports].join("\n") };
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
92
|
async generateBundle(_opts, bundle) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { configPaths, resolveConfig, resolveConfigPath, resolveRoot, } from './config.js';
|
|
2
2
|
export { createNodeLogger } from './logging.js';
|
|
3
3
|
export { mergeConfig } from './merge.js';
|
|
4
|
-
export type { AstroConfigType } from './
|
|
4
|
+
export type { AstroConfigType } from './schemas/index.js';
|
|
5
5
|
export { createSettings } from './settings.js';
|
|
6
6
|
export { loadTSConfig, updateTSConfigForFramework } from './tsconfig.js';
|