astro 6.3.1 → 7.0.0-alpha.1
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/endpoint/generic.js +16 -7
- 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/add/index.js +0 -54
- 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/content/vite-plugin-content-assets.js +1 -0
- 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 +0 -2
- package/dist/core/config/schemas/base.js +0 -2
- package/dist/core/config/schemas/relative.d.ts +0 -3
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +2 -0
- package/dist/core/dev/dev.js +1 -13
- package/dist/core/errors/dev/utils.js +1 -1
- package/dist/core/head-propagation/hint.d.ts +4 -0
- package/dist/core/head-propagation/hint.js +7 -0
- package/dist/core/messages/runtime.d.ts +0 -3
- package/dist/core/messages/runtime.js +1 -9
- package/dist/core/middleware/vite-plugin.js +2 -2
- package/dist/core/preview/static-preview-server.js +1 -3
- 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-astro/utils.d.ts +0 -1
- package/dist/vite-plugin-astro/utils.js +1 -9
- package/dist/vite-plugin-head/index.js +9 -3
- package/dist/vite-plugin-pages/util.d.ts +1 -1
- package/package.json +9 -9
- package/templates/content/module.mjs +1 -1
- package/dist/assets/endpoint/loadImage.d.ts +0 -11
- package/dist/assets/endpoint/loadImage.js +0 -19
- 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
|
@@ -4,7 +4,21 @@ import { isRemoteAllowed } from "@astrojs/internal-helpers/remote";
|
|
|
4
4
|
import * as mime from "mrmime";
|
|
5
5
|
import { getConfiguredImageService } from "../internal.js";
|
|
6
6
|
import { etag } from "../utils/etag.js";
|
|
7
|
-
import {
|
|
7
|
+
import { fetchWithRedirects } from "../utils/redirectValidation.js";
|
|
8
|
+
async function loadRemoteImage(src, headers) {
|
|
9
|
+
try {
|
|
10
|
+
const res = await fetchWithRedirects({ url: src, headers, imageConfig });
|
|
11
|
+
if (!isRemoteAllowed(res.url, imageConfig)) {
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
14
|
+
if (!res.ok) {
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
return await res.arrayBuffer();
|
|
18
|
+
} catch {
|
|
19
|
+
return void 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
8
22
|
const GET = async ({ request }) => {
|
|
9
23
|
try {
|
|
10
24
|
const imageService = await getConfiguredImageService();
|
|
@@ -25,12 +39,7 @@ const GET = async ({ request }) => {
|
|
|
25
39
|
if (!isRemoteImage && sourceUrl.origin !== url.origin) {
|
|
26
40
|
return new Response("Forbidden", { status: 403 });
|
|
27
41
|
}
|
|
28
|
-
inputBuffer = await
|
|
29
|
-
sourceUrl,
|
|
30
|
-
isRemoteImage ? new Headers() : request.headers,
|
|
31
|
-
imageConfig,
|
|
32
|
-
isRemoteImage
|
|
33
|
-
);
|
|
42
|
+
inputBuffer = await loadRemoteImage(sourceUrl, isRemoteImage ? new Headers() : request.headers);
|
|
34
43
|
if (!inputBuffer) {
|
|
35
44
|
return new Response("Not Found", { status: 404 });
|
|
36
45
|
}
|
|
@@ -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
|
});
|
package/dist/cli/add/index.js
CHANGED
|
@@ -197,12 +197,6 @@ async function add(names, { flags }) {
|
|
|
197
197
|
logger,
|
|
198
198
|
scripts: { "generate-types": "wrangler types" }
|
|
199
199
|
});
|
|
200
|
-
await updatePackageJsonOverrides({
|
|
201
|
-
configURL,
|
|
202
|
-
flags,
|
|
203
|
-
logger,
|
|
204
|
-
overrides: { vite: "^7" }
|
|
205
|
-
});
|
|
206
200
|
}
|
|
207
201
|
if (integrations.find((integration) => integration.id === "tailwind")) {
|
|
208
202
|
const dir = new URL("./styles/", new URL(userConfig.srcDir ?? "./src/", root));
|
|
@@ -590,54 +584,6 @@ async function updateAstroConfig({
|
|
|
590
584
|
return "cancelled";
|
|
591
585
|
}
|
|
592
586
|
}
|
|
593
|
-
async function updatePackageJsonOverrides({
|
|
594
|
-
configURL,
|
|
595
|
-
flags,
|
|
596
|
-
logger,
|
|
597
|
-
overrides
|
|
598
|
-
}) {
|
|
599
|
-
const pkgURL = new URL("./package.json", configURL);
|
|
600
|
-
if (!existsSync(pkgURL)) {
|
|
601
|
-
logger.debug("add", "No package.json found, skipping overrides update");
|
|
602
|
-
return "none";
|
|
603
|
-
}
|
|
604
|
-
const pkgPath = fileURLToPath(pkgURL);
|
|
605
|
-
const input = await fs.readFile(pkgPath, { encoding: "utf-8" });
|
|
606
|
-
const pkgJson = JSON.parse(input);
|
|
607
|
-
pkgJson.overrides ??= {};
|
|
608
|
-
let hasChanges = false;
|
|
609
|
-
for (const [name, range] of Object.entries(overrides)) {
|
|
610
|
-
if (!(name in pkgJson.overrides)) {
|
|
611
|
-
pkgJson.overrides[name] = range;
|
|
612
|
-
hasChanges = true;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
if (!hasChanges) {
|
|
616
|
-
return "none";
|
|
617
|
-
}
|
|
618
|
-
const output = JSON.stringify(pkgJson, null, 2);
|
|
619
|
-
const diff = getDiffContent(input, output);
|
|
620
|
-
if (!diff) {
|
|
621
|
-
return "none";
|
|
622
|
-
}
|
|
623
|
-
logger.info(
|
|
624
|
-
"SKIP_FORMAT",
|
|
625
|
-
`
|
|
626
|
-
${magenta("Astro will add the following overrides to your package.json:")}`
|
|
627
|
-
);
|
|
628
|
-
clack.box(diff, "package.json", {
|
|
629
|
-
rounded: true,
|
|
630
|
-
withGuide: false,
|
|
631
|
-
width: "auto"
|
|
632
|
-
});
|
|
633
|
-
if (await askToContinue({ flags, logger })) {
|
|
634
|
-
await fs.writeFile(pkgPath, output, { encoding: "utf-8" });
|
|
635
|
-
logger.debug("add", "Updated package.json overrides");
|
|
636
|
-
return "updated";
|
|
637
|
-
} else {
|
|
638
|
-
return "cancelled";
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
587
|
async function updatePackageJsonScripts({
|
|
642
588
|
configURL,
|
|
643
589
|
flags,
|
|
@@ -191,7 +191,7 @@ ${contentConfig.error.message}`
|
|
|
191
191
|
logger.info("Content config changed");
|
|
192
192
|
shouldClear = true;
|
|
193
193
|
}
|
|
194
|
-
if (previousAstroVersion && previousAstroVersion !== "
|
|
194
|
+
if (previousAstroVersion && previousAstroVersion !== "7.0.0-alpha.1") {
|
|
195
195
|
logger.info("Astro version changed");
|
|
196
196
|
shouldClear = true;
|
|
197
197
|
}
|
|
@@ -199,8 +199,8 @@ ${contentConfig.error.message}`
|
|
|
199
199
|
logger.info("Clearing content store");
|
|
200
200
|
this.#store.clearAll();
|
|
201
201
|
}
|
|
202
|
-
if ("
|
|
203
|
-
this.#store.metaStore().set("astro-version", "
|
|
202
|
+
if ("7.0.0-alpha.1") {
|
|
203
|
+
this.#store.metaStore().set("astro-version", "7.0.0-alpha.1");
|
|
204
204
|
}
|
|
205
205
|
if (currentConfigDigest) {
|
|
206
206
|
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 } : {},
|
|
@@ -194,7 +194,7 @@ async function buildEnvironments(opts, internals) {
|
|
|
194
194
|
}
|
|
195
195
|
return `${settings.config.build.assets}/[name].[hash][extname]`;
|
|
196
196
|
},
|
|
197
|
-
...viteConfig.build?.
|
|
197
|
+
...viteConfig.build?.rolldownOptions?.output,
|
|
198
198
|
entryFileNames(chunkInfo) {
|
|
199
199
|
if (chunkInfo.facadeModuleId?.startsWith(VIRTUAL_PAGE_RESOLVED_MODULE_ID)) {
|
|
200
200
|
return makeAstroPageEntryPointFileName(
|
|
@@ -203,8 +203,8 @@ async function buildEnvironments(opts, internals) {
|
|
|
203
203
|
routes
|
|
204
204
|
);
|
|
205
205
|
} else if (chunkInfo.facadeModuleId === RESOLVED_LEGACY_SSR_ENTRY_VIRTUAL_MODULE || // This catches the case when the adapter uses `entrypointResolution: 'auto'`. When doing so,
|
|
206
|
-
// the adapter must set
|
|
207
|
-
|
|
206
|
+
// the adapter must set rolldownOptions.input or Astro sets it from `serverEntrypoint`.
|
|
207
|
+
isRolldownInput(chunkInfo.name) || isRolldownInput(chunkInfo.facadeModuleId)) {
|
|
208
208
|
return opts.settings.config.build.serverEntry;
|
|
209
209
|
} else {
|
|
210
210
|
return "[name].mjs";
|
|
@@ -228,7 +228,7 @@ async function buildEnvironments(opts, internals) {
|
|
|
228
228
|
let prerenderOutput = await builder2.build(builder2.environments.prerender);
|
|
229
229
|
settings.timer.end("Prerender build");
|
|
230
230
|
extractPrerenderEntryFileName(internals, prerenderOutput);
|
|
231
|
-
const prerenderOutputs =
|
|
231
|
+
const prerenderOutputs = viteBuildReturnToRolldownOutputs(prerenderOutput);
|
|
232
232
|
const prerenderChunks = extractRelevantChunks(prerenderOutputs, true);
|
|
233
233
|
prerenderOutput = void 0;
|
|
234
234
|
let ssrChunks = [];
|
|
@@ -238,7 +238,7 @@ async function buildEnvironments(opts, internals) {
|
|
|
238
238
|
builder2.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr]
|
|
239
239
|
);
|
|
240
240
|
settings.timer.end("SSR build");
|
|
241
|
-
const ssrOutputs =
|
|
241
|
+
const ssrOutputs = viteBuildReturnToRolldownOutputs(ssrOutput);
|
|
242
242
|
ssrChunks = extractRelevantChunks(ssrOutputs, false);
|
|
243
243
|
ssrOutput = void 0;
|
|
244
244
|
}
|
|
@@ -266,14 +266,14 @@ async function buildEnvironments(opts, internals) {
|
|
|
266
266
|
build: {
|
|
267
267
|
emitAssets: true,
|
|
268
268
|
outDir: fileURLToPath(getPrerenderOutputDirectory(settings)),
|
|
269
|
-
|
|
269
|
+
rolldownOptions: {
|
|
270
270
|
// Only skip the default prerender entrypoint if an adapter with `entrypointResolution: 'self'` is used
|
|
271
271
|
// AND provides a custom prerenderer. Otherwise, use the default.
|
|
272
272
|
...!legacyAdapter && settings.prerenderer ? {} : { input: "astro/entrypoints/prerender" },
|
|
273
273
|
output: {
|
|
274
274
|
entryFileNames: `${PRERENDER_ENTRY_FILENAME_PREFIX}.[hash].mjs`,
|
|
275
275
|
format: "esm",
|
|
276
|
-
...viteConfig.environments?.prerender?.build?.
|
|
276
|
+
...viteConfig.environments?.prerender?.build?.rolldownOptions?.output
|
|
277
277
|
}
|
|
278
278
|
},
|
|
279
279
|
ssr: true
|
|
@@ -287,7 +287,7 @@ async function buildEnvironments(opts, internals) {
|
|
|
287
287
|
copyPublicDir: true,
|
|
288
288
|
sourcemap: viteConfig.environments?.client?.build?.sourcemap ?? false,
|
|
289
289
|
minify: true,
|
|
290
|
-
|
|
290
|
+
rolldownOptions: {
|
|
291
291
|
preserveEntrySignatures: "exports-only",
|
|
292
292
|
output: {
|
|
293
293
|
entryFileNames(chunkInfo) {
|
|
@@ -304,7 +304,7 @@ async function buildEnvironments(opts, internals) {
|
|
|
304
304
|
}
|
|
305
305
|
return `${settings.config.build.assets}/[name].[hash][extname]`;
|
|
306
306
|
},
|
|
307
|
-
...viteConfig.environments?.client?.build?.
|
|
307
|
+
...viteConfig.environments?.client?.build?.rolldownOptions?.output
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
}
|
|
@@ -312,9 +312,9 @@ async function buildEnvironments(opts, internals) {
|
|
|
312
312
|
[ASTRO_VITE_ENVIRONMENT_NAMES.ssr]: {
|
|
313
313
|
build: {
|
|
314
314
|
outDir: fileURLToPath(getServerOutputDirectory(settings)),
|
|
315
|
-
|
|
315
|
+
rolldownOptions: {
|
|
316
316
|
output: {
|
|
317
|
-
...viteConfig.environments?.ssr?.build?.
|
|
317
|
+
...viteConfig.environments?.ssr?.build?.rolldownOptions?.output
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
}
|
|
@@ -332,7 +332,7 @@ async function buildEnvironments(opts, internals) {
|
|
|
332
332
|
await builder.buildApp();
|
|
333
333
|
}
|
|
334
334
|
function getPrerenderEntryFileName(prerenderOutput) {
|
|
335
|
-
const outputs =
|
|
335
|
+
const outputs = viteBuildReturnToRolldownOutputs(prerenderOutput);
|
|
336
336
|
for (const output of outputs) {
|
|
337
337
|
for (const chunk of output.output) {
|
|
338
338
|
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
|
});
|
|
@@ -80,7 +80,6 @@ export declare const ASTRO_CONFIG_DEFAULTS: {
|
|
|
80
80
|
clientPrerender: false;
|
|
81
81
|
contentIntellisense: false;
|
|
82
82
|
chromeDevtoolsWorkspace: false;
|
|
83
|
-
rustCompiler: false;
|
|
84
83
|
queuedRendering: {
|
|
85
84
|
enabled: false;
|
|
86
85
|
};
|
|
@@ -521,7 +520,6 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
521
520
|
swr: z.ZodOptional<z.ZodNumber>;
|
|
522
521
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
523
522
|
}, z.core.$strip>>>;
|
|
524
|
-
rustCompiler: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
525
523
|
queuedRendering: z.ZodPrefault<z.ZodOptional<z.ZodObject<{
|
|
526
524
|
enabled: z.ZodPrefault<z.ZodOptional<z.ZodBoolean>>;
|
|
527
525
|
poolSize: z.ZodOptional<z.ZodNumber>;
|
|
@@ -65,7 +65,6 @@ const ASTRO_CONFIG_DEFAULTS = {
|
|
|
65
65
|
clientPrerender: false,
|
|
66
66
|
contentIntellisense: false,
|
|
67
67
|
chromeDevtoolsWorkspace: false,
|
|
68
|
-
rustCompiler: false,
|
|
69
68
|
queuedRendering: {
|
|
70
69
|
enabled: false
|
|
71
70
|
},
|
|
@@ -317,7 +316,6 @@ const AstroConfigSchema = z.object({
|
|
|
317
316
|
svgOptimizer: SvgOptimizerSchema.optional(),
|
|
318
317
|
cache: CacheSchema.optional(),
|
|
319
318
|
routeRules: RouteRulesSchema.optional(),
|
|
320
|
-
rustCompiler: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.rustCompiler),
|
|
321
319
|
queuedRendering: z.object({
|
|
322
320
|
enabled: z.boolean().optional().prefault(false),
|
|
323
321
|
poolSize: z.number().int().nonnegative().optional(),
|