astro 6.2.1 → 7.0.0-alpha.0
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/assets/utils/assets.d.ts +4 -5
- package/dist/assets/utils/node.d.ts +2 -2
- package/dist/assets/vite-plugin-assets.js +1 -1
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/content/runtime-assets.d.ts +2 -2
- package/dist/content/utils.d.ts +2 -3
- package/dist/core/build/add-rolldown-input.d.ts +2 -0
- package/dist/core/build/{add-rollup-input.js → add-rolldown-input.js} +3 -3
- package/dist/core/build/graph.d.ts +8 -8
- package/dist/core/build/plugins/plugin-analyzer.js +1 -1
- package/dist/core/build/plugins/plugin-component-entry.d.ts +1 -1
- package/dist/core/build/plugins/plugin-component-entry.js +3 -3
- package/dist/core/build/plugins/plugin-internals.js +1 -1
- package/dist/core/build/plugins/plugin-prerender.js +1 -1
- package/dist/core/build/static-build.d.ts +2 -2
- package/dist/core/build/static-build.js +31 -31
- package/dist/core/build/util.d.ts +2 -2
- package/dist/core/build/util.js +2 -2
- package/dist/core/compile/compile.d.ts +1 -1
- package/dist/core/compile/compile.js +20 -16
- package/dist/core/config/schemas/base.d.ts +4 -6
- package/dist/core/config/schemas/base.js +7 -9
- package/dist/core/config/schemas/relative.d.ts +7 -7
- package/dist/core/config/schemas/relative.js +3 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +2 -0
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/dev/utils.js +1 -1
- package/dist/core/errors/zod-error-map.js +0 -27
- package/dist/core/head-propagation/hint.d.ts +4 -0
- package/dist/core/head-propagation/hint.js +7 -0
- package/dist/core/messages/runtime.js +1 -1
- package/dist/core/middleware/vite-plugin.js +2 -2
- package/dist/toolbar/vite-plugin-dev-toolbar.js +1 -23
- package/dist/types/public/config.d.ts +0 -1
- package/dist/types/public/content.d.ts +3 -3
- package/dist/types/public/integrations.d.ts +2 -2
- package/dist/vite-plugin-adapter-config/index.js +1 -1
- package/dist/vite-plugin-astro/compile.d.ts +3 -5
- package/dist/vite-plugin-astro/compile.js +4 -60
- package/dist/vite-plugin-astro/index.js +15 -28
- package/dist/vite-plugin-astro/types.d.ts +2 -1
- package/dist/vite-plugin-head/index.js +9 -3
- package/dist/vite-plugin-pages/util.d.ts +1 -1
- package/package.json +3 -5
- package/templates/content/module.mjs +1 -1
- package/dist/core/build/add-rollup-input.d.ts +0 -2
- package/dist/core/compile/compile-rs.d.ts +0 -25
- package/dist/core/compile/compile-rs.js +0 -111
- package/dist/core/head-propagation/comment.d.ts +0 -7
- package/dist/core/head-propagation/comment.js +0 -7
- package/dist/vite-plugin-astro/compile-rs.d.ts +0 -12
- package/dist/vite-plugin-astro/compile-rs.js +0 -39
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { Environment,
|
|
2
|
-
type
|
|
3
|
-
type EmitFileOptions = Parameters<Rollup.PluginContext['emitFile']>[0];
|
|
1
|
+
import type { Environment, Rolldown } from 'vite';
|
|
2
|
+
type EmitFileOptions = Parameters<Rolldown.PluginContext['emitFile']>[0];
|
|
4
3
|
/**
|
|
5
4
|
* Gets or creates the handle set for an environment
|
|
6
5
|
*/
|
|
@@ -15,9 +14,9 @@ export declare function resetHandles(env: Environment): void;
|
|
|
15
14
|
* Use this instead of pluginContext.emitFile for assets that should
|
|
16
15
|
* be moved from the server/prerender directory to the client directory.
|
|
17
16
|
*
|
|
18
|
-
* Note: The pluginContext is typed as
|
|
17
|
+
* Note: The pluginContext is typed as Rolldown.PluginContext for compatibility
|
|
19
18
|
* with content entry types, but in practice it will always have the `environment`
|
|
20
19
|
* property when running in Vite.
|
|
21
20
|
*/
|
|
22
|
-
export declare function emitClientAsset(pluginContext: PluginContext, options: EmitFileOptions): string;
|
|
21
|
+
export declare function emitClientAsset(pluginContext: Rolldown.PluginContext, options: EmitFileOptions): string;
|
|
23
22
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Rolldown } from 'vite';
|
|
2
2
|
import type { ImageMetadata } from '../types.js';
|
|
3
3
|
export { hashTransform, propsToFilename } from './hash.js';
|
|
4
|
-
type FileEmitter =
|
|
4
|
+
type FileEmitter = (opts: Parameters<Rolldown.PluginContext['emitFile']>[0]) => string;
|
|
5
5
|
type ImageMetadataWithContents = ImageMetadata & {
|
|
6
6
|
contents?: Buffer;
|
|
7
7
|
};
|
|
@@ -278,7 +278,7 @@ function assets({ fs, settings, sync, logger }) {
|
|
|
278
278
|
});
|
|
279
279
|
}
|
|
280
280
|
if (isAstroServerEnvironment(this.environment)) {
|
|
281
|
-
if (id.endsWith(".svg")
|
|
281
|
+
if (id.endsWith(".svg")) {
|
|
282
282
|
const contents = await fs.promises.readFile(imageMetadata.fsPath, {
|
|
283
283
|
encoding: "utf8"
|
|
284
284
|
});
|
|
@@ -192,7 +192,7 @@ ${contentConfig.error.message}`
|
|
|
192
192
|
logger.info("Content config changed");
|
|
193
193
|
shouldClear = true;
|
|
194
194
|
}
|
|
195
|
-
if (previousAstroVersion && previousAstroVersion !== "
|
|
195
|
+
if (previousAstroVersion && previousAstroVersion !== "7.0.0-alpha.0") {
|
|
196
196
|
logger.info("Astro version changed");
|
|
197
197
|
shouldClear = true;
|
|
198
198
|
}
|
|
@@ -200,8 +200,8 @@ ${contentConfig.error.message}`
|
|
|
200
200
|
logger.info("Clearing content store");
|
|
201
201
|
this.#store.clearAll();
|
|
202
202
|
}
|
|
203
|
-
if ("
|
|
204
|
-
this.#store.metaStore().set("astro-version", "
|
|
203
|
+
if ("7.0.0-alpha.0") {
|
|
204
|
+
this.#store.metaStore().set("astro-version", "7.0.0-alpha.0");
|
|
205
205
|
}
|
|
206
206
|
if (currentConfigDigest) {
|
|
207
207
|
this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Rolldown } from 'vite';
|
|
2
2
|
import * as z from 'zod/v4';
|
|
3
|
-
export declare function createImage(pluginContext: PluginContext, shouldEmitFile: boolean, entryFilePath: string): () => z.ZodPipe<z.ZodString, z.ZodTransform<z.ZodNever | {
|
|
3
|
+
export declare function createImage(pluginContext: Rolldown.PluginContext, shouldEmitFile: boolean, entryFilePath: string): () => z.ZodPipe<z.ZodString, z.ZodTransform<z.ZodNever | {
|
|
4
4
|
ASTRO_ASSET: string;
|
|
5
5
|
format: import("../assets/types.js").ImageInputFormat;
|
|
6
6
|
src: string;
|
package/dist/content/utils.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fsMod from 'node:fs';
|
|
2
|
-
import type {
|
|
3
|
-
import type { RunnableDevEnvironment } from 'vite';
|
|
2
|
+
import type { RunnableDevEnvironment, Rolldown } from 'vite';
|
|
4
3
|
import * as z from 'zod/v4';
|
|
5
4
|
import type { AstroLogger } from '../core/logger/core.js';
|
|
6
5
|
import type { AstroSettings } from '../types/astro.js';
|
|
@@ -96,7 +95,7 @@ export declare function getEntryData<TInputData extends Record<string, unknown>
|
|
|
96
95
|
collection: string;
|
|
97
96
|
unvalidatedData: TInputData;
|
|
98
97
|
_internal: EntryInternal;
|
|
99
|
-
}, collectionConfig: CollectionConfig, shouldEmitFile: boolean, pluginContext?: PluginContext): Promise<TOutputData>;
|
|
98
|
+
}, collectionConfig: CollectionConfig, shouldEmitFile: boolean, pluginContext?: Rolldown.PluginContext): Promise<TOutputData>;
|
|
100
99
|
export declare function getContentEntryExts(settings: Pick<AstroSettings, 'contentEntryTypes'>): string[];
|
|
101
100
|
export declare function getDataEntryExts(settings: Pick<AstroSettings, 'dataEntryTypes'>): string[];
|
|
102
101
|
export declare function getEntryConfigByExtMap<TEntryType extends ContentEntryType | DataEntryType>(entryTypes: TEntryType[]): Map<string, TEntryType>;
|
|
@@ -5,7 +5,7 @@ function fromEntries(entries) {
|
|
|
5
5
|
}
|
|
6
6
|
return obj;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function addRolldownInput(inputOptions, newInputs) {
|
|
9
9
|
if (!inputOptions.input) {
|
|
10
10
|
return { ...inputOptions, input: newInputs };
|
|
11
11
|
}
|
|
@@ -30,8 +30,8 @@ function addRollupInput(inputOptions, newInputs) {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
throw new Error(`Unknown
|
|
33
|
+
throw new Error(`Unknown rolldown input type. Supported inputs are string, array and object.`);
|
|
34
34
|
}
|
|
35
35
|
export {
|
|
36
|
-
|
|
36
|
+
addRolldownInput
|
|
37
37
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Rolldown } from 'vite';
|
|
2
2
|
interface ExtendedModuleInfo {
|
|
3
|
-
info: ModuleInfo;
|
|
3
|
+
info: Rolldown.ModuleInfo;
|
|
4
4
|
depth: number;
|
|
5
5
|
order: number;
|
|
6
6
|
}
|
|
7
7
|
export declare function getParentExtendedModuleInfos(id: string, ctx: {
|
|
8
|
-
getModuleInfo: GetModuleInfo;
|
|
8
|
+
getModuleInfo: Rolldown.GetModuleInfo;
|
|
9
9
|
}, until?: (importer: string) => boolean, depth?: number, order?: number, childId?: string, seen?: Set<string>, accumulated?: ExtendedModuleInfo[]): ExtendedModuleInfo[];
|
|
10
10
|
export declare function getParentModuleInfos(id: string, ctx: {
|
|
11
|
-
getModuleInfo: GetModuleInfo;
|
|
12
|
-
}, until?: (importer: string) => boolean, seen?: Set<string>, accumulated?: ModuleInfo[]): ModuleInfo[];
|
|
13
|
-
export declare function moduleIsTopLevelPage(info: ModuleInfo): boolean;
|
|
11
|
+
getModuleInfo: Rolldown.GetModuleInfo;
|
|
12
|
+
}, until?: (importer: string) => boolean, seen?: Set<string>, accumulated?: Rolldown.ModuleInfo[]): Rolldown.ModuleInfo[];
|
|
13
|
+
export declare function moduleIsTopLevelPage(info: Rolldown.ModuleInfo): boolean;
|
|
14
14
|
export declare function getTopLevelPageModuleInfos(id: string, ctx: {
|
|
15
|
-
getModuleInfo: GetModuleInfo;
|
|
16
|
-
}): ModuleInfo[];
|
|
15
|
+
getModuleInfo: Rolldown.GetModuleInfo;
|
|
16
|
+
}): Rolldown.ModuleInfo[];
|
|
17
17
|
export {};
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import { ASTRO_VITE_ENVIRONMENT_NAMES } from "../../constants.js";
|
|
9
9
|
function pluginAnalyzer(internals) {
|
|
10
10
|
return {
|
|
11
|
-
name: "@astro/
|
|
11
|
+
name: "@astro/rolldown-plugin-astro-analyzer",
|
|
12
12
|
applyToEnvironment(environment) {
|
|
13
13
|
return environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr || environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.prerender;
|
|
14
14
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Plugin as VitePlugin } from 'vite';
|
|
2
2
|
import type { BuildInternals } from '../internal.js';
|
|
3
3
|
/**
|
|
4
|
-
* When adding hydrated or client:only components as
|
|
4
|
+
* When adding hydrated or client:only components as Rolldown inputs, sometimes we're not using all
|
|
5
5
|
* of the export names, e.g. `import { Counter } from './ManyComponents.jsx'`. This plugin proxies
|
|
6
6
|
* entries to re-export only the names that the user is using.
|
|
7
7
|
*/
|
|
@@ -27,9 +27,9 @@ function pluginComponentEntry(internals) {
|
|
|
27
27
|
return environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.client;
|
|
28
28
|
},
|
|
29
29
|
config(config) {
|
|
30
|
-
const
|
|
31
|
-
if (Array.isArray(
|
|
32
|
-
config.build.
|
|
30
|
+
const rolldownInput = config.build?.rolldownOptions?.input;
|
|
31
|
+
if (Array.isArray(rolldownInput)) {
|
|
32
|
+
config.build.rolldownOptions.input = rolldownInput.map((id) => {
|
|
33
33
|
if (componentToExportNames.has(id)) {
|
|
34
34
|
return astroEntryPrefix + id;
|
|
35
35
|
} else {
|
|
@@ -21,7 +21,7 @@ function pluginInternals(options, internals) {
|
|
|
21
21
|
if (environmentName === ASTRO_VITE_ENVIRONMENT_NAMES.prerender) {
|
|
22
22
|
return {
|
|
23
23
|
build: {
|
|
24
|
-
|
|
24
|
+
rolldownOptions: {
|
|
25
25
|
// These packages as they're not bundle-friendly. Users with strict package installations
|
|
26
26
|
// need to manually install these themselves if they use the related features.
|
|
27
27
|
external: [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ASTRO_VITE_ENVIRONMENT_NAMES } from "../../constants.js";
|
|
2
2
|
function pluginPrerender(_opts, internals) {
|
|
3
3
|
return {
|
|
4
|
-
name: "astro:
|
|
4
|
+
name: "astro:rolldown-plugin-prerender",
|
|
5
5
|
applyToEnvironment(environment) {
|
|
6
6
|
return environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr;
|
|
7
7
|
},
|
|
@@ -2,8 +2,8 @@ import { type BuildInternals } from '../../core/build/internal.js';
|
|
|
2
2
|
import type { RouteData } from '../../types/public/internal.js';
|
|
3
3
|
import type { StaticBuildOptions } from './types.js';
|
|
4
4
|
/**
|
|
5
|
-
* Minimal chunk data extracted from
|
|
6
|
-
* Allows releasing full
|
|
5
|
+
* Minimal chunk data extracted from RolldownOutput for deferred manifest/content injection.
|
|
6
|
+
* Allows releasing full RolldownOutput objects early to reduce memory usage.
|
|
7
7
|
*/
|
|
8
8
|
export interface ExtractedChunk {
|
|
9
9
|
fileName: string;
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
RESOLVED_LEGACY_SSR_ENTRY_VIRTUAL_MODULE
|
|
31
31
|
} from "./plugins/plugin-ssr.js";
|
|
32
32
|
import { ASTRO_PAGE_EXTENSION_POST_PATTERN } from "./plugins/util.js";
|
|
33
|
-
import { cleanChunkName, getTimeStat,
|
|
33
|
+
import { cleanChunkName, getTimeStat, viteBuildReturnToRolldownOutputs } from "./util.js";
|
|
34
34
|
import { NOOP_MODULE_ID } from "./plugins/plugin-noop.js";
|
|
35
35
|
import { ASTRO_VITE_ENVIRONMENT_NAMES } from "../constants.js";
|
|
36
36
|
import { getSSRAssets } from "./internal.js";
|
|
@@ -87,25 +87,25 @@ async function buildEnvironments(opts, internals) {
|
|
|
87
87
|
const buildPlugins = getAllBuildPlugins(internals, opts);
|
|
88
88
|
const flatPlugins = buildPlugins.flat().filter(Boolean);
|
|
89
89
|
const plugins = [...flatPlugins, ...viteConfig.plugins || []];
|
|
90
|
-
let
|
|
90
|
+
let currentRolldownInput = void 0;
|
|
91
91
|
let buildPostHooks = [];
|
|
92
92
|
plugins.push({
|
|
93
93
|
name: "astro:resolve-input",
|
|
94
|
-
// When the
|
|
94
|
+
// When the rolldown input is safe to update, we normalize it to always be an object
|
|
95
95
|
// so we can reliably identify which entrypoint corresponds to the adapter
|
|
96
96
|
enforce: "post",
|
|
97
97
|
config(config) {
|
|
98
|
-
if (typeof config.build?.
|
|
99
|
-
config.build.
|
|
100
|
-
} else if (Array.isArray(config.build?.
|
|
101
|
-
config.build.
|
|
102
|
-
config.build.
|
|
98
|
+
if (typeof config.build?.rolldownOptions?.input === "string") {
|
|
99
|
+
config.build.rolldownOptions.input = { index: config.build.rolldownOptions.input };
|
|
100
|
+
} else if (Array.isArray(config.build?.rolldownOptions?.input)) {
|
|
101
|
+
config.build.rolldownOptions.input = Object.fromEntries(
|
|
102
|
+
config.build.rolldownOptions.input.map((v, i) => [`index_${i}`, v])
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
|
-
// We save the
|
|
106
|
+
// We save the rolldown input to be able to check later on
|
|
107
107
|
configResolved(config) {
|
|
108
|
-
|
|
108
|
+
currentRolldownInput = config.build.rolldownOptions.input;
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
111
|
plugins.push({
|
|
@@ -137,16 +137,16 @@ async function buildEnvironments(opts, internals) {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
});
|
|
140
|
-
function
|
|
141
|
-
if (!
|
|
140
|
+
function isRolldownInput(moduleName) {
|
|
141
|
+
if (!currentRolldownInput || !moduleName) {
|
|
142
142
|
return false;
|
|
143
143
|
}
|
|
144
|
-
if (typeof
|
|
145
|
-
return
|
|
146
|
-
} else if (Array.isArray(
|
|
147
|
-
return
|
|
144
|
+
if (typeof currentRolldownInput === "string") {
|
|
145
|
+
return currentRolldownInput === moduleName;
|
|
146
|
+
} else if (Array.isArray(currentRolldownInput)) {
|
|
147
|
+
return currentRolldownInput.includes(moduleName);
|
|
148
148
|
} else {
|
|
149
|
-
return Object.keys(
|
|
149
|
+
return Object.keys(currentRolldownInput).includes(moduleName);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
const viteBuildConfig = {
|
|
@@ -161,8 +161,8 @@ async function buildEnvironments(opts, internals) {
|
|
|
161
161
|
emptyOutDir: false,
|
|
162
162
|
copyPublicDir: false,
|
|
163
163
|
manifest: false,
|
|
164
|
-
|
|
165
|
-
...viteConfig.build?.
|
|
164
|
+
rolldownOptions: {
|
|
165
|
+
...viteConfig.build?.rolldownOptions,
|
|
166
166
|
// Setting as `exports-only` allows us to safely delete inputs that are only used during prerendering
|
|
167
167
|
preserveEntrySignatures: "exports-only",
|
|
168
168
|
...legacyAdapter && settings.buildOutput === "server" ? { input: LEGACY_SSR_ENTRY_VIRTUAL_MODULE } : {},
|
|
@@ -187,7 +187,7 @@ async function buildEnvironments(opts, internals) {
|
|
|
187
187
|
return [prefix, cleanChunkName(name), suffix].join("");
|
|
188
188
|
},
|
|
189
189
|
assetFileNames: `${settings.config.build.assets}/[name].[hash][extname]`,
|
|
190
|
-
...viteConfig.build?.
|
|
190
|
+
...viteConfig.build?.rolldownOptions?.output,
|
|
191
191
|
entryFileNames(chunkInfo) {
|
|
192
192
|
if (chunkInfo.facadeModuleId?.startsWith(VIRTUAL_PAGE_RESOLVED_MODULE_ID)) {
|
|
193
193
|
return makeAstroPageEntryPointFileName(
|
|
@@ -196,8 +196,8 @@ async function buildEnvironments(opts, internals) {
|
|
|
196
196
|
routes
|
|
197
197
|
);
|
|
198
198
|
} else if (chunkInfo.facadeModuleId === RESOLVED_LEGACY_SSR_ENTRY_VIRTUAL_MODULE || // This catches the case when the adapter uses `entrypointResolution: 'auto'`. When doing so,
|
|
199
|
-
// the adapter must set
|
|
200
|
-
|
|
199
|
+
// the adapter must set rolldownOptions.input or Astro sets it from `serverEntrypoint`.
|
|
200
|
+
isRolldownInput(chunkInfo.name) || isRolldownInput(chunkInfo.facadeModuleId)) {
|
|
201
201
|
return opts.settings.config.build.serverEntry;
|
|
202
202
|
} else {
|
|
203
203
|
return "[name].mjs";
|
|
@@ -221,7 +221,7 @@ async function buildEnvironments(opts, internals) {
|
|
|
221
221
|
let prerenderOutput = await builder2.build(builder2.environments.prerender);
|
|
222
222
|
settings.timer.end("Prerender build");
|
|
223
223
|
extractPrerenderEntryFileName(internals, prerenderOutput);
|
|
224
|
-
const prerenderOutputs =
|
|
224
|
+
const prerenderOutputs = viteBuildReturnToRolldownOutputs(prerenderOutput);
|
|
225
225
|
const prerenderChunks = extractRelevantChunks(prerenderOutputs, true);
|
|
226
226
|
prerenderOutput = void 0;
|
|
227
227
|
let ssrChunks = [];
|
|
@@ -231,7 +231,7 @@ async function buildEnvironments(opts, internals) {
|
|
|
231
231
|
builder2.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr]
|
|
232
232
|
);
|
|
233
233
|
settings.timer.end("SSR build");
|
|
234
|
-
const ssrOutputs =
|
|
234
|
+
const ssrOutputs = viteBuildReturnToRolldownOutputs(ssrOutput);
|
|
235
235
|
ssrChunks = extractRelevantChunks(ssrOutputs, false);
|
|
236
236
|
ssrOutput = void 0;
|
|
237
237
|
}
|
|
@@ -259,14 +259,14 @@ async function buildEnvironments(opts, internals) {
|
|
|
259
259
|
build: {
|
|
260
260
|
emitAssets: true,
|
|
261
261
|
outDir: fileURLToPath(getPrerenderOutputDirectory(settings)),
|
|
262
|
-
|
|
262
|
+
rolldownOptions: {
|
|
263
263
|
// Only skip the default prerender entrypoint if an adapter with `entrypointResolution: 'self'` is used
|
|
264
264
|
// AND provides a custom prerenderer. Otherwise, use the default.
|
|
265
265
|
...!legacyAdapter && settings.prerenderer ? {} : { input: "astro/entrypoints/prerender" },
|
|
266
266
|
output: {
|
|
267
267
|
entryFileNames: `${PRERENDER_ENTRY_FILENAME_PREFIX}.[hash].mjs`,
|
|
268
268
|
format: "esm",
|
|
269
|
-
...viteConfig.environments?.prerender?.build?.
|
|
269
|
+
...viteConfig.environments?.prerender?.build?.rolldownOptions?.output
|
|
270
270
|
}
|
|
271
271
|
},
|
|
272
272
|
ssr: true
|
|
@@ -280,7 +280,7 @@ async function buildEnvironments(opts, internals) {
|
|
|
280
280
|
copyPublicDir: true,
|
|
281
281
|
sourcemap: viteConfig.environments?.client?.build?.sourcemap ?? false,
|
|
282
282
|
minify: true,
|
|
283
|
-
|
|
283
|
+
rolldownOptions: {
|
|
284
284
|
preserveEntrySignatures: "exports-only",
|
|
285
285
|
output: {
|
|
286
286
|
entryFileNames(chunkInfo) {
|
|
@@ -290,7 +290,7 @@ async function buildEnvironments(opts, internals) {
|
|
|
290
290
|
return `${settings.config.build.assets}/${cleanChunkName(chunkInfo.name)}.[hash].js`;
|
|
291
291
|
},
|
|
292
292
|
assetFileNames: `${settings.config.build.assets}/[name].[hash][extname]`,
|
|
293
|
-
...viteConfig.environments?.client?.build?.
|
|
293
|
+
...viteConfig.environments?.client?.build?.rolldownOptions?.output
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
}
|
|
@@ -298,9 +298,9 @@ async function buildEnvironments(opts, internals) {
|
|
|
298
298
|
[ASTRO_VITE_ENVIRONMENT_NAMES.ssr]: {
|
|
299
299
|
build: {
|
|
300
300
|
outDir: fileURLToPath(getServerOutputDirectory(settings)),
|
|
301
|
-
|
|
301
|
+
rolldownOptions: {
|
|
302
302
|
output: {
|
|
303
|
-
...viteConfig.environments?.ssr?.build?.
|
|
303
|
+
...viteConfig.environments?.ssr?.build?.rolldownOptions?.output
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
}
|
|
@@ -318,7 +318,7 @@ async function buildEnvironments(opts, internals) {
|
|
|
318
318
|
await builder.buildApp();
|
|
319
319
|
}
|
|
320
320
|
function getPrerenderEntryFileName(prerenderOutput) {
|
|
321
|
-
const outputs =
|
|
321
|
+
const outputs = viteBuildReturnToRolldownOutputs(prerenderOutput);
|
|
322
322
|
for (const output of outputs) {
|
|
323
323
|
for (const chunk of output.output) {
|
|
324
324
|
if (chunk.type !== "asset" && "fileName" in chunk) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Rolldown } from 'vite';
|
|
2
2
|
import type { AstroConfig } from '../../types/public/config.js';
|
|
3
3
|
import type { ViteBuildReturn } from './types.js';
|
|
4
4
|
export declare function getTimeStat(timeStart: number, timeEnd: number): string;
|
|
@@ -12,4 +12,4 @@ export declare function shouldAppendForwardSlash(trailingSlash: AstroConfig['tra
|
|
|
12
12
|
* and break deploys on platforms like Netlify.
|
|
13
13
|
*/
|
|
14
14
|
export declare function cleanChunkName(name: string): string;
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function viteBuildReturnToRolldownOutputs(viteBuildReturn: ViteBuildReturn): Rolldown.RolldownOutput[];
|
package/dist/core/build/util.js
CHANGED
|
@@ -34,7 +34,7 @@ function encodeName(name) {
|
|
|
34
34
|
}
|
|
35
35
|
return name;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function viteBuildReturnToRolldownOutputs(viteBuildReturn) {
|
|
38
38
|
const result = [];
|
|
39
39
|
if (Array.isArray(viteBuildReturn)) {
|
|
40
40
|
result.push(...viteBuildReturn);
|
|
@@ -47,5 +47,5 @@ export {
|
|
|
47
47
|
cleanChunkName,
|
|
48
48
|
getTimeStat,
|
|
49
49
|
shouldAppendForwardSlash,
|
|
50
|
-
|
|
50
|
+
viteBuildReturnToRolldownOutputs
|
|
51
51
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type TransformResult } from '@astrojs/compiler-rs';
|
|
2
2
|
import type { ResolvedConfig } from 'vite';
|
|
3
3
|
import type { AstroConfig } from '../../types/public/config.js';
|
|
4
4
|
import type { CompileCssResult } from './types.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
|
-
import { transform } from "@astrojs/compiler";
|
|
2
|
+
import { preprocessStyles, transform } from "@astrojs/compiler-rs";
|
|
3
3
|
import { AggregateError, CompilerError } from "../errors/errors.js";
|
|
4
4
|
import { AstroErrorData } from "../errors/index.js";
|
|
5
5
|
import { normalizePath, resolvePath } from "../viteUtils.js";
|
|
@@ -15,7 +15,17 @@ async function compile({
|
|
|
15
15
|
const cssTransformErrors = [];
|
|
16
16
|
let transformResult;
|
|
17
17
|
try {
|
|
18
|
-
|
|
18
|
+
const preprocessedStyles = await preprocessStyles(
|
|
19
|
+
source,
|
|
20
|
+
createStylePreprocessor({
|
|
21
|
+
filename,
|
|
22
|
+
viteConfig,
|
|
23
|
+
astroConfig,
|
|
24
|
+
cssPartialCompileResults,
|
|
25
|
+
cssTransformErrors
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
transformResult = transform(source, {
|
|
19
29
|
compact: astroConfig.compressHTML,
|
|
20
30
|
filename,
|
|
21
31
|
normalizedFilename: normalizeFilename(filename, astroConfig.root),
|
|
@@ -27,14 +37,8 @@ async function compile({
|
|
|
27
37
|
resultScopedSlot: true,
|
|
28
38
|
transitionsAnimationURL: "astro/components/viewtransitions.css",
|
|
29
39
|
annotateSourceFile: viteConfig.command === "serve" && astroConfig.devToolbar && astroConfig.devToolbar.enabled && toolbarEnabled,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
viteConfig,
|
|
33
|
-
astroConfig,
|
|
34
|
-
cssPartialCompileResults,
|
|
35
|
-
cssTransformErrors
|
|
36
|
-
}),
|
|
37
|
-
async resolvePath(specifier) {
|
|
40
|
+
preprocessedStyles,
|
|
41
|
+
resolvePath(specifier) {
|
|
38
42
|
return resolvePath(specifier, filename);
|
|
39
43
|
}
|
|
40
44
|
});
|
|
@@ -48,7 +52,7 @@ async function compile({
|
|
|
48
52
|
}
|
|
49
53
|
});
|
|
50
54
|
}
|
|
51
|
-
handleCompileResultErrors(transformResult, cssTransformErrors);
|
|
55
|
+
handleCompileResultErrors(filename, transformResult, cssTransformErrors);
|
|
52
56
|
return {
|
|
53
57
|
...transformResult,
|
|
54
58
|
css: transformResult.css.map((code, i) => ({
|
|
@@ -57,16 +61,16 @@ async function compile({
|
|
|
57
61
|
}))
|
|
58
62
|
};
|
|
59
63
|
}
|
|
60
|
-
function handleCompileResultErrors(result, cssTransformErrors) {
|
|
61
|
-
const compilerError = result.diagnostics.find((diag) => diag.severity ===
|
|
64
|
+
function handleCompileResultErrors(filename, result, cssTransformErrors) {
|
|
65
|
+
const compilerError = result.diagnostics.find((diag) => diag.severity === "error");
|
|
62
66
|
if (compilerError) {
|
|
63
67
|
throw new CompilerError({
|
|
64
68
|
name: "CompilerError",
|
|
65
69
|
message: compilerError.text,
|
|
66
70
|
location: {
|
|
67
|
-
line: compilerError.
|
|
68
|
-
column: compilerError.
|
|
69
|
-
file:
|
|
71
|
+
line: compilerError.labels[0].line,
|
|
72
|
+
column: compilerError.labels[0].column,
|
|
73
|
+
file: filename
|
|
70
74
|
},
|
|
71
75
|
hint: compilerError.hint
|
|
72
76
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RehypePlugin as _RehypePlugin, RemarkPlugin as _RemarkPlugin, RemarkRehype as _RemarkRehype, Smartypants as _Smartypants, ShikiConfig } from '@astrojs/markdown-remark';
|
|
2
1
|
import type { OutgoingHttpHeaders } from 'node:http';
|
|
2
|
+
import type { RehypePlugin as _RehypePlugin, RemarkPlugin as _RemarkPlugin, RemarkRehype as _RemarkRehype, ShikiConfig, Smartypants as _Smartypants } from '@astrojs/markdown-remark';
|
|
3
3
|
import * as z from 'zod/v4';
|
|
4
4
|
import type { ViteUserConfig } from '../../../types/public/config.js';
|
|
5
5
|
/** @lintignore */
|
|
@@ -78,7 +78,6 @@ export declare const ASTRO_CONFIG_DEFAULTS: {
|
|
|
78
78
|
clientPrerender: false;
|
|
79
79
|
contentIntellisense: false;
|
|
80
80
|
chromeDevtoolsWorkspace: false;
|
|
81
|
-
rustCompiler: false;
|
|
82
81
|
queuedRendering: {
|
|
83
82
|
enabled: false;
|
|
84
83
|
};
|
|
@@ -103,10 +102,10 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
103
102
|
name: z.ZodString;
|
|
104
103
|
hooks: z.ZodDefault<z.ZodObject<{}, z.core.$loose>>;
|
|
105
104
|
}, z.core.$strip>>;
|
|
106
|
-
integrations: z.
|
|
105
|
+
integrations: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
107
106
|
name: z.ZodString;
|
|
108
107
|
hooks: z.ZodDefault<z.ZodObject<{}, z.core.$loose>>;
|
|
109
|
-
}, z.core.$strip
|
|
108
|
+
}, z.core.$strip>>>>;
|
|
110
109
|
build: z.ZodPrefault<z.ZodObject<{
|
|
111
110
|
format: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"file">, z.ZodLiteral<"directory">, z.ZodLiteral<"preserve">]>>>;
|
|
112
111
|
client: z.ZodPipe<z.ZodDefault<z.ZodOptional<z.ZodString>>, z.ZodTransform<URL, string>>;
|
|
@@ -124,7 +123,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
124
123
|
}>>>;
|
|
125
124
|
concurrency: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
126
125
|
}, z.core.$strip>>;
|
|
127
|
-
server: z.
|
|
126
|
+
server: z.ZodPipe<z.ZodTransform<any, unknown>, z.ZodPrefault<z.ZodObject<{
|
|
128
127
|
open: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>>;
|
|
129
128
|
host: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>>;
|
|
130
129
|
port: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
@@ -517,7 +516,6 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
517
516
|
swr: z.ZodOptional<z.ZodNumber>;
|
|
518
517
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
519
518
|
}, z.core.$strip>>>;
|
|
520
|
-
rustCompiler: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
521
519
|
queuedRendering: z.ZodPrefault<z.ZodOptional<z.ZodObject<{
|
|
522
520
|
enabled: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
|
|
523
521
|
poolSize: z.ZodOptional<z.ZodNumber>;
|
|
@@ -2,11 +2,11 @@ import { markdownConfigDefaults, syntaxHighlightDefaults } from "@astrojs/markdo
|
|
|
2
2
|
import { bundledThemes } from "shiki";
|
|
3
3
|
import * as z from "zod/v4";
|
|
4
4
|
import { FontFamilySchema } from "../../../assets/fonts/config.js";
|
|
5
|
-
import { SvgOptimizerSchema } from "../../../assets/svg/config.js";
|
|
6
5
|
import { EnvSchema } from "../../../env/schema.js";
|
|
7
|
-
import { CacheSchema, RouteRulesSchema } from "../../cache/config.js";
|
|
8
6
|
import { allowedDirectivesSchema, cspAlgorithmSchema, cspHashSchema } from "../../csp/config.js";
|
|
7
|
+
import { CacheSchema, RouteRulesSchema } from "../../cache/config.js";
|
|
9
8
|
import { SessionSchema } from "../../session/config.js";
|
|
9
|
+
import { SvgOptimizerSchema } from "../../../assets/svg/config.js";
|
|
10
10
|
const ASTRO_CONFIG_DEFAULTS = {
|
|
11
11
|
root: ".",
|
|
12
12
|
srcDir: "./src",
|
|
@@ -63,7 +63,6 @@ const ASTRO_CONFIG_DEFAULTS = {
|
|
|
63
63
|
clientPrerender: false,
|
|
64
64
|
contentIntellisense: false,
|
|
65
65
|
chromeDevtoolsWorkspace: false,
|
|
66
|
-
rustCompiler: false,
|
|
67
66
|
queuedRendering: {
|
|
68
67
|
enabled: false
|
|
69
68
|
},
|
|
@@ -105,13 +104,13 @@ const AstroConfigSchema = z.object({
|
|
|
105
104
|
message: 'The `output: "hybrid"` option has been removed. Use `output: "static"` (the default) instead, which now behaves the same way.'
|
|
106
105
|
}),
|
|
107
106
|
scopedStyleStrategy: z.union([z.literal("where"), z.literal("class"), z.literal("attribute")]).optional().default("attribute"),
|
|
108
|
-
adapter: z.object({ name: z.string(), hooks: z.object({}).
|
|
107
|
+
adapter: z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) }).optional(),
|
|
109
108
|
integrations: z.preprocess(
|
|
110
109
|
// preprocess
|
|
111
110
|
(val) => Array.isArray(val) ? val.flat(Number.POSITIVE_INFINITY).filter(Boolean) : val,
|
|
112
111
|
// validate
|
|
113
|
-
z.array(z.object({ name: z.string(), hooks: z.object({}).
|
|
114
|
-
)
|
|
112
|
+
z.array(z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) })).default(ASTRO_CONFIG_DEFAULTS.integrations)
|
|
113
|
+
),
|
|
115
114
|
build: z.object({
|
|
116
115
|
format: z.union([z.literal("file"), z.literal("directory"), z.literal("preserve")]).optional().default(ASTRO_CONFIG_DEFAULTS.build.format),
|
|
117
116
|
client: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.client).transform((val) => new URL(val)),
|
|
@@ -135,8 +134,8 @@ const AstroConfigSchema = z.object({
|
|
|
135
134
|
port: z.number().optional().default(ASTRO_CONFIG_DEFAULTS.server.port),
|
|
136
135
|
headers: z.custom().optional(),
|
|
137
136
|
allowedHosts: z.union([z.array(z.string()), z.literal(true)]).optional().default(ASTRO_CONFIG_DEFAULTS.server.allowedHosts)
|
|
138
|
-
})
|
|
139
|
-
)
|
|
137
|
+
}).prefault({})
|
|
138
|
+
),
|
|
140
139
|
redirects: z.record(
|
|
141
140
|
z.string(),
|
|
142
141
|
z.union([
|
|
@@ -313,7 +312,6 @@ const AstroConfigSchema = z.object({
|
|
|
313
312
|
svgOptimizer: SvgOptimizerSchema.optional(),
|
|
314
313
|
cache: CacheSchema.optional(),
|
|
315
314
|
routeRules: RouteRulesSchema.optional(),
|
|
316
|
-
rustCompiler: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.rustCompiler),
|
|
317
315
|
queuedRendering: z.object({
|
|
318
316
|
enabled: z.boolean().optional().prefault(false),
|
|
319
317
|
poolSize: z.number().int().nonnegative().optional(),
|