astro 5.5.0 → 5.5.2
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/content/content-layer.js +3 -3
- package/dist/core/build/plugins/plugin-css.js +27 -1
- package/dist/core/build/static-build.js +1 -9
- 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/session.js +6 -0
- package/dist/types/public/config.d.ts +1 -1
- package/dist/vite-plugin-astro/index.d.ts +2 -2
- package/dist/vite-plugin-astro/index.js +9 -3
- package/dist/vite-plugin-astro/types.d.ts +20 -0
- package/package.json +1 -1
|
@@ -153,7 +153,7 @@ ${contentConfig.error.message}`);
|
|
|
153
153
|
logger.info("Content config changed");
|
|
154
154
|
shouldClear = true;
|
|
155
155
|
}
|
|
156
|
-
if (previousAstroVersion && previousAstroVersion !== "5.5.
|
|
156
|
+
if (previousAstroVersion && previousAstroVersion !== "5.5.2") {
|
|
157
157
|
logger.info("Astro version changed");
|
|
158
158
|
shouldClear = true;
|
|
159
159
|
}
|
|
@@ -161,8 +161,8 @@ ${contentConfig.error.message}`);
|
|
|
161
161
|
logger.info("Clearing content store");
|
|
162
162
|
this.#store.clearAll();
|
|
163
163
|
}
|
|
164
|
-
if ("5.5.
|
|
165
|
-
await this.#store.metaStore().set("astro-version", "5.5.
|
|
164
|
+
if ("5.5.2") {
|
|
165
|
+
await this.#store.metaStore().set("astro-version", "5.5.2");
|
|
166
166
|
}
|
|
167
167
|
if (currentConfigDigest) {
|
|
168
168
|
await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
|
@@ -101,6 +101,22 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
|
+
const cssScopeToPlugin = {
|
|
105
|
+
name: "astro:rollup-plugin-css-scope-to",
|
|
106
|
+
renderChunk(_, chunk, __, meta) {
|
|
107
|
+
for (const id in chunk.modules) {
|
|
108
|
+
const modMeta = this.getModuleInfo(id)?.meta;
|
|
109
|
+
const cssScopeTo = modMeta?.astroCss?.cssScopeTo;
|
|
110
|
+
if (cssScopeTo && !isCssScopeToRendered(cssScopeTo, Object.values(meta.chunks))) {
|
|
111
|
+
delete chunk.modules[id];
|
|
112
|
+
const moduleIdsIndex = chunk.moduleIds.indexOf(id);
|
|
113
|
+
if (moduleIdsIndex > -1) {
|
|
114
|
+
chunk.moduleIds.splice(moduleIdsIndex, 1);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
104
120
|
const singleCssPlugin = {
|
|
105
121
|
name: "astro:rollup-plugin-single-css",
|
|
106
122
|
enforce: "post",
|
|
@@ -162,7 +178,7 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
162
178
|
});
|
|
163
179
|
}
|
|
164
180
|
};
|
|
165
|
-
return [cssBuildPlugin, singleCssPlugin, inlineStylesheetsPlugin];
|
|
181
|
+
return [cssBuildPlugin, cssScopeToPlugin, singleCssPlugin, inlineStylesheetsPlugin];
|
|
166
182
|
}
|
|
167
183
|
function* getParentClientOnlys(id, ctx, internals) {
|
|
168
184
|
for (const info of getParentModuleInfos(id, ctx)) {
|
|
@@ -187,6 +203,16 @@ function appendCSSToPage(pageData, meta, pagesToCss, depth, order) {
|
|
|
187
203
|
}
|
|
188
204
|
}
|
|
189
205
|
}
|
|
206
|
+
function isCssScopeToRendered(cssScopeTo, chunks) {
|
|
207
|
+
for (const moduleId in cssScopeTo) {
|
|
208
|
+
const exports = cssScopeTo[moduleId];
|
|
209
|
+
const renderedModule = chunks.find((c) => c.moduleIds.includes(moduleId))?.modules[moduleId];
|
|
210
|
+
if (renderedModule?.renderedExports.some((e) => exports.includes(e))) {
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
190
216
|
export {
|
|
191
217
|
pluginCSS
|
|
192
218
|
};
|
|
@@ -137,15 +137,7 @@ async function ssrBuild(opts, internals, input, container) {
|
|
|
137
137
|
const encoded = encodeName(name);
|
|
138
138
|
return [prefix, encoded, suffix].join("");
|
|
139
139
|
},
|
|
140
|
-
assetFileNames
|
|
141
|
-
const { names } = chunkInfo;
|
|
142
|
-
const name = names[0] ?? "";
|
|
143
|
-
if (name.includes(ASTRO_PAGE_EXTENSION_POST_PATTERN)) {
|
|
144
|
-
const [sanitizedName] = name.split(ASTRO_PAGE_EXTENSION_POST_PATTERN);
|
|
145
|
-
return `${settings.config.build.assets}/${sanitizedName}.[hash][extname]`;
|
|
146
|
-
}
|
|
147
|
-
return `${settings.config.build.assets}/[name].[hash][extname]`;
|
|
148
|
-
},
|
|
140
|
+
assetFileNames: `${settings.config.build.assets}/[name].[hash][extname]`,
|
|
149
141
|
...viteConfig.build?.rollupOptions?.output,
|
|
150
142
|
entryFileNames(chunkInfo) {
|
|
151
143
|
if (chunkInfo.facadeModuleId?.startsWith(ASTRO_PAGE_RESOLVED_MODULE_ID)) {
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
|
|
|
22
22
|
await telemetry.record([]);
|
|
23
23
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
24
24
|
const logger = restart.container.logger;
|
|
25
|
-
const currentVersion = "5.5.
|
|
25
|
+
const currentVersion = "5.5.2";
|
|
26
26
|
const isPrerelease = currentVersion.includes("-");
|
|
27
27
|
if (!isPrerelease) {
|
|
28
28
|
try {
|
package/dist/core/messages.js
CHANGED
|
@@ -38,7 +38,7 @@ function serverStart({
|
|
|
38
38
|
host,
|
|
39
39
|
base
|
|
40
40
|
}) {
|
|
41
|
-
const version = "5.5.
|
|
41
|
+
const version = "5.5.2";
|
|
42
42
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
43
43
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
44
44
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -282,7 +282,7 @@ function printHelp({
|
|
|
282
282
|
message.push(
|
|
283
283
|
linebreak(),
|
|
284
284
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
285
|
-
`v${"5.5.
|
|
285
|
+
`v${"5.5.2"}`
|
|
286
286
|
)} ${headline}`
|
|
287
287
|
);
|
|
288
288
|
}
|
package/dist/core/session.js
CHANGED
|
@@ -53,6 +53,7 @@ class AstroSession {
|
|
|
53
53
|
// When we load the data from storage, we need to merge it with the local partial data,
|
|
54
54
|
// preserving in-memory changes and deletions.
|
|
55
55
|
#partial = true;
|
|
56
|
+
static #sharedStorage = /* @__PURE__ */ new Map();
|
|
56
57
|
constructor(cookies, {
|
|
57
58
|
cookie: cookieConfig = DEFAULT_COOKIE_NAME,
|
|
58
59
|
...config
|
|
@@ -314,6 +315,10 @@ class AstroSession {
|
|
|
314
315
|
if (this.#storage) {
|
|
315
316
|
return this.#storage;
|
|
316
317
|
}
|
|
318
|
+
if (AstroSession.#sharedStorage.has(this.#config.driver)) {
|
|
319
|
+
this.#storage = AstroSession.#sharedStorage.get(this.#config.driver);
|
|
320
|
+
return this.#storage;
|
|
321
|
+
}
|
|
317
322
|
if (this.#config.driver === "test") {
|
|
318
323
|
this.#storage = this.#config.options.mockStorage;
|
|
319
324
|
return this.#storage;
|
|
@@ -367,6 +372,7 @@ class AstroSession {
|
|
|
367
372
|
this.#storage = createStorage({
|
|
368
373
|
driver: driver(this.#config.options)
|
|
369
374
|
});
|
|
375
|
+
AstroSession.#sharedStorage.set(this.#config.driver, this.#storage);
|
|
370
376
|
return this.#storage;
|
|
371
377
|
} catch (err) {
|
|
372
378
|
throw new AstroError(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type * as vite from 'vite';
|
|
2
2
|
import type { Logger } from '../core/logger/core.js';
|
|
3
3
|
import type { AstroSettings } from '../types/astro.js';
|
|
4
|
-
import type { PluginMetadata as AstroPluginMetadata } from './types.js';
|
|
4
|
+
import type { PluginCssMetadata as AstroPluginCssMetadata, PluginMetadata as AstroPluginMetadata } from './types.js';
|
|
5
5
|
export { getAstroMetadata } from './metadata.js';
|
|
6
|
-
export type { AstroPluginMetadata };
|
|
6
|
+
export type { AstroPluginMetadata, AstroPluginCssMetadata };
|
|
7
7
|
interface AstroPluginOptions {
|
|
8
8
|
settings: AstroSettings;
|
|
9
9
|
logger: Logger;
|
|
@@ -89,9 +89,15 @@ function astro({ settings, logger }) {
|
|
|
89
89
|
result.dependencies?.forEach((dep) => this.addWatchFile(dep));
|
|
90
90
|
return {
|
|
91
91
|
code: result.code,
|
|
92
|
-
//
|
|
93
|
-
// if the
|
|
94
|
-
meta: result.isGlobal ? void 0 : {
|
|
92
|
+
// This metadata is used by `cssScopeToPlugin` to remove this module from the bundle
|
|
93
|
+
// if the `filename` default export (the Astro component) is unused.
|
|
94
|
+
meta: result.isGlobal ? void 0 : {
|
|
95
|
+
astroCss: {
|
|
96
|
+
cssScopeTo: {
|
|
97
|
+
[filename]: ["default"]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
95
101
|
};
|
|
96
102
|
}
|
|
97
103
|
case "script": {
|
|
@@ -15,6 +15,26 @@ export interface PluginMetadata {
|
|
|
15
15
|
pageOptions: PageOptions;
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
+
export interface PluginCssMetadata {
|
|
19
|
+
astroCss: {
|
|
20
|
+
/**
|
|
21
|
+
* For Astro CSS virtual modules, it can scope to the main Astro module's default export
|
|
22
|
+
* so that if those exports are treeshaken away, the CSS module will also be treeshaken.
|
|
23
|
+
*
|
|
24
|
+
* Example config if the CSS id is `/src/Foo.astro?astro&type=style&lang.css`:
|
|
25
|
+
* ```js
|
|
26
|
+
* cssScopeTo: {
|
|
27
|
+
* '/src/Foo.astro': ['default']
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* The above is the only config we use today, but we're exposing as a `Record` to follow the
|
|
32
|
+
* upstream Vite implementation: https://github.com/vitejs/vite/pull/16058. When/If that lands,
|
|
33
|
+
* we can also remove our custom implementation.
|
|
34
|
+
*/
|
|
35
|
+
cssScopeTo: Record<string, string[]>;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
18
38
|
export interface CompileMetadata {
|
|
19
39
|
/** Used for HMR to compare code changes */
|
|
20
40
|
originalCode: string;
|