summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar matthewp <matthewp@users.noreply.github.com> 2022-08-25 15:16:13 +0000
committerGravatar fredkbot <fred+astrobot@astro.build> 2022-08-25 15:16:13 +0000
commitba1ca7e61f3a506d2b5d307c5b3a4ca1c35198db (patch)
tree71bc7c52bfe0bf4e7cfa3d32ad8c3fac67a73193
parent9490f0e2235a61984bc0bba7e2383d2383085cf2 (diff)
downloadastro-ba1ca7e61f3a506d2b5d307c5b3a4ca1c35198db.tar.gz
astro-ba1ca7e61f3a506d2b5d307c5b3a4ca1c35198db.tar.zst
astro-ba1ca7e61f3a506d2b5d307c5b3a4ca1c35198db.zip
[ci] format
-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);
}
}