astro 7.0.0-beta.4 → 7.0.0-beta.6
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/infra/build-time-astro-version-provider.js +1 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/core/app/prepare-response.d.ts +2 -3
- package/dist/core/app/prepare-response.js +1 -6
- package/dist/core/build/generate.js +1 -1
- package/dist/core/build/plugins/plugin-manifest.js +1 -4
- package/dist/core/build/vite-build-config.js +6 -0
- package/dist/core/cache/config.d.ts +7 -6
- package/dist/core/cache/runtime/noop.js +1 -1
- package/dist/core/cache/utils.d.ts +3 -3
- package/dist/core/cache/vite-plugin.js +1 -1
- package/dist/core/config/schemas/base.d.ts +13 -13
- package/dist/core/config/schemas/base.js +4 -4
- package/dist/core/config/schemas/relative.d.ts +36 -36
- package/dist/core/constants.d.ts +0 -41
- package/dist/core/constants.js +1 -18
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/default-handler.js +1 -0
- package/dist/core/errors/errors-data.js +2 -2
- package/dist/core/fetch/fetch-state.d.ts +11 -0
- package/dist/core/fetch/fetch-state.js +19 -1
- package/dist/core/fetch/index.d.ts +8 -3
- package/dist/core/fetch/index.js +2 -2
- package/dist/core/i18n/handler.js +7 -13
- package/dist/core/messages/runtime.js +1 -1
- package/dist/core/middleware/astro-middleware.d.ts +19 -0
- package/dist/core/middleware/astro-middleware.js +43 -0
- package/dist/core/middleware/noop-middleware.js +0 -2
- package/dist/core/pages/handler.d.ts +13 -0
- package/dist/core/pages/handler.js +35 -14
- package/dist/core/routing/handler.js +6 -8
- package/dist/core/routing/rewrite.js +2 -1
- package/dist/core/util/pathname.d.ts +17 -16
- package/dist/core/util/pathname.js +6 -2
- package/dist/i18n/index.js +5 -7
- package/dist/manifest/serialized.js +2 -5
- package/dist/runtime/server/endpoint.d.ts +2 -1
- package/dist/runtime/server/endpoint.js +4 -13
- package/dist/types/public/config.d.ts +85 -83
- package/dist/virtual-modules/container.d.ts +1 -1
- package/dist/vite-plugin-config-alias/index.d.ts +2 -2
- package/dist/vite-plugin-config-alias/index.js +66 -61
- package/dist/vite-plugin-head/index.js +5 -11
- package/package.json +6 -6
- package/templates/content/module.mjs +0 -1
- package/dist/core/head-propagation/hint.d.ts +0 -4
- package/dist/core/head-propagation/hint.js +0 -7
|
@@ -31,81 +31,86 @@ const getConfigAlias = (settings) => {
|
|
|
31
31
|
}
|
|
32
32
|
return aliases;
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (paths) {
|
|
43
|
-
for (const [aliasPattern, values] of Object.entries(paths)) {
|
|
44
|
-
const resolvedValues = values.map((v) => path.resolve(resolvedBaseUrl, v));
|
|
45
|
-
const customResolver = (id) => {
|
|
46
|
-
for (const resolvedValue of resolvedValues) {
|
|
47
|
-
const resolved = resolvedValue.replace("*", id);
|
|
48
|
-
const stats = fs.statSync(resolved, { throwIfNoEntry: false });
|
|
49
|
-
if (stats && stats.isFile()) {
|
|
50
|
-
return normalizePath(resolved);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return null;
|
|
54
|
-
};
|
|
55
|
-
aliases.push({
|
|
56
|
-
// Build regex from alias pattern (e.g., '@styles/*' -> /^@styles\/(.+)$/)
|
|
57
|
-
// First, escape special regex chars. Then replace * with a capture group (.+)
|
|
58
|
-
find: new RegExp(
|
|
59
|
-
`^${aliasPattern.replace(/[\\^$+?.()|[\]{}]/g, "\\$&").replace(/\*/g, "(.+)")}$`
|
|
60
|
-
),
|
|
61
|
-
replacement: aliasPattern.includes("*") ? "$1" : aliasPattern,
|
|
62
|
-
customResolver
|
|
63
|
-
});
|
|
34
|
+
function resolveWithAlias(id, configAlias) {
|
|
35
|
+
for (const alias of configAlias) {
|
|
36
|
+
if (alias.find.test(id)) {
|
|
37
|
+
const updatedId = id.replace(alias.find, alias.replacement);
|
|
38
|
+
const stats = fs.statSync(updatedId, { throwIfNoEntry: false });
|
|
39
|
+
if (stats && stats.isFile()) {
|
|
40
|
+
return normalizePath(updatedId);
|
|
41
|
+
}
|
|
64
42
|
}
|
|
65
43
|
}
|
|
66
|
-
return
|
|
67
|
-
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const cssImportRE = /@import\s+(?:url\(\s*)?['"]([^'"]+)['"]\s*\)?/g;
|
|
68
47
|
function configAliasVitePlugin({
|
|
69
48
|
settings
|
|
70
49
|
}) {
|
|
71
50
|
const configAlias = getConfigAlias(settings);
|
|
72
51
|
if (!configAlias) return null;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
52
|
+
return [
|
|
53
|
+
// Pre-plugin: rewrite CSS @import aliases to absolute paths before Vite's CSS plugin.
|
|
54
|
+
// Vite's internal CSS @import resolver (postcss-import) uses a mini plugin container
|
|
55
|
+
// that doesn't include user resolveId hooks, so we must rewrite aliases in a transform
|
|
56
|
+
// hook that runs before Vite's CSS processing.
|
|
57
|
+
{
|
|
58
|
+
name: "astro:tsconfig-alias-css",
|
|
59
|
+
enforce: "pre",
|
|
60
|
+
transform: {
|
|
61
|
+
filter: {
|
|
62
|
+
id: {
|
|
63
|
+
include: /\.css$/
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
handler(code) {
|
|
67
|
+
if (!code.includes("@import")) return;
|
|
68
|
+
let hasReplacement = false;
|
|
69
|
+
const result = code.replace(cssImportRE, (match, importId) => {
|
|
70
|
+
if (!importId) return match;
|
|
71
|
+
const resolved = resolveWithAlias(importId, configAlias);
|
|
72
|
+
if (resolved) {
|
|
73
|
+
hasReplacement = true;
|
|
74
|
+
return match.replace(importId, resolved);
|
|
75
|
+
}
|
|
76
|
+
return match;
|
|
77
|
+
});
|
|
78
|
+
if (hasReplacement) {
|
|
79
|
+
return { code: result, map: null };
|
|
80
|
+
}
|
|
81
81
|
}
|
|
82
|
-
}
|
|
82
|
+
}
|
|
83
83
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
84
|
+
// Post-plugin: resolve JS/TS imports using tsconfig path aliases via resolveId.
|
|
85
|
+
{
|
|
86
|
+
name: "astro:tsconfig-alias",
|
|
87
|
+
// use post to only resolve ids that all other plugins before it can't
|
|
88
|
+
enforce: "post",
|
|
89
|
+
resolveId: {
|
|
90
|
+
filter: {
|
|
91
|
+
id: {
|
|
92
|
+
include: configAlias.map((alias) => alias.find),
|
|
93
|
+
exclude: /(?:\0|^virtual:|^astro:)/
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
async handler(id, importer, options) {
|
|
97
|
+
for (const alias of configAlias) {
|
|
98
|
+
if (alias.find.test(id)) {
|
|
99
|
+
const updatedId = id.replace(alias.find, alias.replacement);
|
|
100
|
+
if (updatedId.includes("*")) {
|
|
101
|
+
return updatedId;
|
|
102
|
+
}
|
|
103
|
+
const resolved = await this.resolve(updatedId, importer, {
|
|
104
|
+
skipSelf: true,
|
|
105
|
+
...options
|
|
106
|
+
});
|
|
107
|
+
if (resolved) return resolved;
|
|
97
108
|
}
|
|
98
|
-
const resolved = await this.resolve(updatedId, importer, {
|
|
99
|
-
skipSelf: true,
|
|
100
|
-
...options
|
|
101
|
-
});
|
|
102
|
-
if (resolved) return resolved;
|
|
103
109
|
}
|
|
104
110
|
}
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
|
-
|
|
108
|
-
return plugin;
|
|
113
|
+
];
|
|
109
114
|
}
|
|
110
115
|
export {
|
|
111
116
|
configAliasVitePlugin as default
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { hasHeadPropagationCall } from "../core/head-propagation/hint.js";
|
|
2
1
|
import {
|
|
3
2
|
buildImporterGraphFromModuleInfo,
|
|
4
3
|
computeInTreeAncestors
|
|
5
4
|
} from "../core/head-propagation/graph.js";
|
|
6
5
|
import { getTopLevelPageModuleInfos } from "../core/build/graph.js";
|
|
6
|
+
import { PROPAGATED_ASSET_FLAG } from "../content/consts.js";
|
|
7
7
|
import { getAstroMetadata } from "../vite-plugin-astro/index.js";
|
|
8
8
|
import { ASTRO_VITE_ENVIRONMENT_NAMES } from "../core/constants.js";
|
|
9
9
|
const VIRTUAL_COMPONENT_METADATA = "virtual:astro:component-metadata";
|
|
@@ -127,12 +127,12 @@ function configHeadVitePlugin() {
|
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
},
|
|
130
|
-
transform(
|
|
130
|
+
transform(_source, id) {
|
|
131
131
|
let info = this.getModuleInfo(id);
|
|
132
132
|
if (info && getAstroMetadata(info)?.containsHead) {
|
|
133
133
|
propagateMetadata.call(this, id, "containsHead", true);
|
|
134
134
|
}
|
|
135
|
-
if (
|
|
135
|
+
if (id.includes(PROPAGATED_ASSET_FLAG)) {
|
|
136
136
|
propagateMetadata.call(this, id, "propagation", "in-tree");
|
|
137
137
|
}
|
|
138
138
|
invalidateComponentMetadataModule();
|
|
@@ -140,17 +140,11 @@ function configHeadVitePlugin() {
|
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
function astroHeadBuildPlugin(internals) {
|
|
143
|
-
const headPropagationModuleIds = /* @__PURE__ */ new Set();
|
|
144
143
|
return {
|
|
145
144
|
name: "astro:head-metadata-build",
|
|
146
145
|
applyToEnvironment(environment) {
|
|
147
146
|
return environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr || environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.prerender;
|
|
148
147
|
},
|
|
149
|
-
transform(source, id) {
|
|
150
|
-
if (hasHeadPropagationCall(source)) {
|
|
151
|
-
headPropagationModuleIds.add(id);
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
148
|
generateBundle(_opts, bundle) {
|
|
155
149
|
const map = internals.componentMetadata;
|
|
156
150
|
const moduleIds = /* @__PURE__ */ new Set();
|
|
@@ -167,7 +161,7 @@ function astroHeadBuildPlugin(internals) {
|
|
|
167
161
|
}
|
|
168
162
|
for (const [, output] of Object.entries(bundle)) {
|
|
169
163
|
if (output.type !== "chunk") continue;
|
|
170
|
-
for (const [id
|
|
164
|
+
for (const [id] of Object.entries(output.modules)) {
|
|
171
165
|
moduleIds.add(id);
|
|
172
166
|
const modinfo = this.getModuleInfo(id);
|
|
173
167
|
if (modinfo) {
|
|
@@ -182,7 +176,7 @@ function astroHeadBuildPlugin(internals) {
|
|
|
182
176
|
selfPropagationSeeds.add(id);
|
|
183
177
|
}
|
|
184
178
|
}
|
|
185
|
-
if (
|
|
179
|
+
if (id.includes(PROPAGATED_ASSET_FLAG)) {
|
|
186
180
|
commentPropagationSeeds.add(id);
|
|
187
181
|
}
|
|
188
182
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.6",
|
|
4
4
|
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "withastro",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"README.md"
|
|
113
113
|
],
|
|
114
114
|
"dependencies": {
|
|
115
|
-
"@astrojs/compiler-rs": "^0.
|
|
115
|
+
"@astrojs/compiler-rs": "^0.2.2",
|
|
116
116
|
"@capsizecss/unpack": "^4.0.0",
|
|
117
117
|
"@clack/prompts": "^1.1.0",
|
|
118
118
|
"@oslojs/encoding": "^1.1.0",
|
|
@@ -166,8 +166,8 @@
|
|
|
166
166
|
"yargs-parser": "^22.0.0",
|
|
167
167
|
"zod": "^4.3.6",
|
|
168
168
|
"@astrojs/internal-helpers": "0.10.0",
|
|
169
|
-
"@astrojs/
|
|
170
|
-
"@astrojs/
|
|
169
|
+
"@astrojs/markdown-satteri": "0.3.1-beta.2",
|
|
170
|
+
"@astrojs/telemetry": "3.3.2"
|
|
171
171
|
},
|
|
172
172
|
"optionalDependencies": {
|
|
173
173
|
"sharp": "^0.34.0"
|
|
@@ -208,8 +208,8 @@
|
|
|
208
208
|
"unified": "^11.0.5",
|
|
209
209
|
"vitest": "^4.1.0",
|
|
210
210
|
"@astrojs/check": "0.9.9",
|
|
211
|
-
"
|
|
212
|
-
"
|
|
211
|
+
"@astrojs/markdown-remark": "7.2.0",
|
|
212
|
+
"astro-scripts": "0.0.14"
|
|
213
213
|
},
|
|
214
214
|
"engines": {
|
|
215
215
|
"node": ">=22.12.0",
|