astro 5.0.0-beta.5 → 5.0.0-beta.6
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 -0
- package/dist/actions/runtime/middleware.js +10 -4
- package/dist/actions/runtime/route.js +2 -1
- package/dist/actions/runtime/virtual/get-action.js +1 -1
- package/dist/assets/endpoint/node.js +4 -0
- package/dist/assets/internal.js +2 -1
- package/dist/assets/vite-plugin-assets.d.ts +3 -3
- package/dist/assets/vite-plugin-assets.js +6 -7
- package/dist/cli/add/index.js +1 -1
- package/dist/cli/build/index.js +6 -1
- package/dist/cli/dev/index.js +1 -0
- package/dist/cli/index.js +1 -1
- package/dist/cli/install-package.js +7 -1
- package/dist/config/entrypoint.d.ts +15 -0
- package/dist/config/entrypoint.js +21 -0
- package/dist/config/index.d.ts +11 -7
- package/dist/config/index.js +2 -3
- package/dist/container/index.d.ts +7 -0
- package/dist/container/index.js +2 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/content/types-generator.js +10 -3
- package/dist/content/vite-plugin-content-assets.d.ts +1 -2
- package/dist/content/vite-plugin-content-assets.js +1 -4
- package/dist/content/vite-plugin-content-virtual-mod.js +1 -1
- package/dist/core/app/index.js +1 -1
- package/dist/core/app/middlewares.js +4 -1
- package/dist/core/app/node.js +1 -1
- package/dist/core/app/pipeline.d.ts +1 -1
- package/dist/core/app/pipeline.js +2 -2
- package/dist/core/base-pipeline.d.ts +4 -4
- package/dist/core/base-pipeline.js +2 -2
- package/dist/core/build/index.d.ts +7 -0
- package/dist/core/build/index.js +10 -9
- package/dist/core/build/pipeline.js +1 -1
- package/dist/core/build/static-build.js +0 -2
- package/dist/core/build/types.d.ts +1 -1
- package/dist/core/constants.d.ts +4 -0
- package/dist/core/constants.js +3 -1
- package/dist/core/create-vite.d.ts +4 -3
- package/dist/core/create-vite.js +7 -6
- package/dist/core/dev/container.js +3 -2
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.d.ts +6 -7
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/vite-plugin.js +1 -2
- package/dist/core/preview/vite-plugin-astro-preview.js +1 -1
- package/dist/core/render/params-and-props.js +1 -1
- package/dist/core/render/route-cache.d.ts +2 -2
- package/dist/core/render/route-cache.js +4 -4
- package/dist/core/render-context.d.ts +2 -1
- package/dist/core/render-context.js +25 -37
- package/dist/core/routing/astro-designed-error-pages.js +1 -1
- package/dist/core/routing/rewrite.d.ts +9 -0
- package/dist/core/routing/rewrite.js +38 -1
- package/dist/core/server-islands/endpoint.js +1 -1
- package/dist/core/sync/index.d.ts +2 -1
- package/dist/core/sync/index.js +17 -4
- package/dist/env/config.d.ts +1 -1
- package/dist/env/runtime-constants.d.ts +1 -0
- package/dist/env/runtime-constants.js +4 -0
- package/dist/env/runtime.js +5 -1
- package/dist/env/vite-plugin-env.d.ts +1 -1
- package/dist/env/vite-plugin-env.js +3 -10
- package/dist/runtime/server/render/astro/head-and-content.js +1 -1
- package/dist/runtime/server/render/astro/instance.js +1 -1
- package/dist/runtime/server/render/astro/render-template.js +1 -1
- package/dist/runtime/server/render/page.js +1 -4
- package/dist/types/public/config.d.ts +33 -18
- package/dist/types/public/content.d.ts +6 -2
- package/dist/vite-plugin-astro-server/pipeline.js +3 -4
- package/dist/vite-plugin-astro-server/response.js +1 -1
- package/dist/vite-plugin-markdown/index.js +4 -2
- package/package.json +13 -18
- package/templates/actions.mjs +1 -1
- package/config.d.ts +0 -40
- package/config.mjs +0 -16
package/client.d.ts
CHANGED
|
@@ -283,6 +283,7 @@ declare module '*.mdx' {
|
|
|
283
283
|
export const url: MDX['url'];
|
|
284
284
|
export const getHeadings: MDX['getHeadings'];
|
|
285
285
|
export const Content: MDX['Content'];
|
|
286
|
+
export const components: MDX['components'];
|
|
286
287
|
|
|
287
288
|
const load: MDX['default'];
|
|
288
289
|
export default load;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { decodeBase64, encodeBase64 } from "@oslojs/encoding";
|
|
2
2
|
import { yellow } from "kleur/colors";
|
|
3
3
|
import { defineMiddleware } from "../../core/middleware/index.js";
|
|
4
|
+
import { getOriginPathname } from "../../core/routing/rewrite.js";
|
|
4
5
|
import { ACTION_QUERY_PARAMS } from "../consts.js";
|
|
5
6
|
import { formContentTypes, hasContentType } from "./utils.js";
|
|
6
7
|
import { getAction } from "./virtual/get-action.js";
|
|
@@ -14,7 +15,7 @@ const onRequest = defineMiddleware(async (context, next) => {
|
|
|
14
15
|
if (context.request.method === "POST") {
|
|
15
16
|
console.warn(
|
|
16
17
|
yellow("[astro:actions]"),
|
|
17
|
-
|
|
18
|
+
"POST requests should not be sent to prerendered pages. If you're using Actions, disable prerendering with `export const prerender = false`."
|
|
18
19
|
);
|
|
19
20
|
}
|
|
20
21
|
return next();
|
|
@@ -66,7 +67,8 @@ async function handlePost({
|
|
|
66
67
|
if (contentType && hasContentType(contentType, formContentTypes)) {
|
|
67
68
|
formData = await request.clone().formData();
|
|
68
69
|
}
|
|
69
|
-
const
|
|
70
|
+
const { getActionResult, callAction, props, redirect, ...actionAPIContext } = context;
|
|
71
|
+
const action = baseAction.bind(actionAPIContext);
|
|
70
72
|
const actionResult = await action(formData);
|
|
71
73
|
if (context.url.searchParams.get(ACTION_QUERY_PARAMS.actionRedirect) === "false") {
|
|
72
74
|
return renderResult({
|
|
@@ -93,10 +95,14 @@ async function redirectWithResult({
|
|
|
93
95
|
);
|
|
94
96
|
context.cookies.set(ACTION_QUERY_PARAMS.actionPayload, cookieValue);
|
|
95
97
|
if (actionResult.error) {
|
|
96
|
-
const
|
|
97
|
-
if (!
|
|
98
|
+
const referer2 = context.request.headers.get("Referer");
|
|
99
|
+
if (!referer2) {
|
|
98
100
|
throw new Error("Internal: Referer unexpectedly missing from Action POST request.");
|
|
99
101
|
}
|
|
102
|
+
return context.redirect(referer2);
|
|
103
|
+
}
|
|
104
|
+
const referer = getOriginPathname(context.request);
|
|
105
|
+
if (referer) {
|
|
100
106
|
return context.redirect(referer);
|
|
101
107
|
}
|
|
102
108
|
return context.redirect(context.url.pathname);
|
|
@@ -23,7 +23,8 @@ const POST = async (context) => {
|
|
|
23
23
|
} else {
|
|
24
24
|
return new Response(null, { status: 415 });
|
|
25
25
|
}
|
|
26
|
-
const
|
|
26
|
+
const { getActionResult, callAction, props, redirect, ...actionAPIContext } = context;
|
|
27
|
+
const action = baseAction.bind(actionAPIContext);
|
|
27
28
|
const result = await action(args);
|
|
28
29
|
const serialized = serializeActionResult(result);
|
|
29
30
|
if (serialized.type === "empty") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ActionNotFoundError } from "../../../core/errors/errors-data.js";
|
|
2
2
|
import { AstroError } from "../../../core/errors/errors.js";
|
|
3
3
|
async function getAction(path) {
|
|
4
|
-
const pathKeys = path.replace(
|
|
4
|
+
const pathKeys = path.replace(/^.*\/_actions\//, "").split(".").map((key) => decodeURIComponent(key));
|
|
5
5
|
let { server: actionLookup } = await import("astro:internal-actions");
|
|
6
6
|
if (actionLookup == null || !(typeof actionLookup === "object")) {
|
|
7
7
|
throw new TypeError(
|
|
@@ -18,6 +18,10 @@ async function loadLocalImage(src, url) {
|
|
|
18
18
|
fileUrl = pathToFileURL(removeQueryString(replaceFileSystemReferences(src)));
|
|
19
19
|
} else {
|
|
20
20
|
try {
|
|
21
|
+
const idx = url.pathname.indexOf("/_image");
|
|
22
|
+
if (idx > 0) {
|
|
23
|
+
src = src.slice(idx);
|
|
24
|
+
}
|
|
21
25
|
fileUrl = new URL("." + src, outDir);
|
|
22
26
|
const filePath = fileURLToPath(fileUrl);
|
|
23
27
|
if (!isAbsolute(filePath) || !filePath.startsWith(assetsDirPath)) {
|
package/dist/assets/internal.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isRemotePath } from "@astrojs/internal-helpers/path";
|
|
1
2
|
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
2
3
|
import { DEFAULT_HASH_PROPS } from "./consts.js";
|
|
3
4
|
import { isLocalService } from "./services/service.js";
|
|
@@ -47,7 +48,7 @@ async function getImage(options, imageConfig) {
|
|
|
47
48
|
...options,
|
|
48
49
|
src: await resolveSrc(options.src)
|
|
49
50
|
};
|
|
50
|
-
if (options.inferSize && isRemoteImage(resolvedOptions.src)) {
|
|
51
|
+
if (options.inferSize && isRemoteImage(resolvedOptions.src) && isRemotePath(resolvedOptions.src)) {
|
|
51
52
|
const result = await inferRemoteSize(resolvedOptions.src);
|
|
52
53
|
resolvedOptions.width ??= result.width;
|
|
53
54
|
resolvedOptions.height ??= result.height;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as vite from 'vite';
|
|
2
|
-
import type {
|
|
3
|
-
export default function assets({ settings
|
|
4
|
-
|
|
2
|
+
import type { AstroSettings } from '../types/astro.js';
|
|
3
|
+
export default function assets({ settings }: {
|
|
4
|
+
settings: AstroSettings;
|
|
5
5
|
}): vite.Plugin[];
|
|
@@ -62,12 +62,10 @@ const addStaticImageFactory = (settings) => {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
|
-
function assets({
|
|
66
|
-
settings,
|
|
67
|
-
mode
|
|
68
|
-
}) {
|
|
65
|
+
function assets({ settings }) {
|
|
69
66
|
let resolvedConfig;
|
|
70
67
|
let shouldEmitFile = false;
|
|
68
|
+
let isBuild = false;
|
|
71
69
|
globalThis.astroAsset = {
|
|
72
70
|
referencedImages: /* @__PURE__ */ new Set()
|
|
73
71
|
};
|
|
@@ -75,6 +73,9 @@ function assets({
|
|
|
75
73
|
// Expose the components and different utilities from `astro:assets`
|
|
76
74
|
{
|
|
77
75
|
name: "astro:assets",
|
|
76
|
+
config(_, env) {
|
|
77
|
+
isBuild = env.command === "build";
|
|
78
|
+
},
|
|
78
79
|
async resolveId(id) {
|
|
79
80
|
if (id === VIRTUAL_SERVICE_ID) {
|
|
80
81
|
return await this.resolve(settings.config.image.service.entrypoint);
|
|
@@ -112,9 +113,7 @@ function assets({
|
|
|
112
113
|
}
|
|
113
114
|
},
|
|
114
115
|
buildStart() {
|
|
115
|
-
if (
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
116
|
+
if (!isBuild) return;
|
|
118
117
|
globalThis.astroAsset.addStaticImage = addStaticImageFactory(settings);
|
|
119
118
|
},
|
|
120
119
|
// In build, rewrite paths to ESM imported images in code to their final location
|
package/dist/cli/add/index.js
CHANGED
|
@@ -73,7 +73,7 @@ export default async function seed() {
|
|
|
73
73
|
};
|
|
74
74
|
const OFFICIAL_ADAPTER_TO_IMPORT_MAP = {
|
|
75
75
|
netlify: "@astrojs/netlify",
|
|
76
|
-
vercel: "@astrojs/vercel
|
|
76
|
+
vercel: "@astrojs/vercel",
|
|
77
77
|
cloudflare: "@astrojs/cloudflare",
|
|
78
78
|
node: "@astrojs/node"
|
|
79
79
|
};
|
package/dist/cli/build/index.js
CHANGED
|
@@ -9,6 +9,11 @@ async function build({ flags }) {
|
|
|
9
9
|
tables: {
|
|
10
10
|
Flags: [
|
|
11
11
|
["--outDir <directory>", `Specify the output directory for the build.`],
|
|
12
|
+
["--mode", `Specify the mode of the project. Defaults to "production".`],
|
|
13
|
+
[
|
|
14
|
+
"--devOutput",
|
|
15
|
+
"Output a development-based build similar to code transformed in `astro dev`."
|
|
16
|
+
],
|
|
12
17
|
[
|
|
13
18
|
"--force",
|
|
14
19
|
"Clear the content layer and content collection cache, forcing a full rebuild."
|
|
@@ -21,7 +26,7 @@ async function build({ flags }) {
|
|
|
21
26
|
return;
|
|
22
27
|
}
|
|
23
28
|
const inlineConfig = flagsToAstroInlineConfig(flags);
|
|
24
|
-
await _build(inlineConfig);
|
|
29
|
+
await _build(inlineConfig, { devOutput: !!flags.devOutput });
|
|
25
30
|
}
|
|
26
31
|
export {
|
|
27
32
|
build
|
package/dist/cli/dev/index.js
CHANGED
|
@@ -9,6 +9,7 @@ async function dev({ flags }) {
|
|
|
9
9
|
usage: "[...flags]",
|
|
10
10
|
tables: {
|
|
11
11
|
Flags: [
|
|
12
|
+
["--mode", `Specify the mode of the project. Defaults to "development".`],
|
|
12
13
|
["--port", `Specify which port to run on. Defaults to 4321.`],
|
|
13
14
|
["--host", `Listen on all addresses, including LAN and public addresses.`],
|
|
14
15
|
["--host <custom-address>", `Expose on a network IP address at <custom-address>`],
|
package/dist/cli/index.js
CHANGED
|
@@ -109,7 +109,13 @@ ${message}`
|
|
|
109
109
|
await exec(
|
|
110
110
|
installCommand.pm,
|
|
111
111
|
[installCommand.command, ...installCommand.flags, ...installCommand.dependencies],
|
|
112
|
-
{
|
|
112
|
+
{
|
|
113
|
+
nodeOptions: {
|
|
114
|
+
cwd,
|
|
115
|
+
// reset NODE_ENV to ensure install command run in dev mode
|
|
116
|
+
env: { NODE_ENV: void 0 }
|
|
117
|
+
}
|
|
118
|
+
}
|
|
113
119
|
);
|
|
114
120
|
spinner.success();
|
|
115
121
|
return true;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SharpImageServiceConfig } from '../assets/services/sharp.js';
|
|
2
|
+
import type { ImageServiceConfig } from '../types/public/index.js';
|
|
3
|
+
export { defineConfig, getViteConfig } from './index.js';
|
|
4
|
+
export { envField } from '../env/config.js';
|
|
5
|
+
/**
|
|
6
|
+
* Return the configuration needed to use the Sharp-based image service
|
|
7
|
+
*/
|
|
8
|
+
export declare function sharpImageService(config?: SharpImageServiceConfig): ImageServiceConfig;
|
|
9
|
+
/**
|
|
10
|
+
* Return the configuration needed to use the passthrough image service. This image services does not perform
|
|
11
|
+
* any image transformations, and is mainly useful when your platform does not support other image services, or you are
|
|
12
|
+
* not using Astro's built-in image processing.
|
|
13
|
+
* See: https://docs.astro.build/en/guides/images/#configure-no-op-passthrough-service
|
|
14
|
+
*/
|
|
15
|
+
export declare function passthroughImageService(): ImageServiceConfig;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineConfig, getViteConfig } from "./index.js";
|
|
2
|
+
import { envField } from "../env/config.js";
|
|
3
|
+
function sharpImageService(config = {}) {
|
|
4
|
+
return {
|
|
5
|
+
entrypoint: "astro/assets/services/sharp",
|
|
6
|
+
config
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function passthroughImageService() {
|
|
10
|
+
return {
|
|
11
|
+
entrypoint: "astro/assets/services/noop",
|
|
12
|
+
config: {}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
defineConfig,
|
|
17
|
+
envField,
|
|
18
|
+
getViteConfig,
|
|
19
|
+
passthroughImageService,
|
|
20
|
+
sharpImageService
|
|
21
|
+
};
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type { UserConfig as ViteUserConfig } from 'vite';
|
|
2
|
-
import type { AstroInlineConfig, AstroUserConfig } from '../types/public/config.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import type { UserConfig as ViteUserConfig, UserConfigFn as ViteUserConfigFn } from 'vite';
|
|
2
|
+
import type { AstroInlineConfig, AstroUserConfig, Locales } from '../types/public/config.js';
|
|
3
|
+
/**
|
|
4
|
+
* See the full Astro Configuration API Documentation
|
|
5
|
+
* https://astro.build/config
|
|
6
|
+
*/
|
|
7
|
+
export declare function defineConfig<const TLocales extends Locales = never>(config: AstroUserConfig<TLocales>): AstroUserConfig<TLocales>;
|
|
8
|
+
/**
|
|
9
|
+
* Use Astro to generate a fully resolved Vite config
|
|
10
|
+
*/
|
|
11
|
+
export declare function getViteConfig(userViteConfig: ViteUserConfig, inlineAstroConfig?: AstroInlineConfig): ViteUserConfigFn;
|
package/dist/config/index.js
CHANGED
|
@@ -6,7 +6,7 @@ function defineConfig(config) {
|
|
|
6
6
|
}
|
|
7
7
|
function getViteConfig(userViteConfig, inlineAstroConfig = {}) {
|
|
8
8
|
return async ({ mode, command }) => {
|
|
9
|
-
const cmd = command === "serve" ? "dev" :
|
|
9
|
+
const cmd = command === "serve" ? "dev" : "build";
|
|
10
10
|
const [
|
|
11
11
|
fs,
|
|
12
12
|
{ mergeConfig },
|
|
@@ -35,13 +35,12 @@ function getViteConfig(userViteConfig, inlineAstroConfig = {}) {
|
|
|
35
35
|
const devSSRManifest = createDevelopmentManifest(settings);
|
|
36
36
|
const viteConfig = await createVite(
|
|
37
37
|
{
|
|
38
|
-
mode,
|
|
39
38
|
plugins: [
|
|
40
39
|
// Initialize the content listener
|
|
41
40
|
astroContentListenPlugin({ settings, logger, fs })
|
|
42
41
|
]
|
|
43
42
|
},
|
|
44
|
-
{ settings, logger, mode, sync: false, manifest, ssrManifest: devSSRManifest }
|
|
43
|
+
{ settings, command: cmd, logger, mode, sync: false, manifest, ssrManifest: devSSRManifest }
|
|
45
44
|
);
|
|
46
45
|
await runHookConfigDone({ settings, logger });
|
|
47
46
|
return mergeConfig(viteConfig, userViteConfig);
|
|
@@ -72,6 +72,13 @@ export type ContainerRenderOptions = {
|
|
|
72
72
|
* ```
|
|
73
73
|
*/
|
|
74
74
|
props?: Props;
|
|
75
|
+
/**
|
|
76
|
+
* When `false`, it forces to render the component as it was a full-fledged page.
|
|
77
|
+
*
|
|
78
|
+
* By default, the container API render components as [partials](https://docs.astro.build/en/basics/astro-pages/#page-partials).
|
|
79
|
+
*
|
|
80
|
+
*/
|
|
81
|
+
partial?: boolean;
|
|
75
82
|
};
|
|
76
83
|
export type AddServerRenderer = {
|
|
77
84
|
renderer: NamedSSRLoadedRendererValue;
|
package/dist/container/index.js
CHANGED
|
@@ -266,7 +266,8 @@ class experimental_AstroContainer {
|
|
|
266
266
|
status: 200,
|
|
267
267
|
request,
|
|
268
268
|
pathname: url.pathname,
|
|
269
|
-
locals: options?.locals ?? {}
|
|
269
|
+
locals: options?.locals ?? {},
|
|
270
|
+
partial: options?.partial ?? true
|
|
270
271
|
});
|
|
271
272
|
if (options.params) {
|
|
272
273
|
renderContext.params = options.params;
|
|
@@ -114,7 +114,7 @@ class ContentLayer {
|
|
|
114
114
|
logger.info("Content config changed");
|
|
115
115
|
shouldClear = true;
|
|
116
116
|
}
|
|
117
|
-
if (previousAstroVersion !== "5.0.0-beta.
|
|
117
|
+
if (previousAstroVersion !== "5.0.0-beta.6") {
|
|
118
118
|
logger.info("Astro version changed");
|
|
119
119
|
shouldClear = true;
|
|
120
120
|
}
|
|
@@ -122,8 +122,8 @@ class ContentLayer {
|
|
|
122
122
|
logger.info("Clearing content store");
|
|
123
123
|
this.#store.clearAll();
|
|
124
124
|
}
|
|
125
|
-
if ("5.0.0-beta.
|
|
126
|
-
await this.#store.metaStore().set("astro-version", "5.0.0-beta.
|
|
125
|
+
if ("5.0.0-beta.6") {
|
|
126
|
+
await this.#store.metaStore().set("astro-version", "5.0.0-beta.6");
|
|
127
127
|
}
|
|
128
128
|
if (currentConfigDigest) {
|
|
129
129
|
await this.#store.metaStore().set("config-digest", currentConfigDigest);
|
|
@@ -5,7 +5,6 @@ import { bold, cyan } from "kleur/colors";
|
|
|
5
5
|
import { normalizePath } from "vite";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
8
|
-
import { printNode, zodToTs } from "zod-to-ts";
|
|
9
8
|
import { AstroError } from "../core/errors/errors.js";
|
|
10
9
|
import { AstroErrorData } from "../core/errors/index.js";
|
|
11
10
|
import { isRelativePath } from "../core/path.js";
|
|
@@ -299,8 +298,16 @@ async function typeForCollection(collection, collectionKey) {
|
|
|
299
298
|
if (collection?.type === CONTENT_LAYER_TYPE) {
|
|
300
299
|
const schema = await getContentLayerSchema(collection, collectionKey);
|
|
301
300
|
if (schema) {
|
|
302
|
-
|
|
303
|
-
|
|
301
|
+
try {
|
|
302
|
+
const zodToTs = await import("zod-to-ts");
|
|
303
|
+
const ast = zodToTs.zodToTs(schema);
|
|
304
|
+
return zodToTs.printNode(ast.node);
|
|
305
|
+
} catch (err) {
|
|
306
|
+
if (err.message.includes("Cannot find package 'typescript'")) {
|
|
307
|
+
return "any";
|
|
308
|
+
}
|
|
309
|
+
throw err;
|
|
310
|
+
}
|
|
304
311
|
}
|
|
305
312
|
}
|
|
306
313
|
return "any";
|
|
@@ -3,8 +3,7 @@ import type { BuildInternals } from '../core/build/internal.js';
|
|
|
3
3
|
import type { AstroBuildPlugin } from '../core/build/plugin.js';
|
|
4
4
|
import type { StaticBuildOptions } from '../core/build/types.js';
|
|
5
5
|
import type { AstroSettings } from '../types/astro.js';
|
|
6
|
-
export declare function astroContentAssetPropagationPlugin({
|
|
7
|
-
mode: string;
|
|
6
|
+
export declare function astroContentAssetPropagationPlugin({ settings, }: {
|
|
8
7
|
settings: AstroSettings;
|
|
9
8
|
}): Plugin;
|
|
10
9
|
export declare function astroConfigBuildPlugin(options: StaticBuildOptions, internals: BuildInternals): AstroBuildPlugin;
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
} from "./consts.js";
|
|
15
15
|
import { hasContentFlag } from "./utils.js";
|
|
16
16
|
function astroContentAssetPropagationPlugin({
|
|
17
|
-
mode,
|
|
18
17
|
settings
|
|
19
18
|
}) {
|
|
20
19
|
let devModuleLoader;
|
|
@@ -50,9 +49,7 @@ function astroContentAssetPropagationPlugin({
|
|
|
50
49
|
}
|
|
51
50
|
},
|
|
52
51
|
configureServer(server) {
|
|
53
|
-
|
|
54
|
-
devModuleLoader = createViteLoader(server);
|
|
55
|
-
}
|
|
52
|
+
devModuleLoader = createViteLoader(server);
|
|
56
53
|
},
|
|
57
54
|
async transform(_, id, options) {
|
|
58
55
|
if (hasContentFlag(id, PROPAGATED_ASSET_FLAG)) {
|
|
@@ -46,7 +46,7 @@ function astroContentVirtualModPlugin({
|
|
|
46
46
|
name: "astro-content-virtual-mod-plugin",
|
|
47
47
|
enforce: "pre",
|
|
48
48
|
configResolved(config) {
|
|
49
|
-
IS_DEV = config.
|
|
49
|
+
IS_DEV = !config.isProduction;
|
|
50
50
|
dataStoreFile = getDataStoreFile(settings, IS_DEV);
|
|
51
51
|
},
|
|
52
52
|
async resolveId(id) {
|
package/dist/core/app/index.js
CHANGED
|
@@ -60,7 +60,7 @@ class App {
|
|
|
60
60
|
return AppPipeline.create(manifestData, {
|
|
61
61
|
logger: this.#logger,
|
|
62
62
|
manifest: this.#manifest,
|
|
63
|
-
|
|
63
|
+
runtimeMode: "production",
|
|
64
64
|
renderers: this.#manifest.renderers,
|
|
65
65
|
defaultRoutes: createDefaultRoutes(this.#manifest),
|
|
66
66
|
resolve: async (specifier) => {
|
|
@@ -6,7 +6,10 @@ const FORM_CONTENT_TYPES = [
|
|
|
6
6
|
];
|
|
7
7
|
function createOriginCheckMiddleware() {
|
|
8
8
|
return defineMiddleware((context, next) => {
|
|
9
|
-
const { request, url } = context;
|
|
9
|
+
const { request, url, isPrerendered } = context;
|
|
10
|
+
if (isPrerendered) {
|
|
11
|
+
return next();
|
|
12
|
+
}
|
|
10
13
|
const contentType = request.headers.get("content-type");
|
|
11
14
|
if (contentType) {
|
|
12
15
|
if (FORM_CONTENT_TYPES.includes(contentType.toLowerCase())) {
|
package/dist/core/app/node.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { Http2ServerResponse } from "node:http2";
|
|
3
|
+
import { clientAddressSymbol } from "../constants.js";
|
|
3
4
|
import { deserializeManifest } from "./common.js";
|
|
4
5
|
import { createOutgoingHttpHeaders } from "./createOutgoingHttpHeaders.js";
|
|
5
6
|
import { App } from "./index.js";
|
|
6
7
|
import { apply } from "../polyfill.js";
|
|
7
|
-
const clientAddressSymbol = Symbol.for("astro.clientAddress");
|
|
8
8
|
class NodeApp extends App {
|
|
9
9
|
match(req) {
|
|
10
10
|
if (!(req instanceof Request)) {
|
|
@@ -5,7 +5,7 @@ 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: ManifestData, { logger, manifest,
|
|
8
|
+
static create(manifestData: ManifestData, { 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>;
|
|
@@ -7,7 +7,7 @@ class AppPipeline extends Pipeline {
|
|
|
7
7
|
static create(manifestData, {
|
|
8
8
|
logger,
|
|
9
9
|
manifest,
|
|
10
|
-
|
|
10
|
+
runtimeMode,
|
|
11
11
|
renderers,
|
|
12
12
|
resolve,
|
|
13
13
|
serverLike,
|
|
@@ -17,7 +17,7 @@ class AppPipeline extends Pipeline {
|
|
|
17
17
|
const pipeline = new AppPipeline(
|
|
18
18
|
logger,
|
|
19
19
|
manifest,
|
|
20
|
-
|
|
20
|
+
runtimeMode,
|
|
21
21
|
renderers,
|
|
22
22
|
resolve,
|
|
23
23
|
serverLike,
|
|
@@ -14,9 +14,9 @@ export declare abstract class Pipeline {
|
|
|
14
14
|
readonly logger: Logger;
|
|
15
15
|
readonly manifest: SSRManifest;
|
|
16
16
|
/**
|
|
17
|
-
* "development" or "production"
|
|
17
|
+
* "development" or "production" only
|
|
18
18
|
*/
|
|
19
|
-
readonly
|
|
19
|
+
readonly runtimeMode: RuntimeMode;
|
|
20
20
|
readonly renderers: SSRLoadedRenderer[];
|
|
21
21
|
readonly resolve: (s: string) => Promise<string>;
|
|
22
22
|
/**
|
|
@@ -53,9 +53,9 @@ export declare abstract class Pipeline {
|
|
|
53
53
|
resolvedMiddleware: MiddlewareHandler | undefined;
|
|
54
54
|
constructor(logger: Logger, manifest: SSRManifest,
|
|
55
55
|
/**
|
|
56
|
-
* "development" or "production"
|
|
56
|
+
* "development" or "production" only
|
|
57
57
|
*/
|
|
58
|
-
|
|
58
|
+
runtimeMode: RuntimeMode, renderers: SSRLoadedRenderer[], resolve: (s: string) => Promise<string>,
|
|
59
59
|
/**
|
|
60
60
|
* Based on Astro config's `output` option, `true` if "server" or "hybrid".
|
|
61
61
|
*/
|
|
@@ -8,10 +8,10 @@ import { sequence } from "./middleware/sequence.js";
|
|
|
8
8
|
import { RouteCache } from "./render/route-cache.js";
|
|
9
9
|
import { createDefaultRoutes } from "./routing/default.js";
|
|
10
10
|
class Pipeline {
|
|
11
|
-
constructor(logger, manifest,
|
|
11
|
+
constructor(logger, manifest, runtimeMode, renderers, resolve, serverLike, streaming, adapterName = manifest.adapterName, clientDirectives = manifest.clientDirectives, inlinedScripts = manifest.inlinedScripts, compressHTML = manifest.compressHTML, i18n = manifest.i18n, middleware = manifest.middleware, routeCache = new RouteCache(logger, runtimeMode), site = manifest.site ? new URL(manifest.site) : void 0, callSetGetEnv = true, defaultRoutes = createDefaultRoutes(manifest)) {
|
|
12
12
|
this.logger = logger;
|
|
13
13
|
this.manifest = manifest;
|
|
14
|
-
this.
|
|
14
|
+
this.runtimeMode = runtimeMode;
|
|
15
15
|
this.renderers = renderers;
|
|
16
16
|
this.resolve = resolve;
|
|
17
17
|
this.serverLike = serverLike;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { AstroInlineConfig } from '../../types/public/config.js';
|
|
2
2
|
export interface BuildOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Output a development-based build similar to code transformed in `astro dev`. This
|
|
5
|
+
* can be useful to test build-only issues with additional debugging information included.
|
|
6
|
+
*
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
devOutput?: boolean;
|
|
3
10
|
}
|
|
4
11
|
/**
|
|
5
12
|
* Builds your site for deployment. By default, this will generate static files and place them in a dist/ directory.
|
package/dist/core/build/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import { collectPagesData } from "./page-data.js";
|
|
|
27
27
|
import { staticBuild, viteBuild } from "./static-build.js";
|
|
28
28
|
import { getTimeStat } from "./util.js";
|
|
29
29
|
async function build(inlineConfig, options = {}) {
|
|
30
|
-
ensureProcessNodeEnv("production");
|
|
30
|
+
ensureProcessNodeEnv(options.devOutput ? "development" : "production");
|
|
31
31
|
applyPolyfill();
|
|
32
32
|
const logger = createNodeLogger(inlineConfig);
|
|
33
33
|
const { userConfig, astroConfig } = await resolveConfig(inlineConfig, "build");
|
|
@@ -39,22 +39,23 @@ async function build(inlineConfig, options = {}) {
|
|
|
39
39
|
const builder = new AstroBuilder(settings, {
|
|
40
40
|
...options,
|
|
41
41
|
logger,
|
|
42
|
-
mode: inlineConfig.mode
|
|
42
|
+
mode: inlineConfig.mode ?? "production",
|
|
43
|
+
runtimeMode: options.devOutput ? "development" : "production"
|
|
43
44
|
});
|
|
44
45
|
await builder.run();
|
|
45
46
|
}
|
|
46
47
|
class AstroBuilder {
|
|
47
48
|
settings;
|
|
48
49
|
logger;
|
|
49
|
-
mode
|
|
50
|
+
mode;
|
|
51
|
+
runtimeMode;
|
|
50
52
|
origin;
|
|
51
53
|
manifest;
|
|
52
54
|
timer;
|
|
53
55
|
teardownCompiler;
|
|
54
56
|
constructor(settings, options) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
57
|
+
this.mode = options.mode;
|
|
58
|
+
this.runtimeMode = options.runtimeMode;
|
|
58
59
|
this.settings = settings;
|
|
59
60
|
this.logger = options.logger;
|
|
60
61
|
this.teardownCompiler = options.teardownCompiler ?? true;
|
|
@@ -82,7 +83,6 @@ class AstroBuilder {
|
|
|
82
83
|
}
|
|
83
84
|
const viteConfig = await createVite(
|
|
84
85
|
{
|
|
85
|
-
mode: this.mode,
|
|
86
86
|
server: {
|
|
87
87
|
hmr: false,
|
|
88
88
|
middlewareMode: true
|
|
@@ -91,7 +91,7 @@ class AstroBuilder {
|
|
|
91
91
|
{
|
|
92
92
|
settings: this.settings,
|
|
93
93
|
logger: this.logger,
|
|
94
|
-
mode:
|
|
94
|
+
mode: this.mode,
|
|
95
95
|
command: "build",
|
|
96
96
|
sync: false,
|
|
97
97
|
manifest: this.manifest
|
|
@@ -99,6 +99,7 @@ class AstroBuilder {
|
|
|
99
99
|
);
|
|
100
100
|
const { syncInternal } = await import("../sync/index.js");
|
|
101
101
|
await syncInternal({
|
|
102
|
+
mode: this.mode,
|
|
102
103
|
settings: this.settings,
|
|
103
104
|
logger,
|
|
104
105
|
fs,
|
|
@@ -136,7 +137,7 @@ class AstroBuilder {
|
|
|
136
137
|
settings: this.settings,
|
|
137
138
|
logger: this.logger,
|
|
138
139
|
manifest: this.manifest,
|
|
139
|
-
|
|
140
|
+
runtimeMode: this.runtimeMode,
|
|
140
141
|
origin: this.origin,
|
|
141
142
|
pageNames,
|
|
142
143
|
teardownCompiler: this.teardownCompiler,
|
|
@@ -108,7 +108,6 @@ async function ssrBuild(opts, internals, input, container) {
|
|
|
108
108
|
const { lastVitePlugins, vitePlugins } = await container.runBeforeHook("server", input);
|
|
109
109
|
const viteBuildConfig = {
|
|
110
110
|
...viteConfig,
|
|
111
|
-
mode: viteConfig.mode || "production",
|
|
112
111
|
logLevel: viteConfig.logLevel ?? "error",
|
|
113
112
|
build: {
|
|
114
113
|
target: "esnext",
|
|
@@ -204,7 +203,6 @@ async function clientBuild(opts, internals, input, container) {
|
|
|
204
203
|
${bgGreen(black(" building client (vite) "))}`);
|
|
205
204
|
const viteBuildConfig = {
|
|
206
205
|
...viteConfig,
|
|
207
|
-
mode: viteConfig.mode || "production",
|
|
208
206
|
build: {
|
|
209
207
|
target: "esnext",
|
|
210
208
|
...viteConfig.build,
|