[ci] format
This commit is contained in:
parent
9490f0e223
commit
ba1ca7e61f
3 changed files with 24 additions and 12 deletions
|
@ -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])) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue