0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-20 22:12:38 -05:00

[ci] format

This commit is contained in:
matthewp 2023-05-03 18:51:25 +00:00 committed by fredkbot
parent 80e3d4d3d0
commit 2c655a57f6
7 changed files with 14 additions and 23 deletions

View file

@ -24,8 +24,8 @@ import {
import { RouteCache } from '../render/route-cache.js'; import { RouteCache } from '../render/route-cache.js';
import { import {
createAssetLink, createAssetLink,
createStylesheetElementSet,
createModuleScriptElement, createModuleScriptElement,
createStylesheetElementSet,
} from '../render/ssr-element.js'; } from '../render/ssr-element.js';
import { matchRoute } from '../routing/match.js'; import { matchRoute } from '../routing/match.js';
export { deserializeManifest } from './common.js'; export { deserializeManifest } from './common.js';

View file

@ -40,19 +40,14 @@ import { createEnvironment, createRenderContext, renderPage } from '../render/in
import { callGetStaticPaths } from '../render/route-cache.js'; import { callGetStaticPaths } from '../render/route-cache.js';
import { import {
createAssetLink, createAssetLink,
createStylesheetElementSet,
createModuleScriptsSet, createModuleScriptsSet,
createStylesheetElementSet,
} from '../render/ssr-element.js'; } from '../render/ssr-element.js';
import { createRequest } from '../request.js'; import { createRequest } from '../request.js';
import { matchRoute } from '../routing/match.js'; import { matchRoute } from '../routing/match.js';
import { getOutputFilename } from '../util.js'; import { getOutputFilename } from '../util.js';
import { getOutDirWithinCwd, getOutFile, getOutFolder } from './common.js'; import { getOutDirWithinCwd, getOutFile, getOutFolder } from './common.js';
import { import { cssOrder, eachPageData, getPageDataByComponent, mergeInlineCss } from './internal.js';
eachPageData,
getPageDataByComponent,
cssOrder,
mergeInlineCss,
} from './internal.js';
import type { import type {
PageBuildData, PageBuildData,
SingleFileBuiltModule, SingleFileBuiltModule,

View file

@ -272,7 +272,7 @@ export function mergeInlineCss(
acc[acc.length - 1] = merged; acc[acc.length - 1] = merged;
return acc; return acc;
} }
acc.push(current) acc.push(current);
return acc; return acc;
} }

View file

@ -58,8 +58,8 @@ function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[] {
let resolvedConfig: ResolvedConfig; let resolvedConfig: ResolvedConfig;
// stylesheet filenames are kept in here until "post", when they are rendered and ready to be inlined // stylesheet filenames are kept in here until "post", when they are rendered and ready to be inlined
const pagesToCss: Record<string, Record<string, { order: number; depth: number }>> = {} const pagesToCss: Record<string, Record<string, { order: number; depth: number }>> = {};
const pagesToPropagatedCss: Record<string, Record<string, Set<string>>> = {} const pagesToPropagatedCss: Record<string, Record<string, Set<string>>> = {};
const cssBuildPlugin: VitePlugin = { const cssBuildPlugin: VitePlugin = {
name: 'astro:rollup-plugin-build-css', name: 'astro:rollup-plugin-build-css',
@ -129,7 +129,7 @@ function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[] {
for (const id of Object.keys(chunk.modules)) { for (const id of Object.keys(chunk.modules)) {
for (const pageData of getParentClientOnlys(id, this, internals)) { for (const pageData of getParentClientOnlys(id, this, internals)) {
for (const importedCssImport of meta.importedCss) { for (const importedCssImport of meta.importedCss) {
const cssToInfoRecord = pagesToCss[pageData.moduleSpecifier] ??= {} const cssToInfoRecord = (pagesToCss[pageData.moduleSpecifier] ??= {});
cssToInfoRecord[importedCssImport] = { depth: -1, order: -1 }; cssToInfoRecord[importedCssImport] = { depth: -1, order: -1 };
} }
} }
@ -155,8 +155,8 @@ function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[] {
if (pageData === undefined) continue; if (pageData === undefined) continue;
for (const css of meta.importedCss) { for (const css of meta.importedCss) {
const propagatedStyles = pagesToPropagatedCss[pageData.moduleSpecifier] ??= {} const propagatedStyles = (pagesToPropagatedCss[pageData.moduleSpecifier] ??= {});
const existingCss = propagatedStyles[pageInfo.id] ??= new Set(); const existingCss = (propagatedStyles[pageInfo.id] ??= new Set());
existingCss.add(css); existingCss.add(css);
} }
@ -194,7 +194,7 @@ function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[] {
); );
if (cssChunk === undefined) return; if (cssChunk === undefined) return;
for (const pageData of eachPageData(internals)) { for (const pageData of eachPageData(internals)) {
const cssToInfoMap = pagesToCss[pageData.moduleSpecifier] ??= {}; const cssToInfoMap = (pagesToCss[pageData.moduleSpecifier] ??= {});
cssToInfoMap[cssChunk.fileName] = { depth: -1, order: -1 }; cssToInfoMap[cssChunk.fileName] = { depth: -1, order: -1 };
} }
}, },
@ -312,7 +312,7 @@ function appendCSSToPage(
cssInfo.order = order; cssInfo.order = order;
} }
} else { } else {
const cssToInfoRecord = pagesToCss[pageData.moduleSpecifier] ??= {}; const cssToInfoRecord = (pagesToCss[pageData.moduleSpecifier] ??= {});
cssToInfoRecord[importedCssImport] = { depth, order }; cssToInfoRecord[importedCssImport] = { depth, order };
} }
} }

View file

@ -13,11 +13,7 @@ import { joinPaths, prependForwardSlash } from '../../path.js';
import { serializeRouteData } from '../../routing/index.js'; import { serializeRouteData } from '../../routing/index.js';
import { addRollupInput } from '../add-rollup-input.js'; import { addRollupInput } from '../add-rollup-input.js';
import { getOutFile, getOutFolder } from '../common.js'; import { getOutFile, getOutFolder } from '../common.js';
import { import { cssOrder, eachPageData, mergeInlineCss } from '../internal.js';
eachPageData,
cssOrder,
mergeInlineCss,
} from '../internal.js';
import type { AstroBuildPlugin } from '../plugin'; import type { AstroBuildPlugin } from '../plugin';
export const virtualModuleId = '@astrojs-ssr-virtual-entry'; export const virtualModuleId = '@astrojs-ssr-virtual-entry';

View file

@ -1,7 +1,7 @@
import slashify from 'slash'; import slashify from 'slash';
import type { SSRElement } from '../../@types/astro'; import type { SSRElement } from '../../@types/astro';
import type { StylesheetAsset } from '../app/types';
import { joinPaths, prependForwardSlash } from '../../core/path.js'; import { joinPaths, prependForwardSlash } from '../../core/path.js';
import type { StylesheetAsset } from '../app/types';
export function createAssetLink(href: string, base?: string, assetsPrefix?: string): string { export function createAssetLink(href: string, base?: string, assetsPrefix?: string): string {
if (assetsPrefix) { if (assetsPrefix) {