astro 2.0.7 → 2.0.9
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/cli/sync/index.js +4 -0
- package/dist/content/types-generator.js +13 -5
- package/dist/content/utils.d.ts +4 -1
- package/dist/content/vite-plugin-content-imports.js +3 -0
- package/dist/core/build/graph.js +7 -1
- package/dist/core/build/plugins/plugin-internals.js +9 -3
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/package.json +1 -1
package/dist/cli/sync/index.js
CHANGED
|
@@ -29,6 +29,10 @@ async function sync(settings, { logging, fs }) {
|
|
|
29
29
|
viteServer: tempViteServer
|
|
30
30
|
});
|
|
31
31
|
const typesResult = await contentTypesGenerator.init();
|
|
32
|
+
const contentConfig = globalContentConfigObserver.get();
|
|
33
|
+
if (contentConfig.status === "error") {
|
|
34
|
+
throw contentConfig.error;
|
|
35
|
+
}
|
|
32
36
|
if (typesResult.typesGenerated === false) {
|
|
33
37
|
switch (typesResult.reason) {
|
|
34
38
|
case "no-content-dir":
|
|
@@ -3,6 +3,7 @@ import { cyan } from "kleur/colors";
|
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
5
|
import { normalizePath } from "vite";
|
|
6
|
+
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
6
7
|
import { info, warn } from "../core/logger/core.js";
|
|
7
8
|
import { isRelativePath } from "../core/path.js";
|
|
8
9
|
import { CONTENT_TYPES_FILE } from "./consts.js";
|
|
@@ -79,11 +80,18 @@ async function createContentTypesGenerator({
|
|
|
79
80
|
}
|
|
80
81
|
if (fileType === "config") {
|
|
81
82
|
contentConfigObserver.set({ status: "loading" });
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
try {
|
|
84
|
+
const config = await loadContentConfig({ fs, settings, viteServer });
|
|
85
|
+
if (config) {
|
|
86
|
+
contentConfigObserver.set({ status: "loaded", config });
|
|
87
|
+
} else {
|
|
88
|
+
contentConfigObserver.set({ status: "does-not-exist" });
|
|
89
|
+
}
|
|
90
|
+
} catch (e) {
|
|
91
|
+
contentConfigObserver.set({
|
|
92
|
+
status: "error",
|
|
93
|
+
error: e instanceof Error ? e : new AstroError(AstroErrorData.UnknownContentCollectionError)
|
|
94
|
+
});
|
|
87
95
|
}
|
|
88
96
|
return { shouldGenerateTypes: true };
|
|
89
97
|
}
|
package/dist/content/utils.d.ts
CHANGED
|
@@ -83,10 +83,13 @@ type ContentCtx = {
|
|
|
83
83
|
} | {
|
|
84
84
|
status: 'loading';
|
|
85
85
|
} | {
|
|
86
|
-
status: '
|
|
86
|
+
status: 'does-not-exist';
|
|
87
87
|
} | {
|
|
88
88
|
status: 'loaded';
|
|
89
89
|
config: ContentConfig;
|
|
90
|
+
} | {
|
|
91
|
+
status: 'error';
|
|
92
|
+
error: Error;
|
|
90
93
|
};
|
|
91
94
|
type Observable<C> = {
|
|
92
95
|
get: () => C;
|
|
@@ -34,6 +34,9 @@ function astroContentImportPlugin({
|
|
|
34
34
|
message: "Content config failed to load."
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
+
if (observable.status === "error") {
|
|
38
|
+
throw observable.error;
|
|
39
|
+
}
|
|
37
40
|
let contentConfig = observable.status === "loaded" ? observable.config : void 0;
|
|
38
41
|
if (observable.status === "loading") {
|
|
39
42
|
contentConfig = await new Promise((resolve) => {
|
package/dist/core/build/graph.js
CHANGED
|
@@ -4,7 +4,13 @@ function* walkParentInfos(id, ctx, until, depth = 0, order = 0, seen = /* @__PUR
|
|
|
4
4
|
const info = ctx.getModuleInfo(id);
|
|
5
5
|
if (info) {
|
|
6
6
|
if (childId) {
|
|
7
|
-
|
|
7
|
+
const idx = info.importedIds.indexOf(childId);
|
|
8
|
+
if (idx === -1) {
|
|
9
|
+
order += info.importedIds.length;
|
|
10
|
+
order += info.dynamicallyImportedIds.indexOf(childId);
|
|
11
|
+
} else {
|
|
12
|
+
order += idx;
|
|
13
|
+
}
|
|
8
14
|
}
|
|
9
15
|
yield [info, depth, order];
|
|
10
16
|
}
|
|
@@ -29,7 +29,11 @@ function vitePluginInternals(input, internals) {
|
|
|
29
29
|
promises.push(
|
|
30
30
|
this.resolve(specifier).then((result) => {
|
|
31
31
|
if (result) {
|
|
32
|
-
mapping.
|
|
32
|
+
if (mapping.has(result.id)) {
|
|
33
|
+
mapping.get(result.id).add(specifier);
|
|
34
|
+
} else {
|
|
35
|
+
mapping.set(result.id, /* @__PURE__ */ new Set([specifier]));
|
|
36
|
+
}
|
|
33
37
|
}
|
|
34
38
|
})
|
|
35
39
|
);
|
|
@@ -37,8 +41,10 @@ function vitePluginInternals(input, internals) {
|
|
|
37
41
|
await Promise.all(promises);
|
|
38
42
|
for (const [, chunk] of Object.entries(bundle)) {
|
|
39
43
|
if (chunk.type === "chunk" && chunk.facadeModuleId) {
|
|
40
|
-
const
|
|
41
|
-
|
|
44
|
+
const specifiers = mapping.get(chunk.facadeModuleId) || /* @__PURE__ */ new Set([chunk.facadeModuleId]);
|
|
45
|
+
for (const specifier of specifiers) {
|
|
46
|
+
internals.entrySpecifierToBundleMap.set(specifier, chunk.fileName);
|
|
47
|
+
}
|
|
42
48
|
} else if (chunk.type === "chunk") {
|
|
43
49
|
for (const id of Object.keys(chunk.modules)) {
|
|
44
50
|
const pageData = internals.pagesByViteID.get(id);
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -30,7 +30,7 @@ async function dev(settings, options) {
|
|
|
30
30
|
isRestart: options.isRestart
|
|
31
31
|
})
|
|
32
32
|
);
|
|
33
|
-
const currentVersion = "2.0.
|
|
33
|
+
const currentVersion = "2.0.9";
|
|
34
34
|
if (currentVersion.includes("-")) {
|
|
35
35
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
36
36
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function serverStart({
|
|
|
47
47
|
base,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "2.0.
|
|
50
|
+
const version = "2.0.9";
|
|
51
51
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
52
52
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
53
53
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -233,7 +233,7 @@ function printHelp({
|
|
|
233
233
|
message.push(
|
|
234
234
|
linebreak(),
|
|
235
235
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
236
|
-
`v${"2.0.
|
|
236
|
+
`v${"2.0.9"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|