astro 4.13.4 → 4.14.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/components/Code.astro +9 -0
- package/dist/@types/astro.d.ts +249 -1
- package/dist/actions/consts.d.ts +1 -1
- package/dist/actions/consts.js +1 -1
- package/dist/actions/index.js +12 -21
- package/dist/assets/endpoint/node.js +1 -1
- package/dist/assets/utils/resolveImports.d.ts +9 -0
- package/dist/assets/utils/resolveImports.js +22 -0
- package/dist/cli/add/index.d.ts +2 -2
- package/dist/cli/add/index.js +2 -2
- package/dist/cli/build/index.d.ts +2 -2
- package/dist/cli/build/index.js +5 -1
- package/dist/cli/check/index.d.ts +2 -2
- package/dist/cli/check/index.js +5 -2
- package/dist/cli/db/index.d.ts +4 -3
- package/dist/cli/db/index.js +10 -3
- package/dist/cli/dev/index.d.ts +2 -2
- package/dist/cli/dev/index.js +1 -0
- package/dist/cli/docs/index.d.ts +2 -2
- package/dist/cli/flags.d.ts +3 -1
- package/dist/cli/flags.js +2 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +26 -13
- package/dist/cli/info/index.d.ts +2 -2
- package/dist/cli/preferences/index.d.ts +2 -2
- package/dist/cli/preferences/index.js +1 -1
- package/dist/cli/preview/index.d.ts +2 -2
- package/dist/cli/sync/index.d.ts +2 -2
- package/dist/cli/sync/index.js +5 -2
- package/dist/cli/telemetry/index.d.ts +2 -2
- package/dist/content/consts.d.ts +16 -2
- package/dist/content/consts.js +32 -2
- package/dist/content/content-layer.d.ts +40 -0
- package/dist/content/content-layer.js +253 -0
- package/dist/content/data-store.d.ts +54 -0
- package/dist/content/data-store.js +72 -0
- package/dist/content/loaders/file.d.ts +7 -0
- package/dist/content/loaders/file.js +72 -0
- package/dist/content/loaders/glob.d.ts +25 -0
- package/dist/content/loaders/glob.js +218 -0
- package/dist/content/loaders/index.d.ts +3 -0
- package/dist/content/loaders/index.js +7 -0
- package/dist/content/loaders/types.d.ts +36 -0
- package/dist/content/loaders/types.js +0 -0
- package/dist/content/mutable-data-store.d.ts +77 -0
- package/dist/content/mutable-data-store.js +269 -0
- package/dist/content/runtime.d.ts +46 -8
- package/dist/content/runtime.js +225 -31
- package/dist/content/types-generator.js +123 -35
- package/dist/content/utils.d.ts +307 -2
- package/dist/content/utils.js +101 -7
- package/dist/content/vite-plugin-content-assets.js +9 -1
- package/dist/content/vite-plugin-content-virtual-mod.js +94 -2
- package/dist/core/build/index.js +14 -7
- package/dist/core/build/plugins/plugin-ssr.js +32 -4
- package/dist/core/config/config.d.ts +2 -5
- package/dist/core/config/config.js +0 -12
- package/dist/core/config/index.d.ts +1 -1
- package/dist/core/config/index.js +0 -2
- package/dist/core/config/schema.d.ts +34 -0
- package/dist/core/config/schema.js +6 -2
- package/dist/core/config/settings.js +5 -3
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +1 -1
- package/dist/core/dev/container.js +2 -1
- package/dist/core/dev/dev.js +33 -3
- package/dist/core/dev/restart.js +25 -10
- package/dist/core/errors/errors-data.d.ts +21 -0
- package/dist/core/errors/errors-data.js +13 -0
- package/dist/core/index.js +1 -1
- package/dist/core/logger/vite.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/preview/static-preview-server.js +1 -1
- package/dist/core/routing/manifest/create.js +1 -1
- package/dist/core/sync/constants.d.ts +1 -0
- package/dist/core/sync/constants.js +4 -0
- package/dist/core/sync/index.d.ts +12 -4
- package/dist/core/sync/index.js +54 -24
- package/dist/core/sync/write-files.d.ts +4 -0
- package/dist/core/sync/write-files.js +69 -0
- package/dist/core/util.js +1 -1
- package/dist/env/sync.js +6 -4
- package/dist/integrations/hooks.d.ts +7 -1
- package/dist/integrations/hooks.js +54 -0
- package/dist/preferences/index.d.ts +1 -1
- package/dist/preferences/index.js +2 -2
- package/dist/runtime/server/render/server-islands.js +6 -4
- package/dist/vite-plugin-astro-server/response.js +1 -1
- package/dist/vite-plugin-env/index.d.ts +3 -1
- package/dist/vite-plugin-env/index.js +11 -1
- package/dist/vite-plugin-markdown/content-entry-type.js +25 -2
- package/dist/vite-plugin-scanner/index.js +15 -5
- package/package.json +10 -5
- package/templates/content/module.mjs +6 -1
- package/templates/content/types.d.ts +18 -5
- package/types/content.d.ts +34 -1
- package/dist/core/sync/setup-env-ts.d.ts +0 -8
- package/dist/core/sync/setup-env-ts.js +0 -79
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import nodeFs from "node:fs";
|
|
2
2
|
import { extname } from "node:path";
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
import { dataToEsm } from "@rollup/pluginutils";
|
|
4
5
|
import glob from "fast-glob";
|
|
5
6
|
import pLimit from "p-limit";
|
|
6
7
|
import { encodeName } from "../core/build/util.js";
|
|
@@ -10,9 +11,18 @@ import { isServerLikeOutput } from "../core/util.js";
|
|
|
10
11
|
import { rootRelativePath } from "../core/viteUtils.js";
|
|
11
12
|
import { createDefaultAstroMetadata } from "../vite-plugin-astro/metadata.js";
|
|
12
13
|
import {
|
|
14
|
+
ASSET_IMPORTS_FILE,
|
|
15
|
+
ASSET_IMPORTS_RESOLVED_STUB_ID,
|
|
16
|
+
ASSET_IMPORTS_VIRTUAL_ID,
|
|
13
17
|
CONTENT_FLAG,
|
|
14
18
|
CONTENT_RENDER_FLAG,
|
|
15
19
|
DATA_FLAG,
|
|
20
|
+
DATA_STORE_FILE,
|
|
21
|
+
DATA_STORE_VIRTUAL_ID,
|
|
22
|
+
MODULES_IMPORTS_FILE,
|
|
23
|
+
MODULES_MJS_ID,
|
|
24
|
+
MODULES_MJS_VIRTUAL_ID,
|
|
25
|
+
RESOLVED_DATA_STORE_VIRTUAL_ID,
|
|
16
26
|
RESOLVED_VIRTUAL_MODULE_ID,
|
|
17
27
|
VIRTUAL_MODULE_ID
|
|
18
28
|
} from "./consts.js";
|
|
@@ -25,7 +35,8 @@ import {
|
|
|
25
35
|
getEntryConfigByExtMap,
|
|
26
36
|
getEntrySlug,
|
|
27
37
|
getEntryType,
|
|
28
|
-
getExtGlob
|
|
38
|
+
getExtGlob,
|
|
39
|
+
isDeferredModule
|
|
29
40
|
} from "./utils.js";
|
|
30
41
|
function astroContentVirtualModPlugin({
|
|
31
42
|
settings,
|
|
@@ -33,13 +44,14 @@ function astroContentVirtualModPlugin({
|
|
|
33
44
|
}) {
|
|
34
45
|
let IS_DEV = false;
|
|
35
46
|
const IS_SERVER = isServerLikeOutput(settings.config);
|
|
47
|
+
const dataStoreFile = new URL(DATA_STORE_FILE, settings.config.cacheDir);
|
|
36
48
|
return {
|
|
37
49
|
name: "astro-content-virtual-mod-plugin",
|
|
38
50
|
enforce: "pre",
|
|
39
51
|
configResolved(config) {
|
|
40
52
|
IS_DEV = config.mode === "development";
|
|
41
53
|
},
|
|
42
|
-
resolveId(id) {
|
|
54
|
+
async resolveId(id) {
|
|
43
55
|
if (id === VIRTUAL_MODULE_ID) {
|
|
44
56
|
if (!settings.config.experimental.contentCollectionCache) {
|
|
45
57
|
return RESOLVED_VIRTUAL_MODULE_ID;
|
|
@@ -50,6 +62,35 @@ function astroContentVirtualModPlugin({
|
|
|
50
62
|
return { id: RESOLVED_VIRTUAL_MODULE_ID, external: true };
|
|
51
63
|
}
|
|
52
64
|
}
|
|
65
|
+
if (id === DATA_STORE_VIRTUAL_ID) {
|
|
66
|
+
return RESOLVED_DATA_STORE_VIRTUAL_ID;
|
|
67
|
+
}
|
|
68
|
+
if (isDeferredModule(id)) {
|
|
69
|
+
const [, query] = id.split("?");
|
|
70
|
+
const params = new URLSearchParams(query);
|
|
71
|
+
const fileName = params.get("fileName");
|
|
72
|
+
let importerPath = void 0;
|
|
73
|
+
if (fileName && URL.canParse(fileName, settings.config.root.toString())) {
|
|
74
|
+
importerPath = fileURLToPath(new URL(fileName, settings.config.root));
|
|
75
|
+
}
|
|
76
|
+
if (importerPath) {
|
|
77
|
+
return await this.resolve(importerPath);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (id === MODULES_MJS_ID) {
|
|
81
|
+
const modules = new URL(MODULES_IMPORTS_FILE, settings.dotAstroDir);
|
|
82
|
+
if (fs.existsSync(modules)) {
|
|
83
|
+
return fileURLToPath(modules);
|
|
84
|
+
}
|
|
85
|
+
return MODULES_MJS_VIRTUAL_ID;
|
|
86
|
+
}
|
|
87
|
+
if (id === ASSET_IMPORTS_VIRTUAL_ID) {
|
|
88
|
+
const assetImportsFile = new URL(ASSET_IMPORTS_FILE, settings.dotAstroDir);
|
|
89
|
+
if (fs.existsSync(assetImportsFile)) {
|
|
90
|
+
return fileURLToPath(assetImportsFile);
|
|
91
|
+
}
|
|
92
|
+
return ASSET_IMPORTS_RESOLVED_STUB_ID;
|
|
93
|
+
}
|
|
53
94
|
},
|
|
54
95
|
async load(id, args) {
|
|
55
96
|
if (id === RESOLVED_VIRTUAL_MODULE_ID) {
|
|
@@ -75,6 +116,38 @@ function astroContentVirtualModPlugin({
|
|
|
75
116
|
}
|
|
76
117
|
};
|
|
77
118
|
}
|
|
119
|
+
if (id === RESOLVED_DATA_STORE_VIRTUAL_ID) {
|
|
120
|
+
if (!fs.existsSync(dataStoreFile)) {
|
|
121
|
+
return "export default new Map()";
|
|
122
|
+
}
|
|
123
|
+
const jsonData = await fs.promises.readFile(dataStoreFile, "utf-8");
|
|
124
|
+
try {
|
|
125
|
+
const parsed = JSON.parse(jsonData);
|
|
126
|
+
return {
|
|
127
|
+
code: dataToEsm(parsed, {
|
|
128
|
+
compact: true
|
|
129
|
+
}),
|
|
130
|
+
map: { mappings: "" }
|
|
131
|
+
};
|
|
132
|
+
} catch (err) {
|
|
133
|
+
const message = "Could not parse JSON file";
|
|
134
|
+
this.error({ message, id, cause: err });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (id === ASSET_IMPORTS_RESOLVED_STUB_ID) {
|
|
138
|
+
const assetImportsFile = new URL(ASSET_IMPORTS_FILE, settings.dotAstroDir);
|
|
139
|
+
if (!fs.existsSync(assetImportsFile)) {
|
|
140
|
+
return "export default new Map()";
|
|
141
|
+
}
|
|
142
|
+
return fs.readFileSync(assetImportsFile, "utf-8");
|
|
143
|
+
}
|
|
144
|
+
if (id === MODULES_MJS_VIRTUAL_ID) {
|
|
145
|
+
const modules = new URL(MODULES_IMPORTS_FILE, settings.dotAstroDir);
|
|
146
|
+
if (!fs.existsSync(modules)) {
|
|
147
|
+
return "export default new Map()";
|
|
148
|
+
}
|
|
149
|
+
return fs.readFileSync(modules, "utf-8");
|
|
150
|
+
}
|
|
78
151
|
},
|
|
79
152
|
renderChunk(code, chunk) {
|
|
80
153
|
if (!settings.config.experimental.contentCollectionCache) {
|
|
@@ -85,6 +158,25 @@ function astroContentVirtualModPlugin({
|
|
|
85
158
|
const prefix = depth > 0 ? "../".repeat(depth) : "./";
|
|
86
159
|
return code.replaceAll(RESOLVED_VIRTUAL_MODULE_ID, `${prefix}content/entry.mjs`);
|
|
87
160
|
}
|
|
161
|
+
},
|
|
162
|
+
configureServer(server) {
|
|
163
|
+
const dataStorePath = fileURLToPath(dataStoreFile);
|
|
164
|
+
if (Array.isArray(server.watcher.options.ignored)) {
|
|
165
|
+
server.watcher.options.ignored.push(`!${dataStorePath}`);
|
|
166
|
+
}
|
|
167
|
+
server.watcher.add(dataStorePath);
|
|
168
|
+
server.watcher.on("change", (changedPath) => {
|
|
169
|
+
if (changedPath === dataStorePath) {
|
|
170
|
+
const module = server.moduleGraph.getModuleById(RESOLVED_DATA_STORE_VIRTUAL_ID);
|
|
171
|
+
if (module) {
|
|
172
|
+
server.moduleGraph.invalidateModule(module);
|
|
173
|
+
}
|
|
174
|
+
server.ws.send({
|
|
175
|
+
type: "full-reload",
|
|
176
|
+
path: "*"
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
});
|
|
88
180
|
}
|
|
89
181
|
};
|
|
90
182
|
}
|
package/dist/core/build/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import { levels, timerMessage } from "../logger/core.js";
|
|
|
20
20
|
import { apply as applyPolyfill } from "../polyfill.js";
|
|
21
21
|
import { createRouteManifest } from "../routing/index.js";
|
|
22
22
|
import { getServerIslandRouteData } from "../server-islands/endpoint.js";
|
|
23
|
+
import { clearContentLayerCache } from "../sync/index.js";
|
|
23
24
|
import { ensureProcessNodeEnv, isServerLikeOutput } from "../util.js";
|
|
24
25
|
import { collectPagesData } from "./page-data.js";
|
|
25
26
|
import { staticBuild, viteBuild } from "./static-build.js";
|
|
@@ -30,13 +31,16 @@ async function build(inlineConfig, options = {}) {
|
|
|
30
31
|
const logger = createNodeLogger(inlineConfig);
|
|
31
32
|
const { userConfig, astroConfig } = await resolveConfig(inlineConfig, "build");
|
|
32
33
|
telemetry.record(eventCliSession("build", userConfig));
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
if (inlineConfig.force) {
|
|
35
|
+
if (astroConfig.experimental.contentCollectionCache) {
|
|
36
|
+
const contentCacheDir = new URL("./content/", astroConfig.cacheDir);
|
|
37
|
+
if (fs.existsSync(contentCacheDir)) {
|
|
38
|
+
logger.debug("content", "clearing content cache");
|
|
39
|
+
await fs.promises.rm(contentCacheDir, { force: true, recursive: true });
|
|
40
|
+
logger.warn("content", "content cache cleared (force)");
|
|
41
|
+
}
|
|
39
42
|
}
|
|
43
|
+
await clearContentLayerCache({ astroConfig, logger, fs });
|
|
40
44
|
}
|
|
41
45
|
const settings = await createSettings(astroConfig, fileURLToPath(astroConfig.root));
|
|
42
46
|
const builder = new AstroBuilder(settings, {
|
|
@@ -167,15 +171,18 @@ class AstroBuilder {
|
|
|
167
171
|
buildMode: this.settings.config.output
|
|
168
172
|
});
|
|
169
173
|
}
|
|
170
|
-
this.settings.timer.writeStats();
|
|
171
174
|
}
|
|
172
175
|
/** Build the given Astro project. */
|
|
173
176
|
async run() {
|
|
177
|
+
this.settings.timer.start("Total build");
|
|
174
178
|
const setupData = await this.setup();
|
|
175
179
|
try {
|
|
176
180
|
await this.build(setupData);
|
|
177
181
|
} catch (_err) {
|
|
178
182
|
throw _err;
|
|
183
|
+
} finally {
|
|
184
|
+
this.settings.timer.end("Total build");
|
|
185
|
+
this.settings.timer.writeStats();
|
|
179
186
|
}
|
|
180
187
|
}
|
|
181
188
|
validateConfig() {
|
|
@@ -12,6 +12,24 @@ import { RENDERERS_MODULE_ID } from "./plugin-renderers.js";
|
|
|
12
12
|
import { getComponentFromVirtualModulePageName, getVirtualModulePageName } from "./util.js";
|
|
13
13
|
const SSR_VIRTUAL_MODULE_ID = "@astrojs-ssr-virtual-entry";
|
|
14
14
|
const RESOLVED_SSR_VIRTUAL_MODULE_ID = "\0" + SSR_VIRTUAL_MODULE_ID;
|
|
15
|
+
const ADAPTER_VIRTUAL_MODULE_ID = "@astrojs-ssr-adapter";
|
|
16
|
+
const RESOLVED_ADAPTER_VIRTUAL_MODULE_ID = "\0" + ADAPTER_VIRTUAL_MODULE_ID;
|
|
17
|
+
function vitePluginAdapter(adapter) {
|
|
18
|
+
return {
|
|
19
|
+
name: "@astrojs/vite-plugin-astro-adapter",
|
|
20
|
+
enforce: "post",
|
|
21
|
+
resolveId(id) {
|
|
22
|
+
if (id === ADAPTER_VIRTUAL_MODULE_ID) {
|
|
23
|
+
return RESOLVED_ADAPTER_VIRTUAL_MODULE_ID;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
async load(id) {
|
|
27
|
+
if (id === RESOLVED_ADAPTER_VIRTUAL_MODULE_ID) {
|
|
28
|
+
return `export * from '${adapter.serverEntrypoint}';`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
15
33
|
function vitePluginSSR(internals, adapter, options) {
|
|
16
34
|
return {
|
|
17
35
|
name: "@astrojs/vite-plugin-astro-ssr-server",
|
|
@@ -26,7 +44,7 @@ function vitePluginSSR(internals, adapter, options) {
|
|
|
26
44
|
}
|
|
27
45
|
const adapterServerEntrypoint = options.settings.adapter?.serverEntrypoint;
|
|
28
46
|
if (adapterServerEntrypoint) {
|
|
29
|
-
inputs.add(
|
|
47
|
+
inputs.add(ADAPTER_VIRTUAL_MODULE_ID);
|
|
30
48
|
}
|
|
31
49
|
inputs.add(SSR_VIRTUAL_MODULE_ID);
|
|
32
50
|
return addRollupInput(opts, Array.from(inputs));
|
|
@@ -98,7 +116,12 @@ function pluginSSR(options, internals) {
|
|
|
98
116
|
targets: ["server"],
|
|
99
117
|
hooks: {
|
|
100
118
|
"build:before": () => {
|
|
101
|
-
|
|
119
|
+
const adapter = options.settings.adapter;
|
|
120
|
+
let ssrPlugin = ssr && functionPerRouteEnabled === false ? vitePluginSSR(internals, adapter, options) : void 0;
|
|
121
|
+
const vitePlugin = [vitePluginAdapter(adapter)];
|
|
122
|
+
if (ssrPlugin) {
|
|
123
|
+
vitePlugin.unshift(ssrPlugin);
|
|
124
|
+
}
|
|
102
125
|
return {
|
|
103
126
|
enforce: "after-user-plugins",
|
|
104
127
|
vitePlugin
|
|
@@ -185,7 +208,12 @@ function pluginSSRSplit(options, internals) {
|
|
|
185
208
|
targets: ["server"],
|
|
186
209
|
hooks: {
|
|
187
210
|
"build:before": () => {
|
|
188
|
-
|
|
211
|
+
const adapter = options.settings.adapter;
|
|
212
|
+
let ssrPlugin = ssr && functionPerRouteEnabled ? vitePluginSSRSplit(internals, adapter, options) : void 0;
|
|
213
|
+
const vitePlugin = [vitePluginAdapter(adapter)];
|
|
214
|
+
if (ssrPlugin) {
|
|
215
|
+
vitePlugin.unshift(ssrPlugin);
|
|
216
|
+
}
|
|
189
217
|
return {
|
|
190
218
|
enforce: "after-user-plugins",
|
|
191
219
|
vitePlugin
|
|
@@ -199,7 +227,7 @@ function generateSSRCode(settings, adapter, middlewareId) {
|
|
|
199
227
|
const pageMap = isFunctionPerRouteEnabled(adapter) ? "pageModule" : "pageMap";
|
|
200
228
|
const imports = [
|
|
201
229
|
`import { renderers } from '${RENDERERS_MODULE_ID}';`,
|
|
202
|
-
`import * as serverEntrypointModule from '${
|
|
230
|
+
`import * as serverEntrypointModule from '${ADAPTER_VIRTUAL_MODULE_ID}';`,
|
|
203
231
|
`import { manifest as defaultManifest } from '${SSR_MANIFEST_VIRTUAL_MODULE_ID}';`,
|
|
204
232
|
edgeMiddleware ? `` : `import { onRequest as middleware } from '${middlewareId}';`,
|
|
205
233
|
settings.config.experimental.serverIslands ? `import { serverIslandMap } from '${VIRTUAL_ISLAND_MAP_ID}';` : ""
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
-
import type {
|
|
3
|
-
import type { AstroConfig, AstroInlineConfig, AstroUserConfig, CLIFlags } from '../../@types/astro.js';
|
|
4
|
-
/** Convert the generic "yargs" flag object into our own, custom TypeScript object. */
|
|
5
|
-
export declare function resolveFlags(flags: Partial<Flags>): CLIFlags;
|
|
2
|
+
import type { AstroConfig, AstroInlineConfig, AstroUserConfig } from '../../@types/astro.js';
|
|
6
3
|
export declare function resolveRoot(cwd?: string | URL): string;
|
|
7
4
|
export declare const configPaths: readonly string[];
|
|
8
5
|
interface ResolveConfigPathOptions {
|
|
9
6
|
root: string;
|
|
10
|
-
configFile?: string;
|
|
7
|
+
configFile?: string | false;
|
|
11
8
|
fs: typeof fs;
|
|
12
9
|
}
|
|
13
10
|
/**
|
|
@@ -10,17 +10,6 @@ import { formatConfigErrorMessage } from "../messages.js";
|
|
|
10
10
|
import { mergeConfig } from "./merge.js";
|
|
11
11
|
import { validateConfig } from "./validate.js";
|
|
12
12
|
import { loadConfigWithVite } from "./vite-load.js";
|
|
13
|
-
function resolveFlags(flags) {
|
|
14
|
-
return {
|
|
15
|
-
root: typeof flags.root === "string" ? flags.root : void 0,
|
|
16
|
-
site: typeof flags.site === "string" ? flags.site : void 0,
|
|
17
|
-
base: typeof flags.base === "string" ? flags.base : void 0,
|
|
18
|
-
port: typeof flags.port === "number" ? flags.port : void 0,
|
|
19
|
-
config: typeof flags.config === "string" ? flags.config : void 0,
|
|
20
|
-
host: typeof flags.host === "string" || typeof flags.host === "boolean" ? flags.host : void 0,
|
|
21
|
-
open: typeof flags.open === "string" || typeof flags.open === "boolean" ? flags.open : void 0
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
13
|
function resolveRoot(cwd) {
|
|
25
14
|
if (cwd instanceof URL) {
|
|
26
15
|
cwd = fileURLToPath(cwd);
|
|
@@ -115,6 +104,5 @@ export {
|
|
|
115
104
|
configPaths,
|
|
116
105
|
resolveConfig,
|
|
117
106
|
resolveConfigPath,
|
|
118
|
-
resolveFlags,
|
|
119
107
|
resolveRoot
|
|
120
108
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { configPaths, resolveConfig, resolveConfigPath,
|
|
1
|
+
export { configPaths, resolveConfig, resolveConfigPath, resolveRoot, } from './config.js';
|
|
2
2
|
export { createNodeLogger } from './logging.js';
|
|
3
3
|
export { mergeConfig } from './merge.js';
|
|
4
4
|
export type { AstroConfigType } from './schema.js';
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
configPaths,
|
|
3
3
|
resolveConfig,
|
|
4
4
|
resolveConfigPath,
|
|
5
|
-
resolveFlags,
|
|
6
5
|
resolveRoot
|
|
7
6
|
} from "./config.js";
|
|
8
7
|
import { createNodeLogger } from "./logging.js";
|
|
@@ -17,7 +16,6 @@ export {
|
|
|
17
16
|
mergeConfig,
|
|
18
17
|
resolveConfig,
|
|
19
18
|
resolveConfigPath,
|
|
20
|
-
resolveFlags,
|
|
21
19
|
resolveRoot,
|
|
22
20
|
updateTSConfigForFramework
|
|
23
21
|
};
|
|
@@ -57,9 +57,11 @@ export declare const ASTRO_CONFIG_DEFAULTS: {
|
|
|
57
57
|
clientPrerender: false;
|
|
58
58
|
globalRoutePriority: false;
|
|
59
59
|
serverIslands: false;
|
|
60
|
+
contentIntellisense: false;
|
|
60
61
|
env: {
|
|
61
62
|
validateSecrets: false;
|
|
62
63
|
};
|
|
64
|
+
contentLayer: false;
|
|
63
65
|
};
|
|
64
66
|
};
|
|
65
67
|
export declare const AstroConfigSchema: z.ZodObject<{
|
|
@@ -613,6 +615,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
613
615
|
})> | undefined;
|
|
614
616
|
}>>;
|
|
615
617
|
serverIslands: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
618
|
+
contentIntellisense: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
619
|
+
contentLayer: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
616
620
|
}, "strict", z.ZodTypeAny, {
|
|
617
621
|
actions: boolean;
|
|
618
622
|
directRenderScript: boolean;
|
|
@@ -620,6 +624,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
620
624
|
clientPrerender: boolean;
|
|
621
625
|
globalRoutePriority: boolean;
|
|
622
626
|
serverIslands: boolean;
|
|
627
|
+
contentIntellisense: boolean;
|
|
628
|
+
contentLayer: boolean;
|
|
623
629
|
env?: {
|
|
624
630
|
validateSecrets: boolean;
|
|
625
631
|
schema?: Record<string, ({
|
|
@@ -669,6 +675,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
669
675
|
clientPrerender?: boolean | undefined;
|
|
670
676
|
globalRoutePriority?: boolean | undefined;
|
|
671
677
|
serverIslands?: boolean | undefined;
|
|
678
|
+
contentIntellisense?: boolean | undefined;
|
|
679
|
+
contentLayer?: boolean | undefined;
|
|
672
680
|
env?: {
|
|
673
681
|
validateSecrets?: boolean | undefined;
|
|
674
682
|
schema?: Record<string, ({
|
|
@@ -796,6 +804,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
796
804
|
clientPrerender: boolean;
|
|
797
805
|
globalRoutePriority: boolean;
|
|
798
806
|
serverIslands: boolean;
|
|
807
|
+
contentIntellisense: boolean;
|
|
808
|
+
contentLayer: boolean;
|
|
799
809
|
env?: {
|
|
800
810
|
validateSecrets: boolean;
|
|
801
811
|
schema?: Record<string, ({
|
|
@@ -959,6 +969,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
959
969
|
clientPrerender?: boolean | undefined;
|
|
960
970
|
globalRoutePriority?: boolean | undefined;
|
|
961
971
|
serverIslands?: boolean | undefined;
|
|
972
|
+
contentIntellisense?: boolean | undefined;
|
|
973
|
+
contentLayer?: boolean | undefined;
|
|
962
974
|
env?: {
|
|
963
975
|
validateSecrets?: boolean | undefined;
|
|
964
976
|
schema?: Record<string, ({
|
|
@@ -1556,6 +1568,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
1556
1568
|
})> | undefined;
|
|
1557
1569
|
}>>;
|
|
1558
1570
|
serverIslands: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
1571
|
+
contentIntellisense: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
1572
|
+
contentLayer: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
1559
1573
|
}, "strict", z.ZodTypeAny, {
|
|
1560
1574
|
actions: boolean;
|
|
1561
1575
|
directRenderScript: boolean;
|
|
@@ -1563,6 +1577,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
1563
1577
|
clientPrerender: boolean;
|
|
1564
1578
|
globalRoutePriority: boolean;
|
|
1565
1579
|
serverIslands: boolean;
|
|
1580
|
+
contentIntellisense: boolean;
|
|
1581
|
+
contentLayer: boolean;
|
|
1566
1582
|
env?: {
|
|
1567
1583
|
validateSecrets: boolean;
|
|
1568
1584
|
schema?: Record<string, ({
|
|
@@ -1612,6 +1628,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
1612
1628
|
clientPrerender?: boolean | undefined;
|
|
1613
1629
|
globalRoutePriority?: boolean | undefined;
|
|
1614
1630
|
serverIslands?: boolean | undefined;
|
|
1631
|
+
contentIntellisense?: boolean | undefined;
|
|
1632
|
+
contentLayer?: boolean | undefined;
|
|
1615
1633
|
env?: {
|
|
1616
1634
|
validateSecrets?: boolean | undefined;
|
|
1617
1635
|
schema?: Record<string, ({
|
|
@@ -1814,6 +1832,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
1814
1832
|
clientPrerender: boolean;
|
|
1815
1833
|
globalRoutePriority: boolean;
|
|
1816
1834
|
serverIslands: boolean;
|
|
1835
|
+
contentIntellisense: boolean;
|
|
1836
|
+
contentLayer: boolean;
|
|
1817
1837
|
env?: {
|
|
1818
1838
|
validateSecrets: boolean;
|
|
1819
1839
|
schema?: Record<string, ({
|
|
@@ -1977,6 +1997,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
1977
1997
|
clientPrerender?: boolean | undefined;
|
|
1978
1998
|
globalRoutePriority?: boolean | undefined;
|
|
1979
1999
|
serverIslands?: boolean | undefined;
|
|
2000
|
+
contentIntellisense?: boolean | undefined;
|
|
2001
|
+
contentLayer?: boolean | undefined;
|
|
1980
2002
|
env?: {
|
|
1981
2003
|
validateSecrets?: boolean | undefined;
|
|
1982
2004
|
schema?: Record<string, ({
|
|
@@ -2105,6 +2127,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
2105
2127
|
clientPrerender: boolean;
|
|
2106
2128
|
globalRoutePriority: boolean;
|
|
2107
2129
|
serverIslands: boolean;
|
|
2130
|
+
contentIntellisense: boolean;
|
|
2131
|
+
contentLayer: boolean;
|
|
2108
2132
|
env?: {
|
|
2109
2133
|
validateSecrets: boolean;
|
|
2110
2134
|
schema?: Record<string, ({
|
|
@@ -2268,6 +2292,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
2268
2292
|
clientPrerender?: boolean | undefined;
|
|
2269
2293
|
globalRoutePriority?: boolean | undefined;
|
|
2270
2294
|
serverIslands?: boolean | undefined;
|
|
2295
|
+
contentIntellisense?: boolean | undefined;
|
|
2296
|
+
contentLayer?: boolean | undefined;
|
|
2271
2297
|
env?: {
|
|
2272
2298
|
validateSecrets?: boolean | undefined;
|
|
2273
2299
|
schema?: Record<string, ({
|
|
@@ -2396,6 +2422,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
2396
2422
|
clientPrerender: boolean;
|
|
2397
2423
|
globalRoutePriority: boolean;
|
|
2398
2424
|
serverIslands: boolean;
|
|
2425
|
+
contentIntellisense: boolean;
|
|
2426
|
+
contentLayer: boolean;
|
|
2399
2427
|
env?: {
|
|
2400
2428
|
validateSecrets: boolean;
|
|
2401
2429
|
schema?: Record<string, ({
|
|
@@ -2559,6 +2587,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
2559
2587
|
clientPrerender?: boolean | undefined;
|
|
2560
2588
|
globalRoutePriority?: boolean | undefined;
|
|
2561
2589
|
serverIslands?: boolean | undefined;
|
|
2590
|
+
contentIntellisense?: boolean | undefined;
|
|
2591
|
+
contentLayer?: boolean | undefined;
|
|
2562
2592
|
env?: {
|
|
2563
2593
|
validateSecrets?: boolean | undefined;
|
|
2564
2594
|
schema?: Record<string, ({
|
|
@@ -2687,6 +2717,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
2687
2717
|
clientPrerender: boolean;
|
|
2688
2718
|
globalRoutePriority: boolean;
|
|
2689
2719
|
serverIslands: boolean;
|
|
2720
|
+
contentIntellisense: boolean;
|
|
2721
|
+
contentLayer: boolean;
|
|
2690
2722
|
env?: {
|
|
2691
2723
|
validateSecrets: boolean;
|
|
2692
2724
|
schema?: Record<string, ({
|
|
@@ -2850,6 +2882,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
2850
2882
|
clientPrerender?: boolean | undefined;
|
|
2851
2883
|
globalRoutePriority?: boolean | undefined;
|
|
2852
2884
|
serverIslands?: boolean | undefined;
|
|
2885
|
+
contentIntellisense?: boolean | undefined;
|
|
2886
|
+
contentLayer?: boolean | undefined;
|
|
2853
2887
|
env?: {
|
|
2854
2888
|
validateSecrets?: boolean | undefined;
|
|
2855
2889
|
schema?: Record<string, ({
|
|
@@ -47,9 +47,11 @@ const ASTRO_CONFIG_DEFAULTS = {
|
|
|
47
47
|
clientPrerender: false,
|
|
48
48
|
globalRoutePriority: false,
|
|
49
49
|
serverIslands: false,
|
|
50
|
+
contentIntellisense: false,
|
|
50
51
|
env: {
|
|
51
52
|
validateSecrets: false
|
|
52
|
-
}
|
|
53
|
+
},
|
|
54
|
+
contentLayer: false
|
|
53
55
|
}
|
|
54
56
|
};
|
|
55
57
|
const AstroConfigSchema = z.object({
|
|
@@ -332,7 +334,9 @@ const AstroConfigSchema = z.object({
|
|
|
332
334
|
schema: EnvSchema.optional(),
|
|
333
335
|
validateSecrets: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.env.validateSecrets)
|
|
334
336
|
}).strict().optional(),
|
|
335
|
-
serverIslands: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.serverIslands)
|
|
337
|
+
serverIslands: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.serverIslands),
|
|
338
|
+
contentIntellisense: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.contentIntellisense),
|
|
339
|
+
contentLayer: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.contentLayer)
|
|
336
340
|
}).strict(
|
|
337
341
|
`Invalid or outdated experimental feature.
|
|
338
342
|
Check for incorrect spelling or outdated Astro version.
|
|
@@ -12,7 +12,8 @@ import { AstroTimer } from "./timer.js";
|
|
|
12
12
|
import { loadTSConfig } from "./tsconfig.js";
|
|
13
13
|
function createBaseSettings(config) {
|
|
14
14
|
const { contentDir } = getContentPaths(config);
|
|
15
|
-
const
|
|
15
|
+
const dotAstroDir = new URL(".astro/", config.root);
|
|
16
|
+
const preferences = createPreferences(config, dotAstroDir);
|
|
16
17
|
return {
|
|
17
18
|
config,
|
|
18
19
|
preferences,
|
|
@@ -94,9 +95,10 @@ function createBaseSettings(config) {
|
|
|
94
95
|
watchFiles: [],
|
|
95
96
|
devToolbarApps: [],
|
|
96
97
|
timer: new AstroTimer(),
|
|
97
|
-
dotAstroDir
|
|
98
|
-
latestAstroVersion: void 0
|
|
98
|
+
dotAstroDir,
|
|
99
|
+
latestAstroVersion: void 0,
|
|
99
100
|
// Will be set later if applicable when the dev server starts
|
|
101
|
+
injectedTypes: []
|
|
100
102
|
};
|
|
101
103
|
}
|
|
102
104
|
async function createSettings(config, cwd) {
|
package/dist/core/constants.js
CHANGED
package/dist/core/create-vite.js
CHANGED
|
@@ -102,7 +102,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
|
|
102
102
|
// The server plugin is for dev only and having it run during the build causes
|
|
103
103
|
// the build to run very slow as the filewatcher is triggered often.
|
|
104
104
|
mode !== "build" && vitePluginAstroServer({ settings, logger, fs }),
|
|
105
|
-
envVitePlugin({ settings }),
|
|
105
|
+
envVitePlugin({ settings, logger }),
|
|
106
106
|
astroEnv({ settings, mode, fs, sync }),
|
|
107
107
|
markdownVitePlugin({ settings, logger }),
|
|
108
108
|
htmlVitePlugin(),
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
1
|
+
import fs, { existsSync } from "node:fs";
|
|
2
|
+
import { performance } from "node:perf_hooks";
|
|
2
3
|
import { green } from "kleur/colors";
|
|
3
|
-
import { performance } from "perf_hooks";
|
|
4
4
|
import { gt, major, minor, patch } from "semver";
|
|
5
|
+
import { DATA_STORE_FILE } from "../../content/consts.js";
|
|
6
|
+
import { globalContentLayer } from "../../content/content-layer.js";
|
|
5
7
|
import { attachContentServerListeners } from "../../content/index.js";
|
|
8
|
+
import { MutableDataStore } from "../../content/mutable-data-store.js";
|
|
9
|
+
import { globalContentConfigObserver } from "../../content/utils.js";
|
|
6
10
|
import { telemetry } from "../../events/index.js";
|
|
7
11
|
import * as msg from "../messages.js";
|
|
8
12
|
import { ensureProcessNodeEnv } from "../util.js";
|
|
@@ -19,7 +23,7 @@ async function dev(inlineConfig) {
|
|
|
19
23
|
await telemetry.record([]);
|
|
20
24
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
21
25
|
const logger = restart.container.logger;
|
|
22
|
-
const currentVersion = "4.
|
|
26
|
+
const currentVersion = "4.14.1";
|
|
23
27
|
const isPrerelease = currentVersion.includes("-");
|
|
24
28
|
if (!isPrerelease) {
|
|
25
29
|
try {
|
|
@@ -64,6 +68,32 @@ async function dev(inlineConfig) {
|
|
|
64
68
|
logger.warn("SKIP_FORMAT", msg.fsStrictWarning());
|
|
65
69
|
}
|
|
66
70
|
await attachContentServerListeners(restart.container);
|
|
71
|
+
let store;
|
|
72
|
+
try {
|
|
73
|
+
const dataStoreFile = new URL(DATA_STORE_FILE, restart.container.settings.config.cacheDir);
|
|
74
|
+
if (existsSync(dataStoreFile)) {
|
|
75
|
+
store = await MutableDataStore.fromFile(dataStoreFile);
|
|
76
|
+
}
|
|
77
|
+
} catch (err) {
|
|
78
|
+
logger.error("content", err.message);
|
|
79
|
+
}
|
|
80
|
+
if (!store) {
|
|
81
|
+
store = new MutableDataStore();
|
|
82
|
+
}
|
|
83
|
+
const config = globalContentConfigObserver.get();
|
|
84
|
+
if (config.status === "error") {
|
|
85
|
+
logger.error("content", config.error.message);
|
|
86
|
+
}
|
|
87
|
+
if (config.status === "loaded") {
|
|
88
|
+
const contentLayer = globalContentLayer.init({
|
|
89
|
+
settings: restart.container.settings,
|
|
90
|
+
logger,
|
|
91
|
+
watcher: restart.container.viteServer.watcher,
|
|
92
|
+
store
|
|
93
|
+
});
|
|
94
|
+
contentLayer.watchContentConfig();
|
|
95
|
+
await contentLayer.sync();
|
|
96
|
+
}
|
|
67
97
|
logger.info(null, green("watching for file changes..."));
|
|
68
98
|
return {
|
|
69
99
|
address: devServerAddressInfo,
|