astro 2.0.15 → 2.0.17
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/dist/@types/astro.d.ts +2 -0
- package/dist/cli/index.js +1 -1
- package/dist/core/app/index.d.ts +1 -1
- package/dist/core/app/index.js +1 -1
- package/dist/core/build/generate.js +1 -1
- package/dist/core/build/index.d.ts +5 -0
- package/dist/core/build/index.js +9 -4
- package/dist/core/build/static-build.d.ts +5 -1
- package/dist/core/build/static-build.js +22 -8
- package/dist/core/build/types.d.ts +1 -0
- package/dist/core/config/settings.js +3 -1
- package/dist/core/config/timer.d.ts +27 -0
- package/dist/core/config/timer.js +42 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/cookies/response.d.ts +1 -1
- package/dist/core/cookies/response.js +2 -1
- package/dist/core/create-vite.d.ts +2 -1
- package/dist/core/create-vite.js +24 -5
- package/dist/core/dev/container.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/endpoint/dev/index.d.ts +2 -1
- package/dist/core/endpoint/dev/index.js +2 -2
- package/dist/core/endpoint/index.d.ts +2 -1
- package/dist/core/endpoint/index.js +18 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/sync/index.js +1 -1
- package/dist/vite-plugin-astro-server/response.js +10 -6
- package/dist/vite-plugin-astro-server/route.js +1 -1
- package/dist/vite-plugin-head-propagation/index.js +4 -4
- package/package.json +5 -5
package/dist/@types/astro.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { z } from 'zod';
|
|
|
11
11
|
import type { SerializedSSRManifest } from '../core/app/types';
|
|
12
12
|
import type { PageBuildData } from '../core/build/types';
|
|
13
13
|
import type { AstroConfigSchema } from '../core/config';
|
|
14
|
+
import type { AstroTimer } from '../core/config/timer';
|
|
14
15
|
import type { AstroCookies } from '../core/cookies';
|
|
15
16
|
import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server';
|
|
16
17
|
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
|
|
@@ -915,6 +916,7 @@ export interface AstroSettings {
|
|
|
915
916
|
tsConfigPath: string | undefined;
|
|
916
917
|
watchFiles: string[];
|
|
917
918
|
forceDisableTelemetry: boolean;
|
|
919
|
+
timer: AstroTimer;
|
|
918
920
|
}
|
|
919
921
|
export type AsyncRendererComponentFn<U> = (Component: any, props: any, slots: Record<string, string>, metadata?: AstroComponentMetadata) => Promise<U>;
|
|
920
922
|
/** Generic interface for a component (Astro, Svelte, React, etc.) */
|
package/dist/cli/index.js
CHANGED
|
@@ -154,7 +154,7 @@ async function runCommand(cmd, flags) {
|
|
|
154
154
|
}
|
|
155
155
|
case "build": {
|
|
156
156
|
const { default: build } = await import("../core/build/index.js");
|
|
157
|
-
return await build(settings, { ...flags, logging, telemetry });
|
|
157
|
+
return await build(settings, { ...flags, logging, telemetry, teardownCompiler: true });
|
|
158
158
|
}
|
|
159
159
|
case "check": {
|
|
160
160
|
const ret = await check(settings, { logging });
|
package/dist/core/app/index.d.ts
CHANGED
|
@@ -12,5 +12,5 @@ export declare class App {
|
|
|
12
12
|
removeBase(pathname: string): string;
|
|
13
13
|
match(request: Request, { matchNotFound }?: MatchOptions): RouteData | undefined;
|
|
14
14
|
render(request: Request, routeData?: RouteData): Promise<Response>;
|
|
15
|
-
setCookieHeaders(response: Response): Generator<string,
|
|
15
|
+
setCookieHeaders(response: Response): Generator<string, string[], unknown>;
|
|
16
16
|
}
|
package/dist/core/app/index.js
CHANGED
|
@@ -216,7 +216,7 @@ callEndpoint_fn = async function(request, routeData, mod, status = 200) {
|
|
|
216
216
|
route: routeData,
|
|
217
217
|
status
|
|
218
218
|
});
|
|
219
|
-
const result = await callEndpoint(handler, __privateGet(this, _env), ctx);
|
|
219
|
+
const result = await callEndpoint(handler, __privateGet(this, _env), ctx, __privateGet(this, _logging));
|
|
220
220
|
if (result.type === "response") {
|
|
221
221
|
if (result.response.headers.get("X-Astro-Response") === "Not-Found") {
|
|
222
222
|
const fourOhFourRequest = new Request(new URL("/404", request.url));
|
|
@@ -271,7 +271,7 @@ async function generatePath(pathname, opts, gopts) {
|
|
|
271
271
|
let encoding;
|
|
272
272
|
if (pageData.route.type === "endpoint") {
|
|
273
273
|
const endpointHandler = mod;
|
|
274
|
-
const result = await callEndpoint(endpointHandler, env, ctx);
|
|
274
|
+
const result = await callEndpoint(endpointHandler, env, ctx, logging);
|
|
275
275
|
if (result.type === "response") {
|
|
276
276
|
throwIfRedirectNotAllowed(result.response, opts.settings.config);
|
|
277
277
|
if (!result.response.body)
|
|
@@ -5,6 +5,11 @@ export interface BuildOptions {
|
|
|
5
5
|
mode?: RuntimeMode;
|
|
6
6
|
logging: LogOptions;
|
|
7
7
|
telemetry: AstroTelemetry;
|
|
8
|
+
/**
|
|
9
|
+
* Teardown the compiler WASM instance after build. This can improve performance when
|
|
10
|
+
* building once, but may cause a performance hit if building multiple times in a row.
|
|
11
|
+
*/
|
|
12
|
+
teardownCompiler?: boolean;
|
|
8
13
|
}
|
|
9
14
|
/** `astro build` */
|
|
10
15
|
export default function build(settings: AstroSettings, options: BuildOptions): Promise<void>;
|
package/dist/core/build/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { apply as applyPolyfill } from "../polyfill.js";
|
|
|
13
13
|
import { RouteCache } from "../render/route-cache.js";
|
|
14
14
|
import { createRouteManifest } from "../routing/index.js";
|
|
15
15
|
import { collectPagesData } from "./page-data.js";
|
|
16
|
-
import { staticBuild } from "./static-build.js";
|
|
16
|
+
import { staticBuild, viteBuild } from "./static-build.js";
|
|
17
17
|
import { getTimeStat } from "./util.js";
|
|
18
18
|
async function build(settings, options) {
|
|
19
19
|
applyPolyfill();
|
|
@@ -28,6 +28,7 @@ class AstroBuilder {
|
|
|
28
28
|
}
|
|
29
29
|
this.settings = settings;
|
|
30
30
|
this.logging = options.logging;
|
|
31
|
+
this.teardownCompiler = options.teardownCompiler ?? false;
|
|
31
32
|
this.routeCache = new RouteCache(this.logging);
|
|
32
33
|
this.origin = settings.config.site ? new URL(settings.config.site).origin : `http://localhost:${settings.config.server.port}`;
|
|
33
34
|
this.manifest = { routes: [] };
|
|
@@ -51,7 +52,7 @@ class AstroBuilder {
|
|
|
51
52
|
middlewareMode: true
|
|
52
53
|
}
|
|
53
54
|
},
|
|
54
|
-
{ settings: this.settings, logging, mode: "build" }
|
|
55
|
+
{ settings: this.settings, logging, mode: "build", command: "build" }
|
|
55
56
|
);
|
|
56
57
|
await runHookConfigDone({ settings: this.settings, logging });
|
|
57
58
|
const { sync } = await import("../sync/index.js");
|
|
@@ -88,7 +89,7 @@ class AstroBuilder {
|
|
|
88
89
|
"build",
|
|
89
90
|
colors.dim(`Completed in ${getTimeStat(this.timer.init, performance.now())}.`)
|
|
90
91
|
);
|
|
91
|
-
|
|
92
|
+
const opts = {
|
|
92
93
|
allPages,
|
|
93
94
|
settings: this.settings,
|
|
94
95
|
logging: this.logging,
|
|
@@ -97,9 +98,12 @@ class AstroBuilder {
|
|
|
97
98
|
origin: this.origin,
|
|
98
99
|
pageNames,
|
|
99
100
|
routeCache: this.routeCache,
|
|
101
|
+
teardownCompiler: this.teardownCompiler,
|
|
100
102
|
viteConfig,
|
|
101
103
|
buildConfig
|
|
102
|
-
}
|
|
104
|
+
};
|
|
105
|
+
const { internals } = await viteBuild(opts);
|
|
106
|
+
await staticBuild(opts, internals);
|
|
103
107
|
this.timer.assetsStart = performance.now();
|
|
104
108
|
Object.keys(assets).map((k) => {
|
|
105
109
|
if (!assets[k])
|
|
@@ -125,6 +129,7 @@ class AstroBuilder {
|
|
|
125
129
|
buildMode: this.settings.config.output
|
|
126
130
|
});
|
|
127
131
|
}
|
|
132
|
+
this.settings.timer.writeStats();
|
|
128
133
|
}
|
|
129
134
|
async run() {
|
|
130
135
|
const setupData = await this.setup();
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
import { BuildInternals } from '../../core/build/internal.js';
|
|
1
2
|
import type { StaticBuildOptions } from './types';
|
|
2
|
-
export declare function
|
|
3
|
+
export declare function viteBuild(opts: StaticBuildOptions): Promise<{
|
|
4
|
+
internals: BuildInternals;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function staticBuild(opts: StaticBuildOptions, internals: BuildInternals): Promise<void>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { teardown } from "@astrojs/compiler";
|
|
1
2
|
import * as eslexer from "es-module-lexer";
|
|
2
3
|
import glob from "fast-glob";
|
|
3
4
|
import fs from "fs";
|
|
@@ -22,17 +23,16 @@ import { trackPageData } from "./internal.js";
|
|
|
22
23
|
import { createPluginContainer } from "./plugin.js";
|
|
23
24
|
import { registerAllPlugins } from "./plugins/index.js";
|
|
24
25
|
import { getTimeStat } from "./util.js";
|
|
25
|
-
async function
|
|
26
|
+
async function viteBuild(opts) {
|
|
26
27
|
var _a, _b, _c;
|
|
27
28
|
const { allPages, settings } = opts;
|
|
28
29
|
if (isModeServerWithNoAdapter(opts.settings)) {
|
|
29
30
|
throw new AstroError(AstroErrorData.NoAdapterInstalled);
|
|
30
31
|
}
|
|
32
|
+
settings.timer.start("SSR build");
|
|
31
33
|
const pageInput = /* @__PURE__ */ new Set();
|
|
32
34
|
const facadeIdToPageDataMap = /* @__PURE__ */ new Map();
|
|
33
35
|
const internals = createBuildInternals();
|
|
34
|
-
const timer = {};
|
|
35
|
-
timer.buildStart = performance.now();
|
|
36
36
|
for (const [component, pageData] of Object.entries(allPages)) {
|
|
37
37
|
const astroModuleURL = new URL("./" + component, settings.config.root);
|
|
38
38
|
const astroModuleId = prependForwardSlash(component);
|
|
@@ -45,10 +45,12 @@ async function staticBuild(opts) {
|
|
|
45
45
|
}
|
|
46
46
|
const container = createPluginContainer(opts, internals);
|
|
47
47
|
registerAllPlugins(container);
|
|
48
|
-
|
|
48
|
+
const ssrTime = performance.now();
|
|
49
49
|
info(opts.logging, "build", `Building ${settings.config.output} entrypoints...`);
|
|
50
50
|
const ssrOutput = await ssrBuild(opts, internals, pageInput, container);
|
|
51
|
-
info(opts.logging, "build", dim(`Completed in ${getTimeStat(
|
|
51
|
+
info(opts.logging, "build", dim(`Completed in ${getTimeStat(ssrTime, performance.now())}.`));
|
|
52
|
+
settings.timer.end("SSR build");
|
|
53
|
+
settings.timer.start("Client build");
|
|
52
54
|
const rendererClientEntrypoints = settings.renderers.map((r) => r.clientEntrypoint).filter((a) => typeof a === "string");
|
|
53
55
|
const clientInput = /* @__PURE__ */ new Set([
|
|
54
56
|
...internals.discoveredHydratedComponents,
|
|
@@ -59,23 +61,34 @@ async function staticBuild(opts) {
|
|
|
59
61
|
if (settings.scripts.some((script) => script.stage === "page")) {
|
|
60
62
|
clientInput.add(PAGE_SCRIPT_ID);
|
|
61
63
|
}
|
|
62
|
-
timer.clientBuild = performance.now();
|
|
63
64
|
const clientOutput = await clientBuild(opts, internals, clientInput, container);
|
|
64
|
-
timer.generate = performance.now();
|
|
65
65
|
await runPostBuildHooks(container, ssrOutput, clientOutput);
|
|
66
|
+
settings.timer.end("Client build");
|
|
67
|
+
internals.ssrEntryChunk = void 0;
|
|
68
|
+
if (opts.teardownCompiler) {
|
|
69
|
+
teardown();
|
|
70
|
+
}
|
|
71
|
+
return { internals };
|
|
72
|
+
}
|
|
73
|
+
async function staticBuild(opts, internals) {
|
|
74
|
+
const { settings } = opts;
|
|
66
75
|
switch (settings.config.output) {
|
|
67
76
|
case "static": {
|
|
77
|
+
settings.timer.start("Static generate");
|
|
68
78
|
await generatePages(opts, internals);
|
|
69
79
|
await cleanServerOutput(opts);
|
|
80
|
+
settings.timer.end("Static generate");
|
|
70
81
|
return;
|
|
71
82
|
}
|
|
72
83
|
case "server": {
|
|
84
|
+
settings.timer.start("Server generate");
|
|
73
85
|
await generatePages(opts, internals);
|
|
74
86
|
await cleanStaticOutput(opts, internals);
|
|
75
87
|
info(opts.logging, null, `
|
|
76
88
|
${bgMagenta(black(" finalizing server assets "))}
|
|
77
89
|
`);
|
|
78
90
|
await ssrMoveAssets(opts);
|
|
91
|
+
settings.timer.end("Server generate");
|
|
79
92
|
return;
|
|
80
93
|
}
|
|
81
94
|
}
|
|
@@ -284,5 +297,6 @@ async function ssrMoveAssets(opts) {
|
|
|
284
297
|
}
|
|
285
298
|
}
|
|
286
299
|
export {
|
|
287
|
-
staticBuild
|
|
300
|
+
staticBuild,
|
|
301
|
+
viteBuild
|
|
288
302
|
};
|
|
@@ -3,6 +3,7 @@ import { fileURLToPath, pathToFileURL } from "url";
|
|
|
3
3
|
import jsxRenderer from "../../jsx/renderer.js";
|
|
4
4
|
import { createDefaultDevConfig } from "./config.js";
|
|
5
5
|
import { loadTSConfig } from "./tsconfig.js";
|
|
6
|
+
import { AstroTimer } from "./timer.js";
|
|
6
7
|
function createBaseSettings(config) {
|
|
7
8
|
return {
|
|
8
9
|
config,
|
|
@@ -14,7 +15,8 @@ function createBaseSettings(config) {
|
|
|
14
15
|
renderers: [jsxRenderer],
|
|
15
16
|
scripts: [],
|
|
16
17
|
watchFiles: [],
|
|
17
|
-
forceDisableTelemetry: false
|
|
18
|
+
forceDisableTelemetry: false,
|
|
19
|
+
timer: new AstroTimer()
|
|
18
20
|
};
|
|
19
21
|
}
|
|
20
22
|
function createSettings(config, cwd) {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface Stat {
|
|
2
|
+
elapsedTime: number;
|
|
3
|
+
heapUsedChange: number;
|
|
4
|
+
heapUsedTotal: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Timer to track certain operations' performance. Used by Astro's scripts only.
|
|
8
|
+
* Set `process.env.ASTRO_TIMER_PATH` truthy to enable.
|
|
9
|
+
*/
|
|
10
|
+
export declare class AstroTimer {
|
|
11
|
+
private enabled;
|
|
12
|
+
private ongoingTimers;
|
|
13
|
+
private stats;
|
|
14
|
+
constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Start a timer for a scope with a given name.
|
|
17
|
+
*/
|
|
18
|
+
start(name: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* End a timer for a scope with a given name.
|
|
21
|
+
*/
|
|
22
|
+
end(name: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Write stats to `process.env.ASTRO_TIMER_PATH`
|
|
25
|
+
*/
|
|
26
|
+
writeStats(): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
class AstroTimer {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.ongoingTimers = /* @__PURE__ */ new Map();
|
|
5
|
+
this.stats = {};
|
|
6
|
+
this.enabled = !!process.env.ASTRO_TIMER_PATH;
|
|
7
|
+
}
|
|
8
|
+
start(name) {
|
|
9
|
+
var _a;
|
|
10
|
+
if (!this.enabled)
|
|
11
|
+
return;
|
|
12
|
+
(_a = globalThis.gc) == null ? void 0 : _a.call(globalThis);
|
|
13
|
+
this.ongoingTimers.set(name, {
|
|
14
|
+
startTime: performance.now(),
|
|
15
|
+
startHeap: process.memoryUsage().heapUsed
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
end(name) {
|
|
19
|
+
var _a;
|
|
20
|
+
if (!this.enabled)
|
|
21
|
+
return;
|
|
22
|
+
const stat = this.ongoingTimers.get(name);
|
|
23
|
+
if (!stat)
|
|
24
|
+
return;
|
|
25
|
+
(_a = globalThis.gc) == null ? void 0 : _a.call(globalThis);
|
|
26
|
+
const endHeap = process.memoryUsage().heapUsed;
|
|
27
|
+
this.stats[name] = {
|
|
28
|
+
elapsedTime: performance.now() - stat.startTime,
|
|
29
|
+
heapUsedChange: endHeap - stat.startHeap,
|
|
30
|
+
heapUsedTotal: endHeap
|
|
31
|
+
};
|
|
32
|
+
this.ongoingTimers.delete(name);
|
|
33
|
+
}
|
|
34
|
+
writeStats() {
|
|
35
|
+
if (!this.enabled)
|
|
36
|
+
return;
|
|
37
|
+
fs.writeFileSync(process.env.ASTRO_TIMER_PATH, JSON.stringify(this.stats, null, 2));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
AstroTimer
|
|
42
|
+
};
|
package/dist/core/constants.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { AstroCookies } from './cookies';
|
|
2
2
|
export declare function attachToResponse(response: Response, cookies: AstroCookies): void;
|
|
3
|
-
export declare function getSetCookiesFromResponse(response: Response): Generator<string,
|
|
3
|
+
export declare function getSetCookiesFromResponse(response: Response): Generator<string, string[]>;
|
|
@@ -13,11 +13,12 @@ function getFromResponse(response) {
|
|
|
13
13
|
function* getSetCookiesFromResponse(response) {
|
|
14
14
|
const cookies = getFromResponse(response);
|
|
15
15
|
if (!cookies) {
|
|
16
|
-
return;
|
|
16
|
+
return [];
|
|
17
17
|
}
|
|
18
18
|
for (const headerValue of cookies.headers()) {
|
|
19
19
|
yield headerValue;
|
|
20
20
|
}
|
|
21
|
+
return [];
|
|
21
22
|
}
|
|
22
23
|
export {
|
|
23
24
|
attachToResponse,
|
|
@@ -7,8 +7,9 @@ interface CreateViteOptions {
|
|
|
7
7
|
settings: AstroSettings;
|
|
8
8
|
logging: LogOptions;
|
|
9
9
|
mode: 'dev' | 'build' | string;
|
|
10
|
+
command?: 'dev' | 'build';
|
|
10
11
|
fs?: typeof nodeFs;
|
|
11
12
|
}
|
|
12
13
|
/** Return a common starting point for all Vite actions */
|
|
13
|
-
export declare function createVite(commandConfig: vite.InlineConfig, { settings, logging, mode, fs }: CreateViteOptions): Promise<vite.InlineConfig>;
|
|
14
|
+
export declare function createVite(commandConfig: vite.InlineConfig, { settings, logging, mode, command, fs }: CreateViteOptions): Promise<vite.InlineConfig>;
|
|
14
15
|
export {};
|
package/dist/core/create-vite.js
CHANGED
|
@@ -28,18 +28,18 @@ const ALWAYS_NOEXTERNAL = [
|
|
|
28
28
|
"@nanostores/preact",
|
|
29
29
|
"@fontsource/*"
|
|
30
30
|
];
|
|
31
|
-
async function createVite(commandConfig, { settings, logging, mode, fs = nodeFs }) {
|
|
32
|
-
var _a;
|
|
31
|
+
async function createVite(commandConfig, { settings, logging, mode, command, fs = nodeFs }) {
|
|
32
|
+
var _a, _b;
|
|
33
33
|
const astroPkgsConfig = await crawlFrameworkPkgs({
|
|
34
34
|
root: fileURLToPath(settings.config.root),
|
|
35
35
|
isBuild: mode === "build",
|
|
36
36
|
viteUserConfig: settings.config.vite,
|
|
37
37
|
isFrameworkPkgByJson(pkgJson) {
|
|
38
|
-
var _a2,
|
|
38
|
+
var _a2, _b2, _c, _d, _e;
|
|
39
39
|
if (((_a2 = pkgJson == null ? void 0 : pkgJson.astro) == null ? void 0 : _a2.external) === true) {
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
|
-
return ((
|
|
42
|
+
return ((_b2 = pkgJson.peerDependencies) == null ? void 0 : _b2.astro) || ((_c = pkgJson.dependencies) == null ? void 0 : _c.astro) || ((_d = pkgJson.keywords) == null ? void 0 : _d.includes("astro")) || ((_e = pkgJson.keywords) == null ? void 0 : _e.includes("astro-component")) || /^(@[^\/]+\/)?astro\-/.test(pkgJson.name);
|
|
43
43
|
},
|
|
44
44
|
isFrameworkPkgByName(pkgName) {
|
|
45
45
|
const isNotAstroPkg = isCommonNotAstro(pkgName);
|
|
@@ -112,7 +112,26 @@ async function createVite(commandConfig, { settings, logging, mode, fs = nodeFs
|
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
114
|
let result = commonConfig;
|
|
115
|
-
|
|
115
|
+
if (command && ((_b = settings.config.vite) == null ? void 0 : _b.plugins)) {
|
|
116
|
+
let { plugins, ...rest } = settings.config.vite;
|
|
117
|
+
const applyToFilter = command === "build" ? "serve" : "build";
|
|
118
|
+
const applyArgs = [
|
|
119
|
+
{ ...settings.config.vite, mode },
|
|
120
|
+
{ command, mode }
|
|
121
|
+
];
|
|
122
|
+
plugins = plugins.flat(Infinity).filter((p) => {
|
|
123
|
+
if (!p || (p == null ? void 0 : p.apply) === applyToFilter) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
if (typeof p.apply === "function") {
|
|
127
|
+
return p.apply(applyArgs[0], applyArgs[1]);
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
});
|
|
131
|
+
result = vite.mergeConfig(result, { ...rest, plugins });
|
|
132
|
+
} else {
|
|
133
|
+
result = vite.mergeConfig(result, settings.config.vite || {});
|
|
134
|
+
}
|
|
116
135
|
result = vite.mergeConfig(result, commandConfig);
|
|
117
136
|
if (result.plugins) {
|
|
118
137
|
sortPlugins(result.plugins);
|
|
@@ -47,7 +47,7 @@ async function createContainer(params = {}) {
|
|
|
47
47
|
"import.meta.env.BASE_URL": settings.config.base ? JSON.stringify(settings.config.base) : "undefined"
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
|
-
{ settings, logging, mode: "dev", fs }
|
|
50
|
+
{ settings, logging, mode: "dev", command: "dev", fs }
|
|
51
51
|
);
|
|
52
52
|
await runHookConfigDone({ settings, logging });
|
|
53
53
|
const viteServer = await vite.createServer(viteConfig);
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -31,7 +31,7 @@ async function dev(settings, options) {
|
|
|
31
31
|
isRestart: options.isRestart
|
|
32
32
|
})
|
|
33
33
|
);
|
|
34
|
-
const currentVersion = "2.0.
|
|
34
|
+
const currentVersion = "2.0.17";
|
|
35
35
|
if (currentVersion.includes("-")) {
|
|
36
36
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
37
37
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import type { LogOptions } from '../../logger/core';
|
|
2
3
|
import type { SSROptions } from '../../render/dev';
|
|
3
|
-
export declare function call(options: SSROptions): Promise<{
|
|
4
|
+
export declare function call(options: SSROptions, logging: LogOptions): Promise<{
|
|
4
5
|
type: "simple";
|
|
5
6
|
body: string;
|
|
6
7
|
encoding?: BufferEncoding | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRenderContext } from "../../render/index.js";
|
|
2
2
|
import { call as callEndpoint } from "../index.js";
|
|
3
|
-
async function call(options) {
|
|
3
|
+
async function call(options, logging) {
|
|
4
4
|
const {
|
|
5
5
|
env,
|
|
6
6
|
preload: [, mod]
|
|
@@ -12,7 +12,7 @@ async function call(options) {
|
|
|
12
12
|
pathname: options.pathname,
|
|
13
13
|
route: options.route
|
|
14
14
|
});
|
|
15
|
-
return await callEndpoint(endpointHandler, env, ctx);
|
|
15
|
+
return await callEndpoint(endpointHandler, env, ctx, logging);
|
|
16
16
|
}
|
|
17
17
|
export {
|
|
18
18
|
call
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { AstroConfig, EndpointHandler } from '../../@types/astro';
|
|
3
3
|
import type { Environment, RenderContext } from '../render/index';
|
|
4
4
|
import { AstroCookies } from '../cookies/index.js';
|
|
5
|
+
import { LogOptions } from '../logger/core.js';
|
|
5
6
|
type EndpointCallResult = {
|
|
6
7
|
type: 'simple';
|
|
7
8
|
body: string;
|
|
@@ -11,6 +12,6 @@ type EndpointCallResult = {
|
|
|
11
12
|
type: 'response';
|
|
12
13
|
response: Response;
|
|
13
14
|
};
|
|
14
|
-
export declare function call(mod: EndpointHandler, env: Environment, ctx: RenderContext): Promise<EndpointCallResult>;
|
|
15
|
+
export declare function call(mod: EndpointHandler, env: Environment, ctx: RenderContext, logging: LogOptions): Promise<EndpointCallResult>;
|
|
15
16
|
export declare function throwIfRedirectNotAllowed(response: Response, config: AstroConfig): void;
|
|
16
17
|
export {};
|
|
@@ -2,6 +2,7 @@ import { renderEndpoint } from "../../runtime/server/index.js";
|
|
|
2
2
|
import { ASTRO_VERSION } from "../constants.js";
|
|
3
3
|
import { AstroCookies, attachToResponse } from "../cookies/index.js";
|
|
4
4
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
5
|
+
import { warn } from "../logger/core.js";
|
|
5
6
|
import { getParamsAndProps, GetParamsAndPropsError } from "../render/core.js";
|
|
6
7
|
const clientAddressSymbol = Symbol.for("astro.clientAddress");
|
|
7
8
|
function createAPIContext({
|
|
@@ -42,7 +43,7 @@ function createAPIContext({
|
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
|
-
async function call(mod, env, ctx) {
|
|
46
|
+
async function call(mod, env, ctx, logging) {
|
|
46
47
|
var _a, _b;
|
|
47
48
|
const paramsAndPropsResp = await getParamsAndProps({
|
|
48
49
|
mod,
|
|
@@ -75,6 +76,22 @@ async function call(mod, env, ctx) {
|
|
|
75
76
|
response
|
|
76
77
|
};
|
|
77
78
|
}
|
|
79
|
+
if (env.ssr && !mod.prerender) {
|
|
80
|
+
if (response.hasOwnProperty("headers")) {
|
|
81
|
+
warn(
|
|
82
|
+
logging,
|
|
83
|
+
"ssr",
|
|
84
|
+
"Setting headers is not supported when returning an object. Please return an instance of Response. See https://docs.astro.build/en/core-concepts/endpoints/#server-endpoints-api-routes for more information."
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
if (response.encoding) {
|
|
88
|
+
warn(
|
|
89
|
+
logging,
|
|
90
|
+
"ssr",
|
|
91
|
+
"`encoding` is ignored in SSR. To return a charset other than UTF-8, please return an instance of Response. See https://docs.astro.build/en/core-concepts/endpoints/#server-endpoints-api-routes for more information."
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
78
95
|
return {
|
|
79
96
|
type: "simple",
|
|
80
97
|
body: response.body,
|
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function serverStart({
|
|
|
47
47
|
base,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "2.0.
|
|
50
|
+
const version = "2.0.17";
|
|
51
51
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
52
52
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
53
53
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -233,7 +233,7 @@ function printHelp({
|
|
|
233
233
|
message.push(
|
|
234
234
|
linebreak(),
|
|
235
235
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
236
|
-
`v${"2.0.
|
|
236
|
+
`v${"2.0.17"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|
package/dist/core/sync/index.js
CHANGED
|
@@ -38,13 +38,17 @@ function writeHtmlResponse(res, statusCode, html) {
|
|
|
38
38
|
}
|
|
39
39
|
async function writeWebResponse(res, webResponse) {
|
|
40
40
|
const { status, headers, body } = webResponse;
|
|
41
|
-
const _headers = Object.fromEntries(headers.entries());
|
|
42
|
-
if ("getSetCookie" in headers && typeof headers.getSetCookie === "function") {
|
|
43
|
-
_headers["set-cookie"] = headers.getSetCookie();
|
|
44
|
-
}
|
|
45
41
|
const setCookieHeaders = Array.from(getSetCookiesFromResponse(webResponse));
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
setCookieHeaders.forEach((cookie) => {
|
|
43
|
+
headers.append("set-cookie", cookie);
|
|
44
|
+
});
|
|
45
|
+
const _headers = Object.fromEntries(headers.entries());
|
|
46
|
+
if (headers.has("set-cookie")) {
|
|
47
|
+
if ("getSetCookie" in headers && typeof headers.getSetCookie === "function") {
|
|
48
|
+
_headers["set-cookie"] = headers.getSetCookie();
|
|
49
|
+
} else {
|
|
50
|
+
_headers["set-cookie"] = headers.get("set-cookie");
|
|
51
|
+
}
|
|
48
52
|
}
|
|
49
53
|
res.writeHead(status, _headers);
|
|
50
54
|
if (body) {
|
|
@@ -114,7 +114,7 @@ async function handleRoute(matchedRoute, url, pathname, body, origin, env, manif
|
|
|
114
114
|
route
|
|
115
115
|
};
|
|
116
116
|
if (route.type === "endpoint") {
|
|
117
|
-
const result = await callEndpoint(options);
|
|
117
|
+
const result = await callEndpoint(options, logging);
|
|
118
118
|
if (result.type === "response") {
|
|
119
119
|
if (result.response.headers.get("X-Astro-Response") === "Not-Found") {
|
|
120
120
|
const fourOhFourRoute = await matchRoute("/404", env, manifest);
|
|
@@ -65,10 +65,10 @@ function astroHeadPropagationBuildPlugin(options, internals) {
|
|
|
65
65
|
for (const [info2] of walkParentInfos(id, this)) {
|
|
66
66
|
appendPropagation(info2);
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
const info = this.getModuleInfo(id);
|
|
69
|
+
if (info) {
|
|
70
|
+
appendPropagation(info);
|
|
71
|
+
}
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.17",
|
|
4
4
|
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "withastro",
|
|
@@ -85,11 +85,11 @@
|
|
|
85
85
|
"src/content/template"
|
|
86
86
|
],
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@astrojs/compiler": "^1.
|
|
88
|
+
"@astrojs/compiler": "^1.2.0",
|
|
89
89
|
"@astrojs/language-server": "^0.28.3",
|
|
90
90
|
"@astrojs/markdown-remark": "^2.0.1",
|
|
91
|
-
"@astrojs/telemetry": "^2.0.
|
|
92
|
-
"@astrojs/webapi": "^2.0.
|
|
91
|
+
"@astrojs/telemetry": "^2.0.1",
|
|
92
|
+
"@astrojs/webapi": "^2.0.2",
|
|
93
93
|
"@babel/core": "^7.18.2",
|
|
94
94
|
"@babel/generator": "^7.18.2",
|
|
95
95
|
"@babel/parser": "^7.18.4",
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
"@types/send": "^0.17.1",
|
|
161
161
|
"@types/server-destroy": "^1.0.1",
|
|
162
162
|
"@types/unist": "^2.0.6",
|
|
163
|
-
"astro-scripts": "0.0.
|
|
163
|
+
"astro-scripts": "0.0.12",
|
|
164
164
|
"chai": "^4.3.6",
|
|
165
165
|
"cheerio": "^1.0.0-rc.11",
|
|
166
166
|
"eol": "^0.9.1",
|