summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/astro/src/core/build/graph.ts2
-rw-r--r--packages/astro/src/core/build/internal.ts8
-rw-r--r--packages/astro/src/core/build/vite-plugin-css.ts26
3 files changed, 24 insertions, 12 deletions
diff --git a/packages/astro/src/core/build/graph.ts b/packages/astro/src/core/build/graph.ts
index b911253d5..8db52a1c9 100644
--- a/packages/astro/src/core/build/graph.ts
+++ b/packages/astro/src/core/build/graph.ts
@@ -33,7 +33,7 @@ export function moduleIsTopLevelPage(info: ModuleInfo): boolean {
// This could be a .astro page or a .md page.
export function* getTopLevelPages(
id: string,
- ctx: { getModuleInfo: GetModuleInfo },
+ ctx: { getModuleInfo: GetModuleInfo }
): Generator<[ModuleInfo, number], void, unknown> {
for (const res of walkParentInfos(id, ctx)) {
if (moduleIsTopLevelPage(res[0])) {
diff --git a/packages/astro/src/core/build/internal.ts b/packages/astro/src/core/build/internal.ts
index dfebc3052..ca24e0d90 100644
--- a/packages/astro/src/core/build/internal.ts
+++ b/packages/astro/src/core/build/internal.ts
@@ -1,4 +1,4 @@
-import type { OutputChunk, RenderedChunk, ModuleInfo, GetModuleInfo } from 'rollup';
+import type { OutputChunk, RenderedChunk } from 'rollup';
import type { PageBuildData, ViteID } from './types';
import { prependForwardSlash } from '../path.js';
@@ -207,10 +207,10 @@ export function* getPageDatasByHoistedScriptId(
id: string
): Generator<PageBuildData, void, unknown> {
const set = internals.hoistedScriptIdToPagesMap.get(id);
- if(set) {
- for(const pageId of set) {
+ if (set) {
+ for (const pageId of set) {
const pageData = getPageDataByComponent(internals, pageId.slice(1));
- if(pageData) {
+ if (pageData) {
yield pageData;
}
}
diff --git a/packages/astro/src/core/build/vite-plugin-css.ts b/packages/astro/src/core/build/vite-plugin-css.ts
index f6ae3f5a2..4833f3547 100644
--- a/packages/astro/src/core/build/vite-plugin-css.ts
+++ b/packages/astro/src/core/build/vite-plugin-css.ts
@@ -9,8 +9,14 @@ import npath from 'path';
import { Plugin as VitePlugin, ResolvedConfig } from 'vite';
import { isCSSRequest } from '../render/util.js';
import { relativeToSrcDir } from '../util.js';
-import { getTopLevelPages, walkParentInfos, moduleIsTopLevelPage } from './graph.js';
-import { eachPageData, getPageDataByViteID, getPageDatasByClientOnlyID, getPageDatasByHoistedScriptId, isHoistedScript } from './internal.js';
+import { getTopLevelPages, moduleIsTopLevelPage, walkParentInfos } from './graph.js';
+import {
+ eachPageData,
+ getPageDataByViteID,
+ getPageDatasByClientOnlyID,
+ getPageDatasByHoistedScriptId,
+ isHoistedScript,
+} from './internal.js';
interface PluginOptions {
internals: BuildInternals;
@@ -118,7 +124,7 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[]
pageData?.css.set(importedCssImport, { depth });
}
}
- }
+ };
for (const [_, chunk] of Object.entries(bundle)) {
if (chunk.type === 'chunk') {
@@ -144,14 +150,20 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[]
// For this CSS chunk, walk parents until you find a page. Add the CSS to that page.
for (const [id] of Object.entries(c.modules)) {
for (const [pageInfo, depth] of walkParentInfos(id, this)) {
- if(moduleIsTopLevelPage(pageInfo)) {
+ if (moduleIsTopLevelPage(pageInfo)) {
const pageViteID = pageInfo.id;
const pageData = getPageDataByViteID(internals, pageViteID);
- if(pageData) {
+ if (pageData) {
appendCSSToPage(pageData, meta, depth);
}
- } else if(options.target === 'client' && isHoistedScript(internals, pageInfo.id)) {
- for(const pageData of getPageDatasByHoistedScriptId(internals, pageInfo.id)) {
+ } else if (
+ options.target === 'client' &&
+ isHoistedScript(internals, pageInfo.id)
+ ) {
+ for (const pageData of getPageDatasByHoistedScriptId(
+ internals,
+ pageInfo.id
+ )) {
appendCSSToPage(pageData, meta, -1);
}
}