astro 2.7.2 → 2.7.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/astro.js +0 -1
- package/dist/@types/astro.d.ts +3 -4
- package/dist/assets/image-endpoint.js +1 -1
- package/dist/assets/services/vendor/squoosh/codecs.js +0 -2
- package/dist/assets/vendor/image-size/types/tiff.js +1 -1
- package/dist/cli/index.js +3 -5
- package/dist/cli/telemetry.d.ts +1 -3
- package/dist/cli/telemetry.js +2 -1
- package/dist/content/utils.d.ts +1 -1
- package/dist/content/utils.js +1 -1
- package/dist/core/add/index.d.ts +1 -3
- package/dist/core/add/index.js +8 -4
- package/dist/core/app/node.d.ts +1 -1
- package/dist/core/build/generate.js +12 -22
- package/dist/core/build/index.d.ts +0 -2
- package/dist/core/build/plugins/index.js +3 -3
- package/dist/core/build/plugins/plugin-analyzer.js +1 -1
- package/dist/core/build/plugins/plugin-css.js +1 -1
- package/dist/core/build/plugins/plugin-middleware.d.ts +2 -3
- package/dist/core/build/plugins/plugin-middleware.js +3 -3
- package/dist/core/build/plugins/plugin-renderers.d.ts +2 -3
- package/dist/core/build/plugins/plugin-renderers.js +3 -4
- package/dist/core/build/plugins/plugin-ssr.js +4 -11
- package/dist/core/compile/compile.js +0 -1
- package/dist/core/config/schema.d.ts +73 -73
- package/dist/core/config/schema.js +0 -1
- package/dist/core/config/settings.js +0 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/cookies/cookies.js +4 -2
- package/dist/core/create-vite.js +2 -2
- package/dist/core/dev/container.d.ts +0 -1
- package/dist/core/dev/container.js +2 -6
- package/dist/core/dev/dev.d.ts +0 -2
- package/dist/core/dev/dev.js +3 -2
- package/dist/core/dev/restart.js +1 -1
- package/dist/core/endpoint/dev/index.js +3 -7
- package/dist/core/errors/dev/utils.js +2 -2
- package/dist/core/errors/errors.d.ts +6 -6
- package/dist/core/errors/overlay.d.ts +1 -2
- package/dist/core/errors/overlay.js +3 -2
- package/dist/core/errors/utils.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/callMiddleware.js +0 -4
- package/dist/core/module-loader/loader.d.ts +1 -0
- package/dist/core/preview/index.d.ts +0 -2
- package/dist/core/render/context.js +2 -2
- package/dist/core/render/core.d.ts +1 -21
- package/dist/core/render/core.js +0 -63
- package/dist/core/render/dev/environment.js +1 -2
- package/dist/core/render/dev/index.d.ts +7 -7
- package/dist/core/render/dev/index.js +8 -14
- package/dist/core/render/dev/vite.js +7 -8
- package/dist/core/render/environment.d.ts +13 -9
- package/dist/core/render/environment.js +0 -20
- package/dist/core/render/index.d.ts +4 -3
- package/dist/core/render/index.js +5 -11
- package/dist/core/render/params-and-props.d.ts +13 -0
- package/dist/core/render/params-and-props.js +57 -0
- package/dist/core/render/renderer.d.ts +4 -9
- package/dist/core/render/renderer.js +12 -17
- package/dist/core/render/result.d.ts +12 -0
- package/dist/core/render/route-cache.d.ts +3 -2
- package/dist/core/render/route-cache.js +13 -7
- package/dist/core/routing/manifest/create.js +2 -22
- package/dist/events/error.js +6 -2
- package/dist/prerender/routing.d.ts +3 -3
- package/dist/prerender/routing.js +2 -5
- package/dist/runtime/client/visible.js +1 -2
- package/dist/runtime/client/visible.prebuilt.d.ts +1 -1
- package/dist/runtime/client/visible.prebuilt.js +1 -1
- package/dist/runtime/server/astro-global.js +1 -1
- package/dist/runtime/server/astro-island.js +2 -2
- package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt.js +1 -1
- package/dist/runtime/server/endpoint.js +1 -1
- package/dist/runtime/server/jsx.js +1 -1
- package/dist/runtime/server/render/head.js +1 -1
- package/dist/runtime/server/render/util.js +20 -5
- package/dist/runtime/server/serialize.js +2 -0
- package/dist/vite-plugin-astro/compile.js +2 -4
- package/dist/vite-plugin-astro/hmr.js +1 -1
- package/dist/vite-plugin-astro-postprocess/index.d.ts +1 -6
- package/dist/vite-plugin-astro-postprocess/index.js +1 -1
- package/dist/vite-plugin-astro-server/plugin.js +2 -2
- package/dist/vite-plugin-astro-server/request.js +1 -3
- package/dist/vite-plugin-astro-server/route.d.ts +2 -2
- package/dist/vite-plugin-astro-server/route.js +19 -24
- package/dist/vite-plugin-head/index.d.ts +2 -6
- package/dist/vite-plugin-head/index.js +2 -4
- package/dist/vite-plugin-html/transform/escape.js +2 -2
- package/dist/vite-plugin-html/transform/slots.js +1 -1
- package/dist/vite-plugin-jsx/import-source.js +1 -1
- package/dist/vite-plugin-jsx/tag.d.ts +1 -1
- package/dist/vite-plugin-jsx/tag.js +1 -2
- package/dist/vite-plugin-markdown/content-entry-type.js +2 -3
- package/dist/vite-plugin-scanner/scan.js +1 -1
- package/dist/vite-plugin-scripts/index.js +1 -1
- package/dist/vite-plugin-ssr-manifest/index.js +1 -1
- package/package.json +2 -2
package/astro.js
CHANGED
package/dist/@types/astro.d.ts
CHANGED
|
@@ -765,7 +765,7 @@ export interface AstroUserConfig {
|
|
|
765
765
|
* @docs
|
|
766
766
|
* @name build.split
|
|
767
767
|
* @type {boolean}
|
|
768
|
-
* @default
|
|
768
|
+
* @default `false`
|
|
769
769
|
* @version 2.7.0
|
|
770
770
|
* @description
|
|
771
771
|
* Defines how the SSR code should be bundled when built.
|
|
@@ -1269,7 +1269,6 @@ export interface AstroSettings {
|
|
|
1269
1269
|
tsConfig: TsConfigJson | undefined;
|
|
1270
1270
|
tsConfigPath: string | undefined;
|
|
1271
1271
|
watchFiles: string[];
|
|
1272
|
-
forceDisableTelemetry: boolean;
|
|
1273
1272
|
timer: AstroTimer;
|
|
1274
1273
|
}
|
|
1275
1274
|
export type AsyncRendererComponentFn<U> = (Component: any, props: any, slots: Record<string, string>, metadata?: AstroComponentMetadata) => Promise<U>;
|
|
@@ -1600,15 +1599,15 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
|
|
|
1600
1599
|
*/
|
|
1601
1600
|
locals: App.Locals;
|
|
1602
1601
|
}
|
|
1603
|
-
export type Props = Record<string, unknown>;
|
|
1604
1602
|
export interface EndpointOutput {
|
|
1605
1603
|
body: Body;
|
|
1606
1604
|
encoding?: BufferEncoding;
|
|
1607
1605
|
}
|
|
1608
|
-
export type APIRoute = (context: APIContext) => EndpointOutput | Response | Promise<EndpointOutput | Response>;
|
|
1606
|
+
export type APIRoute<Props extends Record<string, any> = Record<string, any>> = (context: APIContext<Props>) => EndpointOutput | Response | Promise<EndpointOutput | Response>;
|
|
1609
1607
|
export interface EndpointHandler {
|
|
1610
1608
|
[method: string]: APIRoute | ((params: Params, request: Request) => EndpointOutput | Response);
|
|
1611
1609
|
}
|
|
1610
|
+
export type Props = Record<string, unknown>;
|
|
1612
1611
|
export interface AstroRenderer {
|
|
1613
1612
|
/** Name of the renderer. */
|
|
1614
1613
|
name: string;
|
|
@@ -23,7 +23,7 @@ const get = async ({ request }) => {
|
|
|
23
23
|
}
|
|
24
24
|
const url = new URL(request.url);
|
|
25
25
|
const transform = await imageService.parseURL(url, imageServiceConfig);
|
|
26
|
-
if (!transform
|
|
26
|
+
if (!(transform == null ? void 0 : transform.src)) {
|
|
27
27
|
throw new Error("Incorrect transform returned by `parseURL`");
|
|
28
28
|
}
|
|
29
29
|
let inputBuffer = void 0;
|
|
@@ -211,7 +211,6 @@ const codecs = {
|
|
|
211
211
|
avif: {
|
|
212
212
|
name: "AVIF",
|
|
213
213
|
extension: "avif",
|
|
214
|
-
// eslint-disable-next-line no-control-regex
|
|
215
214
|
detectors: [/^\x00\x00\x00 ftypavif\x00\x00\x00\x00/],
|
|
216
215
|
dec: () => instantiateEmscriptenWasm(avifDec, avifDecWasm),
|
|
217
216
|
enc: async () => {
|
|
@@ -241,7 +240,6 @@ const codecs = {
|
|
|
241
240
|
oxipng: {
|
|
242
241
|
name: "OxiPNG",
|
|
243
242
|
extension: "png",
|
|
244
|
-
// eslint-disable-next-line no-control-regex
|
|
245
243
|
detectors: [/^\x89PNG\x0D\x0A\x1A\x0A/],
|
|
246
244
|
dec: async () => {
|
|
247
245
|
await pngEncDecInit();
|
|
@@ -26,7 +26,7 @@ function nextTag(buffer) {
|
|
|
26
26
|
function extractTags(buffer, isBigEndian) {
|
|
27
27
|
const tags = {};
|
|
28
28
|
let temp = buffer;
|
|
29
|
-
while (temp
|
|
29
|
+
while (temp == null ? void 0 : temp.length) {
|
|
30
30
|
const code = readUInt(temp, 16, 0, isBigEndian);
|
|
31
31
|
const type = readUInt(temp, 16, 2, isBigEndian);
|
|
32
32
|
const length = readUInt(temp, 32, 4, isBigEndian);
|
package/dist/cli/index.js
CHANGED
|
@@ -109,7 +109,7 @@ async function runCommand(cmd, flags) {
|
|
|
109
109
|
const { default: add } = await import("../core/add/index.js");
|
|
110
110
|
telemetry.record(event.eventCliSession(cmd));
|
|
111
111
|
const packages = flags._.slice(3);
|
|
112
|
-
return await add(packages, { cwd: root, flags, logging
|
|
112
|
+
return await add(packages, { cwd: root, flags, logging });
|
|
113
113
|
}
|
|
114
114
|
case "docs": {
|
|
115
115
|
telemetry.record(event.eventCliSession(cmd));
|
|
@@ -128,7 +128,7 @@ async function runCommand(cmd, flags) {
|
|
|
128
128
|
case "telemetry": {
|
|
129
129
|
const telemetryHandler = await import("./telemetry.js");
|
|
130
130
|
const subcommand = (_a = flags._[3]) == null ? void 0 : _a.toString();
|
|
131
|
-
return await telemetryHandler.update(subcommand, { flags
|
|
131
|
+
return await telemetryHandler.update(subcommand, { flags });
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
if (!process.env.NODE_ENV) {
|
|
@@ -157,7 +157,6 @@ async function runCommand(cmd, flags) {
|
|
|
157
157
|
configFlagPath,
|
|
158
158
|
flags,
|
|
159
159
|
logging,
|
|
160
|
-
telemetry,
|
|
161
160
|
handleConfigError(e) {
|
|
162
161
|
handleConfigError(e, { cmd, cwd: root, flags, logging });
|
|
163
162
|
info(logging, "astro", "Continuing with previous valid configuration\n");
|
|
@@ -171,7 +170,6 @@ async function runCommand(cmd, flags) {
|
|
|
171
170
|
return await build(settings, {
|
|
172
171
|
flags,
|
|
173
172
|
logging,
|
|
174
|
-
telemetry,
|
|
175
173
|
teardownCompiler: true,
|
|
176
174
|
mode: flags.mode
|
|
177
175
|
});
|
|
@@ -197,7 +195,7 @@ async function runCommand(cmd, flags) {
|
|
|
197
195
|
}
|
|
198
196
|
case "preview": {
|
|
199
197
|
const { default: preview } = await import("../core/preview/index.js");
|
|
200
|
-
const server = await preview(settings, { logging,
|
|
198
|
+
const server = await preview(settings, { logging, flags });
|
|
201
199
|
if (server) {
|
|
202
200
|
return await server.closed();
|
|
203
201
|
}
|
package/dist/cli/telemetry.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { AstroTelemetry } from '@astrojs/telemetry';
|
|
2
1
|
import type yargs from 'yargs-parser';
|
|
3
2
|
export interface TelemetryOptions {
|
|
4
3
|
flags: yargs.Arguments;
|
|
5
|
-
telemetry: AstroTelemetry;
|
|
6
4
|
}
|
|
7
|
-
export declare function update(subcommand: string, { flags
|
|
5
|
+
export declare function update(subcommand: string, { flags }: TelemetryOptions): Promise<void>;
|
package/dist/cli/telemetry.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as msg from "../core/messages.js";
|
|
2
|
-
|
|
2
|
+
import { telemetry } from "../events/index.js";
|
|
3
|
+
async function update(subcommand, { flags }) {
|
|
3
4
|
const isValid = ["enable", "disable", "reset"].includes(subcommand);
|
|
4
5
|
if (flags.help || flags.h || !isValid) {
|
|
5
6
|
msg.printHelp({
|
package/dist/content/utils.d.ts
CHANGED
|
@@ -119,7 +119,7 @@ export declare function getContentEntryIdAndSlug({ entry, contentDir, collection
|
|
|
119
119
|
};
|
|
120
120
|
export declare function getEntryType(entryPath: string, paths: Pick<ContentPaths, 'config' | 'contentDir'>, contentFileExts: string[], dataFileExts: string[], experimentalAssets?: boolean): 'content' | 'data' | 'config' | 'ignored' | 'unsupported';
|
|
121
121
|
export declare function hasUnderscoreBelowContentDirectoryPath(fileUrl: URL, contentDir: ContentPaths['contentDir']): boolean;
|
|
122
|
-
export declare function parseFrontmatter(fileContents: string
|
|
122
|
+
export declare function parseFrontmatter(fileContents: string): matter.GrayMatterFile<string>;
|
|
123
123
|
/**
|
|
124
124
|
* The content config is loaded separately from other `src/` files.
|
|
125
125
|
* This global observable lets dependent plugins (like the content flag plugin)
|
package/dist/content/utils.js
CHANGED
|
@@ -209,7 +209,7 @@ function getYAMLErrorLine(rawData, objectKey) {
|
|
|
209
209
|
const numNewlinesBeforeKey = dataBeforeKey.split("\n").length;
|
|
210
210
|
return numNewlinesBeforeKey;
|
|
211
211
|
}
|
|
212
|
-
function parseFrontmatter(fileContents
|
|
212
|
+
function parseFrontmatter(fileContents) {
|
|
213
213
|
try {
|
|
214
214
|
matter.clearCache();
|
|
215
215
|
return matter(fileContents);
|
package/dist/core/add/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { AstroTelemetry } from '@astrojs/telemetry';
|
|
2
1
|
import type yargs from 'yargs-parser';
|
|
3
2
|
import { type LogOptions } from '../logger/core.js';
|
|
4
3
|
export interface AddOptions {
|
|
5
4
|
logging: LogOptions;
|
|
6
5
|
flags: yargs.Arguments;
|
|
7
|
-
telemetry: AstroTelemetry;
|
|
8
6
|
cwd?: string;
|
|
9
7
|
}
|
|
10
8
|
export interface IntegrationInfo {
|
|
@@ -13,5 +11,5 @@ export interface IntegrationInfo {
|
|
|
13
11
|
dependencies: [name: string, version: string][];
|
|
14
12
|
type: 'integration' | 'adapter';
|
|
15
13
|
}
|
|
16
|
-
export default function add(names: string[], { cwd, flags, logging
|
|
14
|
+
export default function add(names: string[], { cwd, flags, logging }: AddOptions): Promise<void>;
|
|
17
15
|
export declare function validateIntegrations(integrations: string[]): Promise<IntegrationInfo[]>;
|
package/dist/core/add/index.js
CHANGED
|
@@ -56,12 +56,16 @@ const OFFICIAL_ADAPTER_TO_IMPORT_MAP = {
|
|
|
56
56
|
deno: "@astrojs/deno"
|
|
57
57
|
};
|
|
58
58
|
async function getRegistry() {
|
|
59
|
-
var _a;
|
|
59
|
+
var _a, _b;
|
|
60
60
|
const packageManager = ((_a = await preferredPM(process.cwd())) == null ? void 0 : _a.name) || "npm";
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
try {
|
|
62
|
+
const { stdout } = await execa(packageManager, ["config", "get", "registry"]);
|
|
63
|
+
return ((_b = stdout == null ? void 0 : stdout.trim()) == null ? void 0 : _b.replace(/\/$/, "")) || "https://registry.npmjs.org";
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return "https://registry.npmjs.org";
|
|
66
|
+
}
|
|
63
67
|
}
|
|
64
|
-
async function add(names, { cwd, flags, logging
|
|
68
|
+
async function add(names, { cwd, flags, logging }) {
|
|
65
69
|
var _a;
|
|
66
70
|
applyPolyfill();
|
|
67
71
|
if (flags.help || names.length === 0) {
|
package/dist/core/app/node.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare class NodeIncomingMessage extends IncomingMessage {
|
|
|
7
7
|
/**
|
|
8
8
|
* The read-only body property of the Request interface contains a ReadableStream with the body contents that have been added to the request.
|
|
9
9
|
*/
|
|
10
|
-
body?:
|
|
10
|
+
body?: unknown;
|
|
11
11
|
}
|
|
12
12
|
export declare class NodeApp extends App {
|
|
13
13
|
match(req: NodeIncomingMessage | Request, opts?: MatchOptions): RouteData | undefined;
|
|
@@ -222,27 +222,25 @@ async function getPathsForRoute(pageData, mod, opts, builtPaths) {
|
|
|
222
222
|
builtPaths.add(pageData.route.pathname);
|
|
223
223
|
} else {
|
|
224
224
|
const route = pageData.route;
|
|
225
|
-
const
|
|
225
|
+
const staticPaths = await callGetStaticPaths({
|
|
226
226
|
mod,
|
|
227
|
-
route
|
|
227
|
+
route,
|
|
228
|
+
routeCache: opts.routeCache,
|
|
228
229
|
isValidate: false,
|
|
229
230
|
logging: opts.logging,
|
|
230
231
|
ssr: isServerLikeOutput(opts.settings.config)
|
|
231
|
-
}).then((_result) => {
|
|
232
|
-
const label = _result.staticPaths.length === 1 ? "page" : "pages";
|
|
233
|
-
debug(
|
|
234
|
-
"build",
|
|
235
|
-
`\u251C\u2500\u2500 ${colors.bold(colors.green("\u2714"))} ${route.component} \u2192 ${colors.magenta(
|
|
236
|
-
`[${_result.staticPaths.length} ${label}]`
|
|
237
|
-
)}`
|
|
238
|
-
);
|
|
239
|
-
return _result;
|
|
240
232
|
}).catch((err) => {
|
|
241
233
|
debug("build", `\u251C\u2500\u2500 ${colors.bold(colors.red("\u2717"))} ${route.component}`);
|
|
242
234
|
throw err;
|
|
243
235
|
});
|
|
244
|
-
|
|
245
|
-
|
|
236
|
+
const label = staticPaths.length === 1 ? "page" : "pages";
|
|
237
|
+
debug(
|
|
238
|
+
"build",
|
|
239
|
+
`\u251C\u2500\u2500 ${colors.bold(colors.green("\u2714"))} ${route.component} \u2192 ${colors.magenta(
|
|
240
|
+
`[${staticPaths.length} ${label}]`
|
|
241
|
+
)}`
|
|
242
|
+
);
|
|
243
|
+
paths = staticPaths.map((staticPath) => {
|
|
246
244
|
try {
|
|
247
245
|
return route.generate(staticPath.params);
|
|
248
246
|
} catch (e) {
|
|
@@ -330,15 +328,7 @@ function getUrlForPath(pathname, base, origin, format, routeType) {
|
|
|
330
328
|
}
|
|
331
329
|
async function generatePath(pathname, opts, gopts, onRequest) {
|
|
332
330
|
const { settings, logging, origin, routeCache } = opts;
|
|
333
|
-
const {
|
|
334
|
-
mod,
|
|
335
|
-
internals,
|
|
336
|
-
linkIds,
|
|
337
|
-
scripts: hoistedScripts,
|
|
338
|
-
styles: _styles,
|
|
339
|
-
pageData,
|
|
340
|
-
renderers
|
|
341
|
-
} = gopts;
|
|
331
|
+
const { mod, internals, scripts: hoistedScripts, styles: _styles, pageData, renderers } = gopts;
|
|
342
332
|
if (pageData.route.type === "page") {
|
|
343
333
|
addPageName(pathname, opts);
|
|
344
334
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import type { AstroTelemetry } from '@astrojs/telemetry';
|
|
2
1
|
import type { AstroSettings, RuntimeMode } from '../../@types/astro';
|
|
3
2
|
import type yargs from 'yargs-parser';
|
|
4
3
|
import { type LogOptions } from '../logger/core.js';
|
|
5
4
|
export interface BuildOptions {
|
|
6
5
|
mode?: RuntimeMode;
|
|
7
6
|
logging: LogOptions;
|
|
8
|
-
telemetry: AstroTelemetry;
|
|
9
7
|
/**
|
|
10
8
|
* Teardown the compiler WASM instance after build. This can improve performance when
|
|
11
9
|
* building once, but may cause a performance hit if building multiple times in a row.
|
|
@@ -16,11 +16,11 @@ function registerAllPlugins({ internals, options, register }) {
|
|
|
16
16
|
register(pluginAliasResolve(internals));
|
|
17
17
|
register(pluginAnalyzer(internals));
|
|
18
18
|
register(pluginInternals(internals));
|
|
19
|
-
register(pluginRenderers(options
|
|
20
|
-
register(pluginMiddleware(options
|
|
19
|
+
register(pluginRenderers(options));
|
|
20
|
+
register(pluginMiddleware(options));
|
|
21
21
|
register(pluginPages(options, internals));
|
|
22
22
|
register(pluginCSS(options, internals));
|
|
23
|
-
register(astroHeadBuildPlugin(
|
|
23
|
+
register(astroHeadBuildPlugin(internals));
|
|
24
24
|
register(pluginPrerender(options, internals));
|
|
25
25
|
register(astroConfigBuildPlugin(options, internals));
|
|
26
26
|
register(pluginHoistedScripts(options, internals));
|
|
@@ -98,7 +98,7 @@ function vitePluginAnalyzer(internals) {
|
|
|
98
98
|
const ids = this.getModuleIds();
|
|
99
99
|
for (const id of ids) {
|
|
100
100
|
const info = this.getModuleInfo(id);
|
|
101
|
-
if (!
|
|
101
|
+
if (!((_a = info == null ? void 0 : info.meta) == null ? void 0 : _a.astro))
|
|
102
102
|
continue;
|
|
103
103
|
const astro = info.meta.astro;
|
|
104
104
|
const pageData = getPageDataByViteID(internals, id);
|
|
@@ -64,7 +64,7 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
64
64
|
});
|
|
65
65
|
},
|
|
66
66
|
async generateBundle(_outputOptions, bundle) {
|
|
67
|
-
for (const [
|
|
67
|
+
for (const [, chunk] of Object.entries(bundle)) {
|
|
68
68
|
if (chunk.type !== "chunk")
|
|
69
69
|
continue;
|
|
70
70
|
if ("viteMetadata" in chunk === false)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Plugin as VitePlugin } from 'vite';
|
|
2
|
-
import type { BuildInternals } from '../internal.js';
|
|
3
2
|
import type { AstroBuildPlugin } from '../plugin';
|
|
4
3
|
import type { StaticBuildOptions } from '../types';
|
|
5
4
|
export declare const MIDDLEWARE_MODULE_ID = "@astro-middleware";
|
|
6
|
-
export declare function vitePluginMiddleware(opts: StaticBuildOptions
|
|
7
|
-
export declare function pluginMiddleware(opts: StaticBuildOptions
|
|
5
|
+
export declare function vitePluginMiddleware(opts: StaticBuildOptions): VitePlugin;
|
|
6
|
+
export declare function pluginMiddleware(opts: StaticBuildOptions): AstroBuildPlugin;
|
|
@@ -2,7 +2,7 @@ import { MIDDLEWARE_PATH_SEGMENT_NAME } from "../../constants.js";
|
|
|
2
2
|
import { addRollupInput } from "../add-rollup-input.js";
|
|
3
3
|
const MIDDLEWARE_MODULE_ID = "@astro-middleware";
|
|
4
4
|
const EMPTY_MIDDLEWARE = "\0empty-middleware";
|
|
5
|
-
function vitePluginMiddleware(opts
|
|
5
|
+
function vitePluginMiddleware(opts) {
|
|
6
6
|
return {
|
|
7
7
|
name: "@astro/plugin-middleware",
|
|
8
8
|
options(options) {
|
|
@@ -30,13 +30,13 @@ function vitePluginMiddleware(opts, _internals) {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
function pluginMiddleware(opts
|
|
33
|
+
function pluginMiddleware(opts) {
|
|
34
34
|
return {
|
|
35
35
|
build: "ssr",
|
|
36
36
|
hooks: {
|
|
37
37
|
"build:before": () => {
|
|
38
38
|
return {
|
|
39
|
-
vitePlugin: vitePluginMiddleware(opts
|
|
39
|
+
vitePlugin: vitePluginMiddleware(opts)
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { Plugin as VitePlugin } from 'vite';
|
|
2
|
-
import type { BuildInternals } from '../internal.js';
|
|
3
2
|
import type { AstroBuildPlugin } from '../plugin';
|
|
4
3
|
import type { StaticBuildOptions } from '../types';
|
|
5
4
|
export declare const RENDERERS_MODULE_ID = "@astro-renderers";
|
|
6
5
|
export declare const RESOLVED_RENDERERS_MODULE_ID: string;
|
|
7
|
-
export declare function vitePluginRenderers(opts: StaticBuildOptions
|
|
8
|
-
export declare function pluginRenderers(opts: StaticBuildOptions
|
|
6
|
+
export declare function vitePluginRenderers(opts: StaticBuildOptions): VitePlugin;
|
|
7
|
+
export declare function pluginRenderers(opts: StaticBuildOptions): AstroBuildPlugin;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { addRollupInput } from "../add-rollup-input.js";
|
|
2
2
|
const RENDERERS_MODULE_ID = "@astro-renderers";
|
|
3
3
|
const RESOLVED_RENDERERS_MODULE_ID = `\0${RENDERERS_MODULE_ID}`;
|
|
4
|
-
|
|
5
|
-
function vitePluginRenderers(opts, _internals) {
|
|
4
|
+
function vitePluginRenderers(opts) {
|
|
6
5
|
return {
|
|
7
6
|
name: "@astro/plugin-renderers",
|
|
8
7
|
options(options) {
|
|
@@ -34,13 +33,13 @@ ${exports.join("\n")}`;
|
|
|
34
33
|
}
|
|
35
34
|
};
|
|
36
35
|
}
|
|
37
|
-
function pluginRenderers(opts
|
|
36
|
+
function pluginRenderers(opts) {
|
|
38
37
|
return {
|
|
39
38
|
build: "ssr",
|
|
40
39
|
hooks: {
|
|
41
40
|
"build:before": () => {
|
|
42
41
|
return {
|
|
43
|
-
vitePlugin: vitePluginRenderers(opts
|
|
42
|
+
vitePlugin: vitePluginRenderers(opts)
|
|
44
43
|
};
|
|
45
44
|
}
|
|
46
45
|
}
|
|
@@ -31,10 +31,7 @@ function vitePluginSSR(internals, adapter, options) {
|
|
|
31
31
|
},
|
|
32
32
|
async load(id) {
|
|
33
33
|
if (id === RESOLVED_SSR_VIRTUAL_MODULE_ID) {
|
|
34
|
-
const {
|
|
35
|
-
settings: { config },
|
|
36
|
-
allPages
|
|
37
|
-
} = options;
|
|
34
|
+
const { allPages } = options;
|
|
38
35
|
const imports = [];
|
|
39
36
|
const contents = [];
|
|
40
37
|
const exports = [];
|
|
@@ -66,7 +63,7 @@ function vitePluginSSR(internals, adapter, options) {
|
|
|
66
63
|
return void 0;
|
|
67
64
|
},
|
|
68
65
|
async generateBundle(_opts, bundle) {
|
|
69
|
-
for (const [
|
|
66
|
+
for (const [, chunk] of Object.entries(bundle)) {
|
|
70
67
|
if (chunk.type === "asset") {
|
|
71
68
|
internals.staticFiles.add(chunk.fileName);
|
|
72
69
|
}
|
|
@@ -141,10 +138,6 @@ function vitePluginSSRSplit(internals, adapter, options) {
|
|
|
141
138
|
},
|
|
142
139
|
async load(id) {
|
|
143
140
|
if (id.startsWith(RESOLVED_SPLIT_MODULE_ID)) {
|
|
144
|
-
const {
|
|
145
|
-
settings: { config },
|
|
146
|
-
allPages
|
|
147
|
-
} = options;
|
|
148
141
|
const imports = [];
|
|
149
142
|
const contents = [];
|
|
150
143
|
const exports = [];
|
|
@@ -162,7 +155,7 @@ function vitePluginSSRSplit(internals, adapter, options) {
|
|
|
162
155
|
return void 0;
|
|
163
156
|
},
|
|
164
157
|
async generateBundle(_opts, bundle) {
|
|
165
|
-
for (const [
|
|
158
|
+
for (const [, chunk] of Object.entries(bundle)) {
|
|
166
159
|
if (chunk.type === "asset") {
|
|
167
160
|
internals.staticFiles.add(chunk.fileName);
|
|
168
161
|
}
|
|
@@ -215,7 +208,7 @@ function pluginSSRSplit(options, internals) {
|
|
|
215
208
|
logging: options.logging,
|
|
216
209
|
entryPoints: internals.entryPoints
|
|
217
210
|
});
|
|
218
|
-
for (const [
|
|
211
|
+
for (const [, chunk] of internals.ssrSplitEntryChunks) {
|
|
219
212
|
const code = injectManifest(manifest, chunk);
|
|
220
213
|
mutate(chunk, "server", code);
|
|
221
214
|
}
|