astro 4.6.2 → 4.6.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-jsx.d.ts +0 -2
- package/components/Image.astro +1 -1
- package/components/Picture.astro +1 -1
- package/components/ViewTransitions.astro +9 -2
- package/dist/@types/astro.d.ts +38 -37
- package/dist/assets/endpoint/generic.js +3 -3
- package/dist/assets/endpoint/node.js +3 -3
- package/dist/assets/utils/emitAsset.d.ts +6 -1
- package/dist/assets/utils/emitAsset.js +15 -9
- package/dist/assets/vite-plugin-assets.js +9 -2
- package/dist/cli/add/index.js +3 -3
- package/dist/cli/install-package.js +3 -1
- package/dist/config/index.js +2 -2
- package/dist/content/runtime-assets.d.ts +1 -1
- package/dist/content/runtime-assets.js +2 -2
- package/dist/content/runtime.d.ts +1 -1
- package/dist/content/utils.d.ts +1 -1
- package/dist/content/utils.js +2 -2
- package/dist/content/vite-plugin-content-imports.js +10 -2
- package/dist/core/app/createOutgoingHttpHeaders.d.ts +1 -0
- package/dist/core/build/consts.d.ts +1 -0
- package/dist/core/build/consts.js +4 -0
- package/dist/core/build/index.js +2 -1
- package/dist/core/build/internal.d.ts +1 -0
- package/dist/core/build/internal.js +2 -1
- package/dist/core/build/plugin.d.ts +1 -1
- package/dist/core/build/plugins/plugin-content.js +135 -30
- package/dist/core/build/plugins/util.d.ts +1 -1
- package/dist/core/build/static-build.d.ts +1 -1
- package/dist/core/build/static-build.js +3 -2
- package/dist/core/config/config.d.ts +1 -0
- package/dist/core/config/config.js +10 -8
- package/dist/core/config/index.d.ts +1 -1
- package/dist/core/config/index.js +8 -1
- package/dist/core/config/schema.d.ts +333 -290
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/render-context.d.ts +10 -1
- package/dist/core/render-context.js +38 -8
- package/dist/integrations/index.d.ts +2 -1
- package/dist/integrations/index.js +9 -2
- package/dist/runtime/client/dev-toolbar/apps/settings.js +3 -1
- package/dist/runtime/client/dev-toolbar/entrypoint.js +1 -1
- package/dist/runtime/client/dev-toolbar/toolbar.js +3 -1
- package/dist/runtime/server/astro-island.js +132 -137
- package/dist/runtime/server/astro-island.prebuilt-dev.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt-dev.js +1 -1
- package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt.js +1 -1
- package/dist/transitions/router.js +4 -3
- package/dist/vite-plugin-astro/index.js +11 -4
- package/dist/vite-plugin-markdown/images.d.ts +0 -1
- package/dist/vite-plugin-markdown/images.js +1 -4
- package/dist/vite-plugin-markdown/index.js +8 -2
- package/package.json +46 -49
package/astro-jsx.d.ts
CHANGED
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
* Adapted from React’s TypeScript definition from DefinitelyTyped.
|
|
10
10
|
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts
|
|
11
11
|
*/
|
|
12
|
-
// BUG! Prettier 3.0 removes `declare`: https://github.com/prettier/prettier/issues/15207
|
|
13
|
-
// prettier-ignore
|
|
14
12
|
declare namespace astroHTML.JSX {
|
|
15
13
|
export type Child = Node | Node[] | string | number | boolean | null | undefined | unknown;
|
|
16
14
|
export type Children = Child | Child[];
|
package/components/Image.astro
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
import {
|
|
2
|
+
import { type LocalImageProps, type RemoteImageProps, getImage } from 'astro:assets';
|
|
3
3
|
import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
|
|
4
4
|
import type { HTMLAttributes } from '../types';
|
|
5
5
|
|
package/components/Picture.astro
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
import {
|
|
2
|
+
import { type LocalImageProps, type RemoteImageProps, getImage } from 'astro:assets';
|
|
3
3
|
import type { GetImageResult, ImageOutputFormat } from '../dist/@types/astro';
|
|
4
4
|
import { isESMImportedImage, resolveSrc } from '../dist/assets/utils/imageKind';
|
|
5
5
|
import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
|
|
@@ -108,9 +108,16 @@ const { fallback = 'animate' } = Astro.props;
|
|
|
108
108
|
const form = el as HTMLFormElement;
|
|
109
109
|
const submitter = ev.submitter;
|
|
110
110
|
const formData = new FormData(form, submitter);
|
|
111
|
+
// form.action and form.method can point to an <input name="action"> or <input name="method">
|
|
112
|
+
// in which case should fallback to the form attribute
|
|
113
|
+
const formAction =
|
|
114
|
+
typeof form.action === 'string' ? form.action : form.getAttribute('action');
|
|
115
|
+
const formMethod =
|
|
116
|
+
typeof form.method === 'string' ? form.method : form.getAttribute('method');
|
|
111
117
|
// Use the form action, if defined, otherwise fallback to current path.
|
|
112
|
-
let action = submitter?.getAttribute('formaction') ??
|
|
113
|
-
|
|
118
|
+
let action = submitter?.getAttribute('formaction') ?? formAction ?? location.pathname;
|
|
119
|
+
// Use the form method, if defined, otherwise fallback to "get"
|
|
120
|
+
const method = submitter?.getAttribute('formmethod') ?? formMethod ?? 'get';
|
|
114
121
|
|
|
115
122
|
// the "dialog" method is a special keyword used within <dialog> elements
|
|
116
123
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fs-method
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -1394,18 +1394,18 @@ export interface AstroUserConfig {
|
|
|
1394
1394
|
* When `true`, all URLs will display a language prefix.
|
|
1395
1395
|
* URLs will be of the form `example.com/[locale]/content/` for every route, including the default language.
|
|
1396
1396
|
* Localized folders are used for every language, including the default.
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1397
|
+
*
|
|
1398
|
+
* ```js
|
|
1399
|
+
* export default defineConfig({
|
|
1400
|
+
* i18n: {
|
|
1401
|
+
* defaultLocale: "en",
|
|
1402
|
+
* locales: ["en", "fr", "pt-br", "es"],
|
|
1403
|
+
* routing: {
|
|
1404
|
+
* prefixDefaultLocale: true,
|
|
1405
|
+
* }
|
|
1406
|
+
* }
|
|
1407
|
+
* })
|
|
1408
|
+
* ```
|
|
1409
1409
|
*/
|
|
1410
1410
|
prefixDefaultLocale?: boolean;
|
|
1411
1411
|
/**
|
|
@@ -1446,32 +1446,32 @@ export interface AstroUserConfig {
|
|
|
1446
1446
|
* - `"pathname": The strategy is applied to the pathname of the URLs
|
|
1447
1447
|
*/
|
|
1448
1448
|
strategy?: 'pathname';
|
|
1449
|
-
}
|
|
1449
|
+
}
|
|
1450
1450
|
/**
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1451
|
+
*
|
|
1452
|
+
* @docs
|
|
1453
|
+
* @name i18n.routing.manual
|
|
1454
|
+
* @kind h4
|
|
1455
|
+
* @type {string}
|
|
1456
|
+
* @version 4.6.0
|
|
1457
|
+
* @description
|
|
1458
|
+
* When this option is enabled, Astro will **disable** its i18n middleware so that you can implement your own custom logic. No other `routing` options (e.g. `prefixDefaultLocale`) may be configured with `routing: "manual"`.
|
|
1459
|
+
*
|
|
1460
|
+
* You will be responsible for writing your own routing logic, or executing Astro's i18n middleware manually alongside your own.
|
|
1461
|
+
*
|
|
1462
|
+
* ```js
|
|
1463
|
+
* export default defineConfig({
|
|
1464
|
+
* i18n: {
|
|
1465
|
+
* defaultLocale: "en",
|
|
1466
|
+
* locales: ["en", "fr", "pt-br", "es"],
|
|
1467
|
+
* routing: {
|
|
1468
|
+
* prefixDefaultLocale: true,
|
|
1469
|
+
* }
|
|
1470
|
+
* }
|
|
1471
|
+
* })
|
|
1472
|
+
* ```
|
|
1473
|
+
*/
|
|
1474
|
+
| 'manual';
|
|
1475
1475
|
/**
|
|
1476
1476
|
* @name i18n.domains
|
|
1477
1477
|
* @type {Record<string, string> }
|
|
@@ -2524,6 +2524,7 @@ export interface AstroIntegration {
|
|
|
2524
2524
|
dir: URL;
|
|
2525
2525
|
routes: RouteData[];
|
|
2526
2526
|
logger: AstroIntegrationLogger;
|
|
2527
|
+
cacheManifest: boolean;
|
|
2527
2528
|
}) => void | Promise<void>;
|
|
2528
2529
|
};
|
|
2529
2530
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { imageConfig } from "astro:assets";
|
|
1
2
|
import { isRemotePath } from "@astrojs/internal-helpers/path";
|
|
2
|
-
import mime from "
|
|
3
|
+
import * as mime from "mrmime";
|
|
3
4
|
import { getConfiguredImageService } from "../internal.js";
|
|
4
5
|
import { etag } from "../utils/etag.js";
|
|
5
6
|
import { isRemoteAllowed } from "../utils/remotePattern.js";
|
|
6
|
-
import { imageConfig } from "astro:assets";
|
|
7
7
|
async function loadRemoteImage(src, headers) {
|
|
8
8
|
try {
|
|
9
9
|
const res = await fetch(src, {
|
|
@@ -47,7 +47,7 @@ const GET = async ({ request }) => {
|
|
|
47
47
|
return new Response(data, {
|
|
48
48
|
status: 200,
|
|
49
49
|
headers: {
|
|
50
|
-
"Content-Type": mime.
|
|
50
|
+
"Content-Type": mime.lookup(format) ?? `image/${format}`,
|
|
51
51
|
"Cache-Control": "public, max-age=31536000",
|
|
52
52
|
ETag: etag(data.toString()),
|
|
53
53
|
Date: (/* @__PURE__ */ new Date()).toUTCString()
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import os from "node:os";
|
|
2
2
|
import { isAbsolute } from "node:path";
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
import { assetsDir, imageConfig, outDir } from "astro:assets";
|
|
4
5
|
import { isRemotePath, removeQueryString } from "@astrojs/internal-helpers/path";
|
|
5
6
|
import { readFile } from "fs/promises";
|
|
6
|
-
import mime from "
|
|
7
|
+
import * as mime from "mrmime";
|
|
7
8
|
import { getConfiguredImageService } from "../internal.js";
|
|
8
9
|
import { etag } from "../utils/etag.js";
|
|
9
10
|
import { isRemoteAllowed } from "../utils/remotePattern.js";
|
|
10
|
-
import { assetsDir, imageConfig, outDir } from "astro:assets";
|
|
11
11
|
function replaceFileSystemReferences(src) {
|
|
12
12
|
return os.platform().includes("win32") ? src.replace(/^\/@fs\//, "") : src.replace(/^\/@fs/, "");
|
|
13
13
|
}
|
|
@@ -83,7 +83,7 @@ const GET = async ({ request }) => {
|
|
|
83
83
|
return new Response(data, {
|
|
84
84
|
status: 200,
|
|
85
85
|
headers: {
|
|
86
|
-
"Content-Type": mime.
|
|
86
|
+
"Content-Type": mime.lookup(format) ?? `image/${format}`,
|
|
87
87
|
"Cache-Control": "public, max-age=31536000",
|
|
88
88
|
ETag: etag(data.toString()),
|
|
89
89
|
Date: (/* @__PURE__ */ new Date()).toUTCString()
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
import type * as vite from 'vite';
|
|
1
2
|
import type { ImageMetadata } from '../types.js';
|
|
2
|
-
|
|
3
|
+
type FileEmitter = vite.Rollup.EmitFile;
|
|
4
|
+
export declare function emitESMImage(id: string | undefined,
|
|
5
|
+
/** @deprecated */
|
|
6
|
+
_watchMode: boolean, fileEmitter?: FileEmitter): Promise<ImageMetadata | undefined>;
|
|
7
|
+
export {};
|
|
@@ -3,7 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
4
|
import { prependForwardSlash, slash } from "../../core/path.js";
|
|
5
5
|
import { imageMetadata } from "./metadata.js";
|
|
6
|
-
async function emitESMImage(id,
|
|
6
|
+
async function emitESMImage(id, _watchMode, fileEmitter) {
|
|
7
7
|
if (!id) {
|
|
8
8
|
return void 0;
|
|
9
9
|
}
|
|
@@ -24,16 +24,22 @@ async function emitESMImage(id, watchMode, fileEmitter) {
|
|
|
24
24
|
writable: false,
|
|
25
25
|
value: id
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
let isBuild = typeof fileEmitter === "function";
|
|
28
|
+
if (isBuild) {
|
|
28
29
|
const pathname = decodeURI(url.pathname);
|
|
29
30
|
const filename = path.basename(pathname, path.extname(pathname) + `.${fileMetadata.format}`);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
try {
|
|
32
|
+
const handle = fileEmitter({
|
|
33
|
+
name: filename,
|
|
34
|
+
source: await fs.readFile(url),
|
|
35
|
+
type: "asset"
|
|
36
|
+
});
|
|
37
|
+
emittedImage.src = `__ASTRO_ASSET_IMAGE__${handle}__`;
|
|
38
|
+
} catch {
|
|
39
|
+
isBuild = false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (!isBuild) {
|
|
37
43
|
url.searchParams.append("origWidth", fileMetadata.width.toString());
|
|
38
44
|
url.searchParams.append("origHeight", fileMetadata.height.toString());
|
|
39
45
|
url.searchParams.append("origFormat", fileMetadata.format);
|
|
@@ -69,6 +69,7 @@ function assets({
|
|
|
69
69
|
mode
|
|
70
70
|
}) {
|
|
71
71
|
let resolvedConfig;
|
|
72
|
+
let shouldEmitFile = false;
|
|
72
73
|
globalThis.astroAsset = {
|
|
73
74
|
referencedImages: /* @__PURE__ */ new Set()
|
|
74
75
|
};
|
|
@@ -113,7 +114,9 @@ function assets({
|
|
|
113
114
|
isServerLikeOutput(settings.config) ? settings.config.build.client : settings.config.outDir
|
|
114
115
|
)
|
|
115
116
|
)});
|
|
116
|
-
export const assetsDir = /* #__PURE__ */ new URL(${JSON.stringify(
|
|
117
|
+
export const assetsDir = /* #__PURE__ */ new URL(${JSON.stringify(
|
|
118
|
+
settings.config.build.assets
|
|
119
|
+
)}, outDir);
|
|
117
120
|
export const getImage = async (options) => await getImageInternal(options, imageConfig);
|
|
118
121
|
`;
|
|
119
122
|
}
|
|
@@ -153,6 +156,9 @@ function assets({
|
|
|
153
156
|
{
|
|
154
157
|
name: "astro:assets:esm",
|
|
155
158
|
enforce: "pre",
|
|
159
|
+
config(_, env) {
|
|
160
|
+
shouldEmitFile = env.command === "build";
|
|
161
|
+
},
|
|
156
162
|
configResolved(viteConfig) {
|
|
157
163
|
resolvedConfig = viteConfig;
|
|
158
164
|
},
|
|
@@ -167,7 +173,8 @@ function assets({
|
|
|
167
173
|
if (!assetRegexEnds.test(id)) {
|
|
168
174
|
return;
|
|
169
175
|
}
|
|
170
|
-
const
|
|
176
|
+
const emitFile = shouldEmitFile ? this.emitFile : void 0;
|
|
177
|
+
const imageMetadata = await emitESMImage(id, this.meta.watchMode, emitFile);
|
|
171
178
|
if (!imageMetadata) {
|
|
172
179
|
throw new AstroError({
|
|
173
180
|
...AstroErrorData.ImageNotFound,
|
package/dist/cli/add/index.js
CHANGED
|
@@ -126,12 +126,12 @@ async function add(names, { flags }) {
|
|
|
126
126
|
["node", "astro add node"]
|
|
127
127
|
],
|
|
128
128
|
Others: [
|
|
129
|
+
["db", "astro add db"],
|
|
129
130
|
["tailwind", "astro add tailwind"],
|
|
130
|
-
["image", "astro add image"],
|
|
131
131
|
["mdx", "astro add mdx"],
|
|
132
|
+
["markdoc", "astro add markdoc"],
|
|
132
133
|
["partytown", "astro add partytown"],
|
|
133
|
-
["sitemap", "astro add sitemap"]
|
|
134
|
-
["prefetch", "astro add prefetch"]
|
|
134
|
+
["sitemap", "astro add sitemap"]
|
|
135
135
|
]
|
|
136
136
|
},
|
|
137
137
|
description: `For more integrations, check out: ${cyan("https://astro.build/integrations")}`
|
|
@@ -26,7 +26,9 @@ async function getPackage(packageName, logger, options, otherDeps = []) {
|
|
|
26
26
|
} catch (e) {
|
|
27
27
|
if (options.optional)
|
|
28
28
|
return void 0;
|
|
29
|
-
let message = `To continue, Astro requires the following dependency to be installed: ${bold(
|
|
29
|
+
let message = `To continue, Astro requires the following dependency to be installed: ${bold(
|
|
30
|
+
packageName
|
|
31
|
+
)}.`;
|
|
30
32
|
if (ci.isCI) {
|
|
31
33
|
message += ` Packages cannot be installed automatically in CI environments.`;
|
|
32
34
|
}
|
package/dist/config/index.js
CHANGED
|
@@ -27,8 +27,8 @@ function getViteConfig(inlineConfig) {
|
|
|
27
27
|
level: "info"
|
|
28
28
|
});
|
|
29
29
|
const { astroConfig: config } = await resolveConfig({}, cmd);
|
|
30
|
-
|
|
31
|
-
await runHookConfigSetup({ settings, command: cmd, logger });
|
|
30
|
+
let settings = await createSettings(config, inlineConfig.root);
|
|
31
|
+
settings = await runHookConfigSetup({ settings, command: cmd, logger });
|
|
32
32
|
const viteConfig = await createVite(
|
|
33
33
|
{
|
|
34
34
|
mode,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PluginContext } from 'rollup';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
export declare function createImage(pluginContext: PluginContext, entryFilePath: string): () => z.ZodEffects<z.ZodString, z.ZodNever | {
|
|
3
|
+
export declare function createImage(pluginContext: PluginContext, shouldEmitFile: boolean, entryFilePath: string): () => z.ZodEffects<z.ZodString, z.ZodNever | {
|
|
4
4
|
ASTRO_ASSET: string;
|
|
5
5
|
src: string;
|
|
6
6
|
width: number;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { emitESMImage } from "../assets/utils/emitAsset.js";
|
|
3
|
-
function createImage(pluginContext, entryFilePath) {
|
|
3
|
+
function createImage(pluginContext, shouldEmitFile, entryFilePath) {
|
|
4
4
|
return () => {
|
|
5
5
|
return z.string().transform(async (imagePath, ctx) => {
|
|
6
6
|
const resolvedFilePath = (await pluginContext.resolve(imagePath, entryFilePath))?.id;
|
|
7
7
|
const metadata = await emitESMImage(
|
|
8
8
|
resolvedFilePath,
|
|
9
9
|
pluginContext.meta.watchMode,
|
|
10
|
-
pluginContext.emitFile
|
|
10
|
+
shouldEmitFile ? pluginContext.emitFile : void 0
|
|
11
11
|
);
|
|
12
12
|
if (!metadata) {
|
|
13
13
|
ctx.addIssue({
|
|
@@ -14,7 +14,7 @@ export declare function createGetCollection({ contentCollectionToEntryMap, dataC
|
|
|
14
14
|
contentCollectionToEntryMap: CollectionToEntryMap;
|
|
15
15
|
dataCollectionToEntryMap: CollectionToEntryMap;
|
|
16
16
|
getRenderEntryImport: GetEntryImport;
|
|
17
|
-
}): (collection: string, filter?: (
|
|
17
|
+
}): (collection: string, filter?: (entry: any) => unknown) => Promise<any[]>;
|
|
18
18
|
export declare function createGetEntryBySlug({ getEntryImport, getRenderEntryImport, }: {
|
|
19
19
|
getEntryImport: GetEntryImport;
|
|
20
20
|
getRenderEntryImport: GetEntryImport;
|
package/dist/content/utils.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ export declare function getEntryData(entry: {
|
|
|
99
99
|
collection: string;
|
|
100
100
|
unvalidatedData: Record<string, unknown>;
|
|
101
101
|
_internal: EntryInternal;
|
|
102
|
-
}, collectionConfig: CollectionConfig, pluginContext: PluginContext): Promise<
|
|
102
|
+
}, collectionConfig: CollectionConfig, shouldEmitFile: boolean, pluginContext: PluginContext): Promise<Record<string, unknown>>;
|
|
103
103
|
export declare function getContentEntryExts(settings: Pick<AstroSettings, 'contentEntryTypes'>): string[];
|
|
104
104
|
export declare function getDataEntryExts(settings: Pick<AstroSettings, 'dataEntryTypes'>): string[];
|
|
105
105
|
export declare function getEntryConfigByExtMap<TEntryType extends ContentEntryType | DataEntryType>(entryTypes: TEntryType[]): Map<string, TEntryType>;
|
package/dist/content/utils.js
CHANGED
|
@@ -49,7 +49,7 @@ function parseEntrySlug({
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
async function getEntryData(entry, collectionConfig, pluginContext) {
|
|
52
|
+
async function getEntryData(entry, collectionConfig, shouldEmitFile, pluginContext) {
|
|
53
53
|
let data;
|
|
54
54
|
if (collectionConfig.type === "data") {
|
|
55
55
|
data = entry.unvalidatedData;
|
|
@@ -60,7 +60,7 @@ async function getEntryData(entry, collectionConfig, pluginContext) {
|
|
|
60
60
|
let schema = collectionConfig.schema;
|
|
61
61
|
if (typeof schema === "function") {
|
|
62
62
|
schema = schema({
|
|
63
|
-
image: createImage(pluginContext, entry._internal.filePath)
|
|
63
|
+
image: createImage(pluginContext, shouldEmitFile, entry._internal.filePath)
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
if (schema) {
|
|
@@ -44,9 +44,13 @@ function astroContentImportPlugin({
|
|
|
44
44
|
const contentEntryConfigByExt = getEntryConfigByExtMap(settings.contentEntryTypes);
|
|
45
45
|
const dataEntryConfigByExt = getEntryConfigByExtMap(settings.dataEntryTypes);
|
|
46
46
|
const { contentDir } = contentPaths;
|
|
47
|
+
let shouldEmitFile = false;
|
|
47
48
|
const plugins = [
|
|
48
49
|
{
|
|
49
50
|
name: "astro:content-imports",
|
|
51
|
+
config(_config, env) {
|
|
52
|
+
shouldEmitFile = env.command === "build";
|
|
53
|
+
},
|
|
50
54
|
async transform(_, viteId) {
|
|
51
55
|
if (hasContentFlag(viteId, DATA_FLAG)) {
|
|
52
56
|
const fileId = viteId.split("?")[0] ?? viteId;
|
|
@@ -56,7 +60,8 @@ function astroContentImportPlugin({
|
|
|
56
60
|
contentDir,
|
|
57
61
|
config: settings.config,
|
|
58
62
|
fs,
|
|
59
|
-
pluginContext: this
|
|
63
|
+
pluginContext: this,
|
|
64
|
+
shouldEmitFile
|
|
60
65
|
});
|
|
61
66
|
const code = `
|
|
62
67
|
export const id = ${JSON.stringify(id)};
|
|
@@ -77,7 +82,8 @@ export const _internal = {
|
|
|
77
82
|
contentDir,
|
|
78
83
|
config: settings.config,
|
|
79
84
|
fs,
|
|
80
|
-
pluginContext: this
|
|
85
|
+
pluginContext: this,
|
|
86
|
+
shouldEmitFile
|
|
81
87
|
});
|
|
82
88
|
const code = `
|
|
83
89
|
export const id = ${JSON.stringify(id)};
|
|
@@ -158,6 +164,7 @@ async function getContentEntryModule(params) {
|
|
|
158
164
|
const data = collectionConfig ? await getEntryData(
|
|
159
165
|
{ id, collection, _internal, unvalidatedData },
|
|
160
166
|
collectionConfig,
|
|
167
|
+
params.shouldEmitFile,
|
|
161
168
|
pluginContext
|
|
162
169
|
) : unvalidatedData;
|
|
163
170
|
const contentEntryModule = {
|
|
@@ -182,6 +189,7 @@ async function getDataEntryModule(params) {
|
|
|
182
189
|
const data = collectionConfig ? await getEntryData(
|
|
183
190
|
{ id, collection, _internal, unvalidatedData },
|
|
184
191
|
collectionConfig,
|
|
192
|
+
params.shouldEmitFile,
|
|
185
193
|
pluginContext
|
|
186
194
|
) : unvalidatedData;
|
|
187
195
|
const dataEntryModule = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CHUNKS_PATH = "chunks/";
|
package/dist/core/build/index.js
CHANGED
|
@@ -146,7 +146,8 @@ class AstroBuilder {
|
|
|
146
146
|
config: this.settings.config,
|
|
147
147
|
pages: pageNames,
|
|
148
148
|
routes: Object.values(allPages).flat().map((pageData) => pageData.route),
|
|
149
|
-
logging: this.logger
|
|
149
|
+
logging: this.logger,
|
|
150
|
+
cacheManifest: internals.cacheManifestUsed
|
|
150
151
|
});
|
|
151
152
|
if (this.logger.level && levels[this.logger.level()] <= levels["info"]) {
|
|
152
153
|
await this.printStats({
|
|
@@ -66,6 +66,7 @@ export interface BuildInternals {
|
|
|
66
66
|
*/
|
|
67
67
|
discoveredScripts: Set<string>;
|
|
68
68
|
cachedClientEntries: string[];
|
|
69
|
+
cacheManifestUsed: boolean;
|
|
69
70
|
propagatedStylesMap: Map<string, Set<StylesheetAsset>>;
|
|
70
71
|
propagatedScriptsMap: Map<string, Set<string>>;
|
|
71
72
|
staticFiles: Set<string>;
|
|
@@ -29,7 +29,8 @@ function createBuildInternals() {
|
|
|
29
29
|
staticFiles: /* @__PURE__ */ new Set(),
|
|
30
30
|
componentMetadata: /* @__PURE__ */ new Map(),
|
|
31
31
|
ssrSplitEntryChunks: /* @__PURE__ */ new Map(),
|
|
32
|
-
entryPoints: /* @__PURE__ */ new Map()
|
|
32
|
+
entryPoints: /* @__PURE__ */ new Map(),
|
|
33
|
+
cacheManifestUsed: false
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
function trackPageData(internals, component, pageData, componentModuleId, componentURL) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Plugin as VitePlugin
|
|
1
|
+
import type { Rollup, Plugin as VitePlugin } from 'vite';
|
|
2
2
|
import type { BuildInternals } from './internal.js';
|
|
3
3
|
import type { StaticBuildOptions, ViteBuildReturn } from './types.js';
|
|
4
4
|
type RollupOutputArray = Extract<ViteBuildReturn, Array<any>>;
|