[ci] format

This commit is contained in:
matthewp 2022-08-05 13:53:50 +00:00 committed by fredkbot
parent 82a1063cc2
commit 9315ce65dd
4 changed files with 9 additions and 10 deletions

View file

@ -7,7 +7,6 @@ import { BuildInternals, createBuildInternals } from '../../core/build/internal.
import { prependForwardSlash } from '../../core/path.js';
import { emptyDir, isModeServerWithNoAdapter, removeDir } from '../../core/util.js';
import { runHookBuildSetup } from '../../integrations/index.js';
import { rollupPluginAstroBuildCSS } from './vite-plugin-css.js';
import { PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
import type { ViteConfigWithSSR } from '../create-vite';
import { info } from '../logger/core.js';
@ -16,6 +15,7 @@ import { trackPageData } from './internal.js';
import type { PageBuildData, StaticBuildOptions } from './types';
import { getTimeStat } from './util.js';
import { vitePluginAnalyzer } from './vite-plugin-analyzer.js';
import { rollupPluginAstroBuildCSS } from './vite-plugin-css.js';
import { vitePluginHoistedScripts } from './vite-plugin-hoisted-scripts.js';
import { vitePluginInternals } from './vite-plugin-internals.js';
import { vitePluginPages } from './vite-plugin-pages.js';

View file

@ -1,16 +1,16 @@
import type { GetModuleInfo, OutputChunk } from 'rollup';
import type { AstroConfig } from '../../@types/astro';
import type { BuildInternals } from './internal';
import type { PageBuildData, StaticBuildOptions } from './types';
import type { AstroConfig } from '../../@types/astro';
import crypto from 'crypto';
import esbuild from 'esbuild';
import npath from 'path';
import { Plugin as VitePlugin } from 'vite';
import { isCSSRequest } from '../render/util.js';
import { relativeToSrcDir } from '../util.js';
import { getTopLevelPages, walkParentInfos } from './graph.js';
import { getPageDataByViteID, getPageDatasByClientOnlyID } from './internal.js';
import { relativeToSrcDir } from '../util.js';
import { isCSSRequest } from '../render/util.js';
interface PluginOptions {
internals: BuildInternals;
@ -30,7 +30,7 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[]
function nameifyPage(id: string) {
let rel = relativeToSrcDir(astroConfig, id);
// Remove pages, ex. blog/posts/something.astro
if(rel.startsWith('pages/')) {
if (rel.startsWith('pages/')) {
rel = rel.slice(6);
}
// Remove extension, ex. blog/posts/something
@ -43,10 +43,10 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[]
function createNameForParentPages(id: string, ctx: { getModuleInfo: GetModuleInfo }): string {
const parents = Array.from(getTopLevelPages(id, ctx)).sort();
const proposedName = parents.map(page => nameifyPage(page.id)).join('-');
const proposedName = parents.map((page) => nameifyPage(page.id)).join('-');
// We don't want absurdedly long chunk names, so if this is too long create a hashed version instead.
if(proposedName.length <= MAX_NAME_LENGTH) {
if (proposedName.length <= MAX_NAME_LENGTH) {
return proposedName;
}

View file

@ -188,7 +188,7 @@ export function isModeServerWithNoAdapter(config: AstroConfig): boolean {
export function relativeToSrcDir(config: AstroConfig, idOrUrl: URL | string) {
let id: string;
if(typeof idOrUrl !== 'string') {
if (typeof idOrUrl !== 'string') {
id = unwrapId(viteID(idOrUrl));
} else {
id = idOrUrl;

View file

@ -17,6 +17,5 @@ describe('Astro.glob on pages/ directory', () => {
let $ = cheerio.load(html);
expect($('link[rel=stylesheet]')).to.have.a.lengthOf(1);
});
});