astro 2.8.2 → 2.8.4
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/components/Code.astro +1 -1
- package/dist/@types/astro.d.ts +2 -2
- package/dist/assets/consts.d.ts +4 -4
- package/dist/assets/consts.js +11 -3
- package/dist/assets/index.d.ts +0 -2
- package/dist/assets/index.js +0 -4
- package/dist/assets/services/service.d.ts +1 -1
- package/dist/assets/services/service.js +6 -3
- package/dist/assets/services/sharp.js +3 -0
- package/dist/assets/services/squoosh.js +25 -0
- package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js +3 -3
- package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js +3 -3
- package/dist/assets/services/vendor/squoosh/image-pool.js +2 -2
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js +3 -3
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js +3 -3
- package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js +3 -3
- package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js +3 -3
- package/dist/assets/types.d.ts +1 -0
- package/dist/assets/utils/emitAsset.d.ts +2 -2
- package/dist/assets/utils/metadata.d.ts +1 -4
- package/dist/assets/utils/transformToPath.js +1 -1
- package/dist/assets/vendor/image-size/index.js +2 -2
- package/dist/assets/vendor/image-size/types/tiff.js +1 -1
- package/dist/cli/add/index.d.ts +1 -2
- package/dist/cli/add/index.js +7 -4
- package/dist/cli/check/index.d.ts +1 -1
- package/dist/cli/check/index.js +2 -2
- package/dist/cli/check/print.js +1 -1
- package/dist/cli/dev/index.js +1 -1
- package/dist/cli/index.js +8 -28
- package/dist/cli/info/index.d.ts +1 -2
- package/dist/cli/info/index.js +2 -2
- package/dist/cli/load-settings.js +1 -1
- package/dist/cli/sync/index.js +1 -1
- package/dist/cli/throw-and-exit.d.ts +2 -0
- package/dist/cli/throw-and-exit.js +21 -0
- package/dist/config/index.js +1 -1
- package/dist/content/runtime-assets.d.ts +1 -1
- package/dist/content/runtime-assets.js +1 -1
- package/dist/content/vite-plugin-content-imports.js +1 -1
- package/dist/core/app/index.d.ts +3 -1
- package/dist/core/app/index.js +33 -47
- package/dist/core/app/node.d.ts +1 -1
- package/dist/core/app/node.js +3 -3
- package/dist/core/build/common.js +2 -2
- package/dist/core/build/css-asset-name.js +2 -2
- package/dist/core/build/generate.d.ts +1 -1
- package/dist/core/build/generate.js +21 -43
- package/dist/core/build/index.js +9 -2
- package/dist/core/build/static-build.js +8 -6
- package/dist/core/compile/compile.js +1 -1
- package/dist/core/compile/style.js +1 -1
- package/dist/core/config/config.d.ts +1 -1
- package/dist/core/config/config.js +16 -22
- package/dist/core/config/merge.js +10 -0
- package/dist/core/config/schema.d.ts +1 -1
- package/dist/core/config/schema.js +1 -6
- package/dist/core/config/settings.js +1 -1
- package/dist/core/config/timer.js +1 -1
- package/dist/core/config/tsconfig.js +2 -2
- package/dist/core/config/vite-load.d.ts +1 -1
- package/dist/core/config/vite-load.js +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.d.ts +1 -1
- package/dist/core/create-vite.js +2 -2
- package/dist/core/dev/container.d.ts +3 -3
- package/dist/core/dev/container.js +1 -1
- package/dist/core/dev/dev.d.ts +2 -2
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/dev/vite.js +2 -2
- package/dist/core/errors/errors-data.d.ts +1 -1
- package/dist/core/errors/errors-data.js +2 -2
- package/dist/core/fs/index.js +4 -4
- package/dist/core/logger/node.d.ts +1 -1
- package/dist/core/logger/node.js +2 -2
- package/dist/core/messages.js +2 -2
- package/dist/core/module-loader/loader.d.ts +1 -1
- package/dist/core/module-loader/loader.js +1 -1
- package/dist/core/module-loader/vite.js +1 -1
- package/dist/core/preview/index.js +1 -1
- package/dist/core/preview/static-preview-server.d.ts +1 -1
- package/dist/core/preview/static-preview-server.js +1 -1
- package/dist/core/preview/vite-plugin-astro-preview.js +2 -2
- package/dist/core/render/core.d.ts +9 -2
- package/dist/core/render/core.js +34 -1
- package/dist/core/render/dev/environment.d.ts +2 -2
- package/dist/core/render/dev/environment.js +6 -7
- package/dist/core/render/dev/index.js +3 -29
- package/dist/core/render/dev/vite.js +1 -1
- package/dist/core/render/index.d.ts +1 -1
- package/dist/core/render/index.js +2 -2
- package/dist/core/request.d.ts +1 -1
- package/dist/core/routing/manifest/create.d.ts +1 -1
- package/dist/core/routing/manifest/create.js +22 -3
- package/dist/core/util.js +3 -3
- package/dist/integrations/index.d.ts +1 -1
- package/dist/vite-plugin-astro-server/base.js +1 -1
- package/dist/vite-plugin-astro-server/plugin.d.ts +10 -2
- package/dist/vite-plugin-astro-server/plugin.js +34 -9
- package/dist/vite-plugin-astro-server/request.d.ts +12 -3
- package/dist/vite-plugin-astro-server/request.js +23 -15
- package/dist/vite-plugin-astro-server/response.d.ts +1 -1
- package/dist/vite-plugin-astro-server/route.d.ts +15 -3
- package/dist/vite-plugin-astro-server/route.js +32 -20
- package/dist/vite-plugin-config-alias/index.js +1 -1
- package/dist/vite-plugin-env/index.js +5 -2
- package/dist/vite-plugin-jsx/index.js +1 -1
- package/dist/vite-plugin-load-fallback/index.d.ts +1 -1
- package/dist/vite-plugin-load-fallback/index.js +2 -2
- package/dist/vite-plugin-utils/index.js +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { emitESMImage } from "../assets/
|
|
2
|
+
import { emitESMImage } from "../assets/utils/emitAsset.js";
|
|
3
3
|
function createImage(pluginContext, entryFilePath) {
|
|
4
4
|
return () => {
|
|
5
5
|
return z.string().transform(async (imagePath, ctx) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as devalue from "devalue";
|
|
2
2
|
import { extname } from "node:path";
|
|
3
|
-
import { pathToFileURL } from "url";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
4
|
import { AstroErrorData } from "../core/errors/errors-data.js";
|
|
5
5
|
import { AstroError } from "../core/errors/errors.js";
|
|
6
6
|
import { escapeViteEnvReferences } from "../vite-plugin-utils/index.js";
|
package/dist/core/app/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RouteData, SSRManifest } from '../../@types/astro';
|
|
1
|
+
import type { ManifestData, RouteData, SSRManifest } from '../../@types/astro';
|
|
2
2
|
export { deserializeManifest } from './common.js';
|
|
3
3
|
export interface MatchOptions {
|
|
4
4
|
matchNotFound?: boolean | undefined;
|
|
@@ -6,6 +6,8 @@ export interface MatchOptions {
|
|
|
6
6
|
export declare class App {
|
|
7
7
|
#private;
|
|
8
8
|
constructor(manifest: SSRManifest, streaming?: boolean);
|
|
9
|
+
set setManifest(newManifest: SSRManifest);
|
|
10
|
+
set setManifestData(newManifestData: ManifestData);
|
|
9
11
|
removeBase(pathname: string): string;
|
|
10
12
|
match(request: Request, { matchNotFound }?: MatchOptions): RouteData | undefined;
|
|
11
13
|
render(request: Request, routeData?: RouteData, locals?: object): Promise<Response>;
|
package/dist/core/app/index.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import mime from "mime";
|
|
2
2
|
import { attachToResponse, getSetCookiesFromResponse } from "../cookies/index.js";
|
|
3
|
-
import { callEndpoint
|
|
3
|
+
import { callEndpoint } from "../endpoint/index.js";
|
|
4
4
|
import { consoleLogDestination } from "../logger/console.js";
|
|
5
5
|
import { error } from "../logger/core.js";
|
|
6
|
-
import { callMiddleware } from "../middleware/callMiddleware.js";
|
|
7
6
|
import { prependForwardSlash, removeTrailingForwardSlash } from "../path.js";
|
|
8
7
|
import { RedirectSinglePageBuiltModule } from "../redirects/index.js";
|
|
9
8
|
import {
|
|
10
9
|
createEnvironment,
|
|
11
10
|
createRenderContext,
|
|
12
|
-
|
|
11
|
+
tryRenderPage
|
|
13
12
|
} from "../render/index.js";
|
|
14
13
|
import { RouteCache } from "../render/route-cache.js";
|
|
15
14
|
import {
|
|
@@ -22,6 +21,9 @@ import { deserializeManifest } from "./common.js";
|
|
|
22
21
|
const clientLocalsSymbol = Symbol.for("astro.locals");
|
|
23
22
|
const responseSentSymbol = Symbol.for("astro.responseSent");
|
|
24
23
|
class App {
|
|
24
|
+
/**
|
|
25
|
+
* The current environment of the application
|
|
26
|
+
*/
|
|
25
27
|
#env;
|
|
26
28
|
#manifest;
|
|
27
29
|
#manifestData;
|
|
@@ -31,7 +33,6 @@ class App {
|
|
|
31
33
|
dest: consoleLogDestination,
|
|
32
34
|
level: "info"
|
|
33
35
|
};
|
|
34
|
-
#base;
|
|
35
36
|
#baseWithoutTrailingSlash;
|
|
36
37
|
constructor(manifest, streaming = true) {
|
|
37
38
|
this.#manifest = manifest;
|
|
@@ -39,26 +40,39 @@ class App {
|
|
|
39
40
|
routes: manifest.routes.map((route) => route.routeData)
|
|
40
41
|
};
|
|
41
42
|
this.#routeDataToRouteInfo = new Map(manifest.routes.map((route) => [route.routeData, route]));
|
|
42
|
-
this.#
|
|
43
|
-
|
|
43
|
+
this.#baseWithoutTrailingSlash = removeTrailingForwardSlash(this.#manifest.base);
|
|
44
|
+
this.#env = this.#createEnvironment(streaming);
|
|
45
|
+
}
|
|
46
|
+
set setManifest(newManifest) {
|
|
47
|
+
this.#manifest = newManifest;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates an environment by reading the stored manifest
|
|
51
|
+
*
|
|
52
|
+
* @param streaming
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
#createEnvironment(streaming = false) {
|
|
56
|
+
return createEnvironment({
|
|
57
|
+
adapterName: this.#manifest.adapterName,
|
|
44
58
|
logging: this.#logging,
|
|
45
|
-
markdown: manifest.markdown,
|
|
59
|
+
markdown: this.#manifest.markdown,
|
|
46
60
|
mode: "production",
|
|
47
|
-
compressHTML: manifest.compressHTML,
|
|
48
|
-
renderers: manifest.renderers,
|
|
49
|
-
clientDirectives: manifest.clientDirectives,
|
|
50
|
-
async
|
|
51
|
-
if (!(specifier in manifest.entryModules)) {
|
|
61
|
+
compressHTML: this.#manifest.compressHTML,
|
|
62
|
+
renderers: this.#manifest.renderers,
|
|
63
|
+
clientDirectives: this.#manifest.clientDirectives,
|
|
64
|
+
resolve: async (specifier) => {
|
|
65
|
+
if (!(specifier in this.#manifest.entryModules)) {
|
|
52
66
|
throw new Error(`Unable to resolve [${specifier}]`);
|
|
53
67
|
}
|
|
54
|
-
const bundlePath = manifest.entryModules[specifier];
|
|
68
|
+
const bundlePath = this.#manifest.entryModules[specifier];
|
|
55
69
|
switch (true) {
|
|
56
70
|
case bundlePath.startsWith("data:"):
|
|
57
71
|
case bundlePath.length === 0: {
|
|
58
72
|
return bundlePath;
|
|
59
73
|
}
|
|
60
74
|
default: {
|
|
61
|
-
return createAssetLink(bundlePath, manifest.base, manifest.assetsPrefix);
|
|
75
|
+
return createAssetLink(bundlePath, this.#manifest.base, this.#manifest.assetsPrefix);
|
|
62
76
|
}
|
|
63
77
|
}
|
|
64
78
|
},
|
|
@@ -67,11 +81,12 @@ class App {
|
|
|
67
81
|
ssr: true,
|
|
68
82
|
streaming
|
|
69
83
|
});
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
}
|
|
85
|
+
set setManifestData(newManifestData) {
|
|
86
|
+
this.#manifestData = newManifestData;
|
|
72
87
|
}
|
|
73
88
|
removeBase(pathname) {
|
|
74
|
-
if (pathname.startsWith(this.#base)) {
|
|
89
|
+
if (pathname.startsWith(this.#manifest.base)) {
|
|
75
90
|
return pathname.slice(this.#baseWithoutTrailingSlash.length + 1);
|
|
76
91
|
}
|
|
77
92
|
return pathname;
|
|
@@ -200,36 +215,7 @@ class App {
|
|
|
200
215
|
mod,
|
|
201
216
|
env: this.#env
|
|
202
217
|
});
|
|
203
|
-
const
|
|
204
|
-
request: renderContext.request,
|
|
205
|
-
params: renderContext.params,
|
|
206
|
-
props: renderContext.props,
|
|
207
|
-
site: this.#env.site,
|
|
208
|
-
adapterName: this.#env.adapterName
|
|
209
|
-
});
|
|
210
|
-
let response;
|
|
211
|
-
if (page.onRequest) {
|
|
212
|
-
response = await callMiddleware(
|
|
213
|
-
this.#env.logging,
|
|
214
|
-
page.onRequest,
|
|
215
|
-
apiContext,
|
|
216
|
-
() => {
|
|
217
|
-
return renderPage({
|
|
218
|
-
mod,
|
|
219
|
-
renderContext,
|
|
220
|
-
env: this.#env,
|
|
221
|
-
cookies: apiContext.cookies
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
);
|
|
225
|
-
} else {
|
|
226
|
-
response = await renderPage({
|
|
227
|
-
mod,
|
|
228
|
-
renderContext,
|
|
229
|
-
env: this.#env,
|
|
230
|
-
cookies: apiContext.cookies
|
|
231
|
-
});
|
|
232
|
-
}
|
|
218
|
+
const response = await tryRenderPage(renderContext, this.#env, mod, page.onRequest);
|
|
233
219
|
Reflect.set(request, responseSentSymbol, true);
|
|
234
220
|
return response;
|
|
235
221
|
} catch (err) {
|
package/dist/core/app/node.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { RouteData } from '../../@types/astro';
|
|
3
3
|
import type { SSRManifest } from './types';
|
|
4
|
-
import { IncomingMessage } from 'http';
|
|
4
|
+
import { IncomingMessage } from 'node:http';
|
|
5
5
|
import { App, type MatchOptions } from './index.js';
|
|
6
6
|
declare class NodeIncomingMessage extends IncomingMessage {
|
|
7
7
|
/**
|
package/dist/core/app/node.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import { IncomingMessage } from "http";
|
|
3
|
-
import { TLSSocket } from "tls";
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import { IncomingMessage } from "node:http";
|
|
3
|
+
import { TLSSocket } from "node:tls";
|
|
4
4
|
import { deserializeManifest } from "./common.js";
|
|
5
5
|
import { App } from "./index.js";
|
|
6
6
|
const clientAddressSymbol = Symbol.for("astro.clientAddress");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import npath from "path";
|
|
2
|
-
import { fileURLToPath, pathToFileURL } from "url";
|
|
1
|
+
import npath from "node:path";
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
3
|
import { appendForwardSlash } from "../../core/path.js";
|
|
4
4
|
const STATUS_CODE_PAGES = /* @__PURE__ */ new Set(["/404", "/500"]);
|
|
5
5
|
const FALLBACK_OUT_DIR_NAME = "./.astro/";
|
|
@@ -12,4 +12,4 @@ export declare function generatePages(opts: StaticBuildOptions, internals: Build
|
|
|
12
12
|
* @param settings
|
|
13
13
|
* @param renderers
|
|
14
14
|
*/
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function createBuildManifest(settings: AstroSettings, internals: BuildInternals, renderers: SSRLoadedRenderer[]): SSRManifest;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
1
|
import * as colors from "kleur/colors";
|
|
3
2
|
import { bgGreen, black, cyan, dim, green, magenta } from "kleur/colors";
|
|
4
|
-
import
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
5
|
import {
|
|
6
6
|
generateImage as generateImageInternal,
|
|
7
7
|
getStaticImageList
|
|
@@ -20,16 +20,15 @@ import {
|
|
|
20
20
|
import { runHookBuildGenerated } from "../../integrations/index.js";
|
|
21
21
|
import { isServerLikeOutput } from "../../prerender/utils.js";
|
|
22
22
|
import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from "../../vite-plugin-scripts/index.js";
|
|
23
|
-
import { callEndpoint,
|
|
23
|
+
import { callEndpoint, throwIfRedirectNotAllowed } from "../endpoint/index.js";
|
|
24
24
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
25
25
|
import { debug, info } from "../logger/core.js";
|
|
26
|
-
import { callMiddleware } from "../middleware/callMiddleware.js";
|
|
27
26
|
import {
|
|
28
27
|
getRedirectLocationOrThrow,
|
|
29
28
|
RedirectSinglePageBuiltModule,
|
|
30
29
|
routeIsRedirect
|
|
31
30
|
} from "../redirects/index.js";
|
|
32
|
-
import { createEnvironment, createRenderContext,
|
|
31
|
+
import { createEnvironment, createRenderContext, tryRenderPage } from "../render/index.js";
|
|
33
32
|
import { callGetStaticPaths } from "../render/route-cache.js";
|
|
34
33
|
import {
|
|
35
34
|
createAssetLink,
|
|
@@ -115,26 +114,26 @@ ${bgGreen(black(` ${verb} static routes `))}`);
|
|
|
115
114
|
}
|
|
116
115
|
} else {
|
|
117
116
|
const ssrEntry = ssrEntryPage;
|
|
118
|
-
const manifest =
|
|
117
|
+
const manifest = createBuildManifest(opts.settings, internals, ssrEntry.renderers);
|
|
119
118
|
await generatePage(opts, internals, pageData, ssrEntry, builtPaths, manifest);
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
}
|
|
123
122
|
for (const pageData of eachRedirectPageData(internals)) {
|
|
124
123
|
const entry = await getEntryForRedirectRoute(pageData.route, internals, outFolder);
|
|
125
|
-
const manifest =
|
|
124
|
+
const manifest = createBuildManifest(opts.settings, internals, entry.renderers);
|
|
126
125
|
await generatePage(opts, internals, pageData, entry, builtPaths, manifest);
|
|
127
126
|
}
|
|
128
127
|
} else {
|
|
129
128
|
for (const [pageData, filePath] of eachPageDataFromEntryPoint(internals)) {
|
|
130
129
|
const ssrEntryURLPage = createEntryURL(filePath, outFolder);
|
|
131
130
|
const entry = await import(ssrEntryURLPage.toString());
|
|
132
|
-
const manifest =
|
|
131
|
+
const manifest = createBuildManifest(opts.settings, internals, entry.renderers);
|
|
133
132
|
await generatePage(opts, internals, pageData, entry, builtPaths, manifest);
|
|
134
133
|
}
|
|
135
134
|
for (const pageData of eachRedirectPageData(internals)) {
|
|
136
135
|
const entry = await getEntryForRedirectRoute(pageData.route, internals, outFolder);
|
|
137
|
-
const manifest =
|
|
136
|
+
const manifest = createBuildManifest(opts.settings, internals, entry.renderers);
|
|
138
137
|
await generatePage(opts, internals, pageData, entry, builtPaths, manifest);
|
|
139
138
|
}
|
|
140
139
|
}
|
|
@@ -373,7 +372,7 @@ async function generatePath(pathname, opts, gopts, manifest, onRequest) {
|
|
|
373
372
|
clientDirectives: manifest.clientDirectives,
|
|
374
373
|
compressHTML: manifest.compressHTML,
|
|
375
374
|
async resolve(specifier) {
|
|
376
|
-
const hashedFilePath =
|
|
375
|
+
const hashedFilePath = manifest.entryModules[specifier];
|
|
377
376
|
if (typeof hashedFilePath !== "string") {
|
|
378
377
|
if (specifier === BEFORE_HYDRATION_SCRIPT_ID) {
|
|
379
378
|
return "";
|
|
@@ -421,35 +420,7 @@ async function generatePath(pathname, opts, gopts, manifest, onRequest) {
|
|
|
421
420
|
} else {
|
|
422
421
|
let response;
|
|
423
422
|
try {
|
|
424
|
-
|
|
425
|
-
request: renderContext.request,
|
|
426
|
-
params: renderContext.params,
|
|
427
|
-
props: renderContext.props,
|
|
428
|
-
site: env.site,
|
|
429
|
-
adapterName: env.adapterName
|
|
430
|
-
});
|
|
431
|
-
if (onRequest) {
|
|
432
|
-
response = await callMiddleware(
|
|
433
|
-
env.logging,
|
|
434
|
-
onRequest,
|
|
435
|
-
apiContext,
|
|
436
|
-
() => {
|
|
437
|
-
return renderPage({
|
|
438
|
-
mod,
|
|
439
|
-
renderContext,
|
|
440
|
-
env,
|
|
441
|
-
cookies: apiContext.cookies
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
);
|
|
445
|
-
} else {
|
|
446
|
-
response = await renderPage({
|
|
447
|
-
mod,
|
|
448
|
-
renderContext,
|
|
449
|
-
env,
|
|
450
|
-
cookies: apiContext.cookies
|
|
451
|
-
});
|
|
452
|
-
}
|
|
423
|
+
response = await tryRenderPage(renderContext, env, mod, onRequest);
|
|
453
424
|
} catch (err) {
|
|
454
425
|
if (!AstroError.is(err) && !err.id && typeof err === "object") {
|
|
455
426
|
err.id = pageData.component;
|
|
@@ -461,9 +432,16 @@ async function generatePath(pathname, opts, gopts, manifest, onRequest) {
|
|
|
461
432
|
return;
|
|
462
433
|
}
|
|
463
434
|
const location = getRedirectLocationOrThrow(response.headers);
|
|
435
|
+
const fromPath = new URL(renderContext.request.url).pathname;
|
|
436
|
+
const delay = response.status === 302 ? 2 : 0;
|
|
464
437
|
body = `<!doctype html>
|
|
465
438
|
<title>Redirecting to: ${location}</title>
|
|
466
|
-
<meta http-equiv="refresh" content="
|
|
439
|
+
<meta http-equiv="refresh" content="${delay};url=${location}">
|
|
440
|
+
<meta name="robots" content="noindex">
|
|
441
|
+
<link rel="canonical" href="${location}">
|
|
442
|
+
<body>
|
|
443
|
+
<a href="${location}">Redirecting from <code>${fromPath}</code> to <code>${location}</code></a>
|
|
444
|
+
</body>`;
|
|
467
445
|
if (pageData.route.type !== "redirect") {
|
|
468
446
|
pageData.route.redirect = location;
|
|
469
447
|
}
|
|
@@ -479,10 +457,10 @@ async function generatePath(pathname, opts, gopts, manifest, onRequest) {
|
|
|
479
457
|
await fs.promises.mkdir(outFolder, { recursive: true });
|
|
480
458
|
await fs.promises.writeFile(outFile, body, encoding ?? "utf-8");
|
|
481
459
|
}
|
|
482
|
-
function
|
|
460
|
+
function createBuildManifest(settings, internals, renderers) {
|
|
483
461
|
return {
|
|
484
462
|
assets: /* @__PURE__ */ new Set(),
|
|
485
|
-
entryModules:
|
|
463
|
+
entryModules: Object.fromEntries(internals.entrySpecifierToBundleMap.entries()),
|
|
486
464
|
routes: [],
|
|
487
465
|
adapterName: "",
|
|
488
466
|
markdown: settings.config.markdown,
|
|
@@ -497,7 +475,7 @@ function generateRuntimeManifest(settings, internals, renderers) {
|
|
|
497
475
|
}
|
|
498
476
|
export {
|
|
499
477
|
chunkIsPage,
|
|
478
|
+
createBuildManifest,
|
|
500
479
|
generatePages,
|
|
501
|
-
generateRuntimeManifest,
|
|
502
480
|
rootRelativeFacadeId
|
|
503
481
|
};
|
package/dist/core/build/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
1
|
import * as colors from "kleur/colors";
|
|
3
|
-
import
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { performance } from "node:perf_hooks";
|
|
4
4
|
import {
|
|
5
5
|
runHookBuildDone,
|
|
6
6
|
runHookBuildStart,
|
|
@@ -176,6 +176,13 @@ class AstroBuilder {
|
|
|
176
176
|
);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
+
if (config.build.split === true) {
|
|
180
|
+
if (config.output !== "server") {
|
|
181
|
+
throw new Error(
|
|
182
|
+
'The option `build.split` can only be used when `output` is set to `"server"`.'
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
179
186
|
}
|
|
180
187
|
/** Stats */
|
|
181
188
|
async printStats({
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { teardown } from "@astrojs/compiler";
|
|
2
2
|
import * as eslexer from "es-module-lexer";
|
|
3
3
|
import glob from "fast-glob";
|
|
4
|
-
import fs from "fs";
|
|
5
4
|
import { bgGreen, bgMagenta, black, dim } from "kleur/colors";
|
|
6
|
-
import
|
|
7
|
-
import path from "path";
|
|
8
|
-
import { fileURLToPath } from "url";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path, { extname } from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
9
8
|
import * as vite from "vite";
|
|
10
9
|
import {
|
|
11
10
|
createBuildInternals,
|
|
@@ -19,6 +18,7 @@ import { isServerLikeOutput } from "../../prerender/utils.js";
|
|
|
19
18
|
import { PAGE_SCRIPT_ID } from "../../vite-plugin-scripts/index.js";
|
|
20
19
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
21
20
|
import { info } from "../logger/core.js";
|
|
21
|
+
import { routeIsRedirect } from "../redirects/index.js";
|
|
22
22
|
import { getOutDirWithinCwd } from "./common.js";
|
|
23
23
|
import { generatePages } from "./generate.js";
|
|
24
24
|
import { trackPageData } from "./internal.js";
|
|
@@ -43,8 +43,10 @@ async function viteBuild(opts) {
|
|
|
43
43
|
const astroModuleURL = new URL("./" + component, settings.config.root);
|
|
44
44
|
const astroModuleId = prependForwardSlash(component);
|
|
45
45
|
trackPageData(internals, component, pageData, astroModuleId, astroModuleURL);
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
if (!routeIsRedirect(pageData.route)) {
|
|
47
|
+
pageInput.add(astroModuleId);
|
|
48
|
+
facadeIdToPageDataMap.set(fileURLToPath(astroModuleURL), pageData);
|
|
49
|
+
}
|
|
48
50
|
}
|
|
49
51
|
if (((_c = (_b = (_a = settings.config) == null ? void 0 : _a.vite) == null ? void 0 : _b.build) == null ? void 0 : _c.emptyOutDir) !== false) {
|
|
50
52
|
emptyDir(settings.config.outDir, new Set(".git"));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { transform } from "@astrojs/compiler";
|
|
2
|
-
import { fileURLToPath } from "url";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { normalizePath } from "vite";
|
|
4
4
|
import { AggregateError, CompilerError } from "../errors/errors.js";
|
|
5
5
|
import { AstroErrorData } from "../errors/index.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { Arguments as Flags } from 'yargs-parser';
|
|
3
3
|
import type { AstroConfig, AstroUserConfig, CLIFlags } from '../../@types/astro';
|
|
4
|
-
import fs from 'fs';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
5
|
export declare const LEGACY_ASTRO_CONFIG_KEYS: Set<string>;
|
|
6
6
|
/** Turn raw config values into normalized values */
|
|
7
7
|
export declare function validateConfig(userConfig: any, root: string, cmd: string): Promise<AstroConfig>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
1
|
import * as colors from "kleur/colors";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
5
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
6
|
+
import { mergeConfig } from "./merge.js";
|
|
6
7
|
import { createRelativeSchema } from "./schema.js";
|
|
7
8
|
import { loadConfigWithVite } from "./vite-load.js";
|
|
8
9
|
const LEGACY_ASTRO_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -84,25 +85,18 @@ function resolveRoot(cwd) {
|
|
|
84
85
|
return cwd ? path.resolve(cwd) : process.cwd();
|
|
85
86
|
}
|
|
86
87
|
function mergeCLIFlags(astroConfig, flags) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
if (typeof flags.host === "string" || typeof flags.host === "boolean") {
|
|
100
|
-
astroConfig.server.host = flags.host;
|
|
101
|
-
}
|
|
102
|
-
if (typeof flags.open === "boolean") {
|
|
103
|
-
astroConfig.server.open = flags.open;
|
|
104
|
-
}
|
|
105
|
-
return astroConfig;
|
|
88
|
+
return mergeConfig(astroConfig, {
|
|
89
|
+
site: flags.site,
|
|
90
|
+
base: flags.base,
|
|
91
|
+
markdown: {
|
|
92
|
+
drafts: flags.drafts
|
|
93
|
+
},
|
|
94
|
+
server: {
|
|
95
|
+
port: flags.port,
|
|
96
|
+
host: flags.host,
|
|
97
|
+
open: flags.open
|
|
98
|
+
}
|
|
99
|
+
});
|
|
106
100
|
}
|
|
107
101
|
async function search(fsMod, root) {
|
|
108
102
|
const paths = [
|
|
@@ -16,6 +16,16 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
|
16
16
|
merged[key] = mergeViteConfig(existing, value);
|
|
17
17
|
continue;
|
|
18
18
|
}
|
|
19
|
+
if (key === "server" && rootPath === "") {
|
|
20
|
+
if (typeof existing === "function" || typeof value === "function") {
|
|
21
|
+
merged[key] = (...args) => {
|
|
22
|
+
const existingConfig = typeof existing === "function" ? existing(...args) : existing;
|
|
23
|
+
const valueConfig = typeof value === "function" ? value(...args) : value;
|
|
24
|
+
return mergeConfigRecursively(existingConfig, valueConfig, key);
|
|
25
|
+
};
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
19
29
|
if (Array.isArray(existing) || Array.isArray(value)) {
|
|
20
30
|
merged[key] = [...arraify(existing ?? []), ...arraify(value ?? [])];
|
|
21
31
|
continue;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { RehypePlugin, RemarkPlugin, RemarkRehype } from '@astrojs/markdown-remark';
|
|
3
3
|
import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
|
|
4
4
|
import type { ViteUserConfig } from '../../@types/astro';
|
|
5
|
-
import type { OutgoingHttpHeaders } from 'http';
|
|
5
|
+
import type { OutgoingHttpHeaders } from 'node:http';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
export declare const AstroConfigSchema: z.ZodObject<{
|
|
8
8
|
root: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
|
|
@@ -171,12 +171,7 @@ function createRelativeSchema(cmd, fileProtocolRoot) {
|
|
|
171
171
|
// preprocess
|
|
172
172
|
(val) => {
|
|
173
173
|
if (typeof val === "function") {
|
|
174
|
-
|
|
175
|
-
if (val.port)
|
|
176
|
-
result.port = val.port;
|
|
177
|
-
if (val.host)
|
|
178
|
-
result.host = val.host;
|
|
179
|
-
return result;
|
|
174
|
+
return val({ command: cmd === "dev" ? "dev" : "preview" });
|
|
180
175
|
} else {
|
|
181
176
|
return val;
|
|
182
177
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import yaml from "js-yaml";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { fileURLToPath, pathToFileURL } from "url";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
4
|
import { getContentPaths } from "../../content/index.js";
|
|
5
5
|
import jsxRenderer from "../../jsx/renderer.js";
|
|
6
6
|
import { isServerLikeOutput } from "../../prerender/utils.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { deepmerge } from "deepmerge-ts";
|
|
2
|
-
import { existsSync } from "fs";
|
|
3
|
-
import { join } from "path";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
4
|
import * as tsr from "tsconfig-resolver";
|
|
5
5
|
const defaultTSConfig = { extends: "astro/tsconfigs/base" };
|
|
6
6
|
const presets = /* @__PURE__ */ new Map([
|
package/dist/core/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { AstroSettings } from '../@types/astro';
|
|
3
3
|
import type { LogOptions } from './logger/core';
|
|
4
|
-
import nodeFs from 'fs';
|
|
4
|
+
import nodeFs from 'node:fs';
|
|
5
5
|
import * as vite from 'vite';
|
|
6
6
|
interface CreateViteOptions {
|
|
7
7
|
settings: AstroSettings;
|
package/dist/core/create-vite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import nodeFs from "fs";
|
|
2
|
-
import { fileURLToPath } from "url";
|
|
1
|
+
import nodeFs from "node:fs";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
3
|
import * as vite from "vite";
|
|
4
4
|
import { crawlFrameworkPkgs } from "vitefu";
|
|
5
5
|
import astroAssetsPlugin from "../assets/vite-plugin-assets.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
|
-
import type * as http from 'http';
|
|
5
|
-
import type { AddressInfo } from 'net';
|
|
4
|
+
import type * as http from 'node:http';
|
|
5
|
+
import type { AddressInfo } from 'node:net';
|
|
6
6
|
import type { AstroSettings, AstroUserConfig } from '../../@types/astro';
|
|
7
|
-
import nodeFs from 'fs';
|
|
7
|
+
import nodeFs from 'node:fs';
|
|
8
8
|
import * as vite from 'vite';
|
|
9
9
|
import type { LogOptions } from '../logger/core.js';
|
|
10
10
|
export interface Container {
|
package/dist/core/dev/dev.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import type http from 'http';
|
|
4
|
-
import type { AddressInfo } from 'net';
|
|
3
|
+
import type http from 'node:http';
|
|
4
|
+
import type { AddressInfo } from 'node:net';
|
|
5
5
|
import type * as vite from 'vite';
|
|
6
6
|
import type yargs from 'yargs-parser';
|
|
7
7
|
import type { AstroSettings } from '../../@types/astro';
|