[ci] format
This commit is contained in:
parent
f5afaf2498
commit
948f82048b
17 changed files with 61 additions and 73 deletions
|
@ -61,7 +61,8 @@ function shouldSkipDraft(pageModule: ComponentInstance, astroConfig: AstroConfig
|
|||
// Drafts are disabled
|
||||
!astroConfig.markdown.drafts &&
|
||||
// This is a draft post
|
||||
('frontmatter' in pageModule && (pageModule as any).frontmatter.draft === true)
|
||||
'frontmatter' in pageModule &&
|
||||
(pageModule as any).frontmatter.draft === true
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { GetModuleInfo, ModuleInfo, OutputChunk } from 'rollup';
|
||||
import type { GetModuleInfo, ModuleInfo } from 'rollup';
|
||||
import { resolvedPagesVirtualModuleId } from '../app/index.js';
|
||||
|
||||
// This walks up the dependency graph and yields out each ModuleInfo object.
|
||||
|
|
|
@ -8,7 +8,6 @@ import * as colors from 'kleur/colors';
|
|||
import { fileURLToPath } from 'url';
|
||||
import { debug } from '../logger/core.js';
|
||||
import { removeTrailingForwardSlash } from '../path.js';
|
||||
import { preload as ssrPreload } from '../render/dev/index.js';
|
||||
import { callGetStaticPaths, RouteCache, RouteCacheEntry } from '../render/route-cache.js';
|
||||
import { matchRoute } from '../routing/match.js';
|
||||
import { isBuildingToSSR } from '../util.js';
|
||||
|
@ -132,7 +131,7 @@ export async function collectPagesData(
|
|||
moduleSpecifier: '',
|
||||
css: new Set(),
|
||||
hoistedScript: undefined,
|
||||
scripts: new Set()
|
||||
scripts: new Set(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,7 @@ import { bgGreen, bgMagenta, black, dim } from 'kleur/colors';
|
|||
import type { RollupOutput } from 'rollup';
|
||||
import { fileURLToPath } from 'url';
|
||||
import * as vite from 'vite';
|
||||
import {
|
||||
BuildInternals,
|
||||
createBuildInternals,
|
||||
} from '../../core/build/internal.js';
|
||||
import { BuildInternals, createBuildInternals } from '../../core/build/internal.js';
|
||||
import { prependForwardSlash } from '../../core/path.js';
|
||||
import { emptyDir, removeDir } from '../../core/util.js';
|
||||
import { runHookBuildSetup } from '../../integrations/index.js';
|
||||
|
@ -19,11 +16,11 @@ import { generatePages } from './generate.js';
|
|||
import { trackPageData } from './internal.js';
|
||||
import type { PageBuildData, StaticBuildOptions } from './types';
|
||||
import { getTimeStat } from './util.js';
|
||||
import { vitePluginAnalyzer } from './vite-plugin-analyzer.js';
|
||||
import { vitePluginHoistedScripts } from './vite-plugin-hoisted-scripts.js';
|
||||
import { vitePluginInternals } from './vite-plugin-internals.js';
|
||||
import { vitePluginPages } from './vite-plugin-pages.js';
|
||||
import { vitePluginSSR, injectManifest } from './vite-plugin-ssr.js';
|
||||
import { vitePluginAnalyzer } from './vite-plugin-analyzer.js';
|
||||
import { injectManifest, vitePluginSSR } from './vite-plugin-ssr.js';
|
||||
|
||||
export async function staticBuild(opts: StaticBuildOptions) {
|
||||
const { allPages, astroConfig } = opts;
|
||||
|
@ -73,7 +70,7 @@ export async function staticBuild(opts: StaticBuildOptions) {
|
|||
const clientInput = new Set<string>([
|
||||
...internals.discoveredHydratedComponents,
|
||||
...internals.discoveredClientOnlyComponents,
|
||||
...astroConfig._ctx.renderers.map(r => r.clientEntrypoint).filter(a => a) as string[],
|
||||
...(astroConfig._ctx.renderers.map((r) => r.clientEntrypoint).filter((a) => a) as string[]),
|
||||
...internals.discoveredScripts,
|
||||
]);
|
||||
|
||||
|
@ -90,7 +87,7 @@ export async function staticBuild(opts: StaticBuildOptions) {
|
|||
}
|
||||
} else {
|
||||
// Inject the manifest
|
||||
await injectManifest(opts, internals)
|
||||
await injectManifest(opts, internals);
|
||||
|
||||
info(opts.logging, null, `\n${bgMagenta(black(' finalizing server assets '))}\n`);
|
||||
await ssrMoveAssets(opts);
|
||||
|
@ -144,7 +141,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
|
|||
// SSR needs to be last
|
||||
isBuildingToSSR(opts.astroConfig) &&
|
||||
vitePluginSSR(opts, internals, opts.astroConfig._ctx.adapter!),
|
||||
vitePluginAnalyzer(opts.astroConfig, internals)
|
||||
vitePluginAnalyzer(opts.astroConfig, internals),
|
||||
],
|
||||
publicDir: ssr ? false : viteConfig.publicDir,
|
||||
root: viteConfig.root,
|
||||
|
|
|
@ -1,31 +1,23 @@
|
|||
|
||||
|
||||
import type { Plugin as VitePlugin } from 'vite';
|
||||
import type { PluginContext } from 'rollup';
|
||||
import type { Plugin as VitePlugin } from 'vite';
|
||||
import type { AstroConfig } from '../../@types/astro';
|
||||
import type { BuildInternals } from '../../core/build/internal.js';
|
||||
import type { PluginMetadata as AstroPluginMetadata } from '../../vite-plugin-astro/types';
|
||||
|
||||
import { prependForwardSlash } from '../../core/path.js';
|
||||
import { getPageDataByViteID, trackClientOnlyPageDatas } from './internal.js';
|
||||
import { getTopLevelPages } from './graph.js';
|
||||
|
||||
import { getPageDataByViteID, trackClientOnlyPageDatas } from './internal.js';
|
||||
|
||||
export function vitePluginAnalyzer(
|
||||
astroConfig: AstroConfig,
|
||||
internals: BuildInternals
|
||||
): VitePlugin {
|
||||
|
||||
function hoistedScriptScanner() {
|
||||
const uniqueHoistedIds = new Map<string, string>();
|
||||
const pageScripts = new Map<string, Set<string>>();
|
||||
|
||||
return {
|
||||
scan(
|
||||
this: PluginContext,
|
||||
scripts: AstroPluginMetadata['astro']['scripts'],
|
||||
from: string
|
||||
) {
|
||||
scan(this: PluginContext, scripts: AstroPluginMetadata['astro']['scripts'], from: string) {
|
||||
const hoistedScripts = new Set<string>();
|
||||
for (let i = 0; i < scripts.length; i++) {
|
||||
const hid = `${from.replace('/@fs', '')}?astro&type=script&index=${i}`;
|
||||
|
@ -75,7 +67,7 @@ export function vitePluginAnalyzer(
|
|||
internals.hoistedScriptIdToHoistedMap.set(moduleId, hoistedScripts);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -118,6 +110,6 @@ export function vitePluginAnalyzer(
|
|||
|
||||
// Finalize hoisting
|
||||
hoistScanner.finalize();
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import type { BuildInternals } from './internal.js';
|
|||
import type { StaticBuildOptions } from './types';
|
||||
|
||||
import glob from 'fast-glob';
|
||||
import * as fs from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { runHookBuildSsr } from '../../integrations/index.js';
|
||||
import { BEFORE_HYDRATION_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
|
||||
|
@ -12,7 +13,6 @@ import { pagesVirtualModuleId } from '../app/index.js';
|
|||
import { serializeRouteData } from '../routing/index.js';
|
||||
import { addRollupInput } from './add-rollup-input.js';
|
||||
import { eachPageData } from './internal.js';
|
||||
import * as fs from 'fs';
|
||||
|
||||
export const virtualModuleId = '@astrojs-ssr-virtual-entry';
|
||||
const resolvedVirtualModuleId = '\0' + virtualModuleId;
|
||||
|
|
|
@ -52,7 +52,8 @@ export class Metadata {
|
|||
|
||||
*hoistedScriptPaths() {
|
||||
for (const metadata of this.deepMetadata()) {
|
||||
let i = 0, pathname = metadata.mockURL.pathname;
|
||||
let i = 0,
|
||||
pathname = metadata.mockURL.pathname;
|
||||
|
||||
while (i < metadata.hoisted.length) {
|
||||
// Strip off the leading "/@fs" added during compilation.
|
||||
|
|
|
@ -113,7 +113,7 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
|
|||
source,
|
||||
ssr: Boolean(opts?.ssr),
|
||||
viteTransform,
|
||||
pluginContext: this
|
||||
pluginContext: this,
|
||||
};
|
||||
if (query.astro) {
|
||||
if (query.type === 'style') {
|
||||
|
@ -222,7 +222,7 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
|
|||
const astroMetadata: AstroPluginMetadata['astro'] = {
|
||||
clientOnlyComponents: transformResult.clientOnlyComponents,
|
||||
hydratedComponents: transformResult.hydratedComponents,
|
||||
scripts: transformResult.scripts
|
||||
scripts: transformResult.scripts,
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
|
@ -2,8 +2,8 @@ import type { TransformResult } from '@astrojs/compiler';
|
|||
|
||||
export interface PluginMetadata {
|
||||
astro: {
|
||||
hydratedComponents: TransformResult['hydratedComponents'],
|
||||
clientOnlyComponents: TransformResult['clientOnlyComponents'],
|
||||
scripts: TransformResult['scripts']
|
||||
}
|
||||
hydratedComponents: TransformResult['hydratedComponents'];
|
||||
clientOnlyComponents: TransformResult['clientOnlyComponents'];
|
||||
scripts: TransformResult['scripts'];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import type { GetModuleInfo, ModuleInfo, OutputChunk } from 'rollup';
|
||||
import type { GetModuleInfo, OutputChunk } from 'rollup';
|
||||
import { BuildInternals } from '../core/build/internal';
|
||||
import type { PageBuildData } from '../core/build/types';
|
||||
|
||||
import crypto from 'crypto';
|
||||
import esbuild from 'esbuild';
|
||||
import { Plugin as VitePlugin } from 'vite';
|
||||
import { resolvedPagesVirtualModuleId } from '../core/app/index.js';
|
||||
import { getPageDataByViteID, getPageDatasByClientOnlyID } from '../core/build/internal.js';
|
||||
import { getTopLevelPages, walkParentInfos } from '../core/build/graph.js';
|
||||
import { getPageDataByViteID, getPageDatasByClientOnlyID } from '../core/build/internal.js';
|
||||
import { isCSSRequest } from '../core/render/util.js';
|
||||
|
||||
interface PluginOptions {
|
||||
|
|
|
@ -7,15 +7,14 @@ import matter from 'gray-matter';
|
|||
import { fileURLToPath } from 'url';
|
||||
import type { Plugin } from 'vite';
|
||||
import type { AstroConfig } from '../@types/astro';
|
||||
import type { PluginMetadata as AstroPluginMetadata } from '../vite-plugin-astro/types';
|
||||
import { pagesVirtualModuleId } from '../core/app/index.js';
|
||||
import { collectErrorMetadata } from '../core/errors.js';
|
||||
import { prependForwardSlash } from '../core/path.js';
|
||||
import { resolvePages, viteID } from '../core/util.js';
|
||||
import type { PluginMetadata as AstroPluginMetadata } from '../vite-plugin-astro/types';
|
||||
import { PAGE_SSR_SCRIPT_ID } from '../vite-plugin-scripts/index.js';
|
||||
import { getFileInfo } from '../vite-plugin-utils/index.js';
|
||||
|
||||
|
||||
interface AstroPluginOptions {
|
||||
config: AstroConfig;
|
||||
}
|
||||
|
@ -212,7 +211,7 @@ ${tsResult}`;
|
|||
const astroMetadata: AstroPluginMetadata['astro'] = {
|
||||
clientOnlyComponents: transformResult.clientOnlyComponents,
|
||||
hydratedComponents: transformResult.hydratedComponents,
|
||||
scripts: transformResult.scripts
|
||||
scripts: transformResult.scripts,
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
|
@ -10,4 +10,4 @@ const ceDefine = customElements.define;
|
|||
customElements.define = function (tagName, Ctr) {
|
||||
Ctr[Symbol.for('tagName')] = tagName;
|
||||
return ceDefine.call(this, tagName, Ctr);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -18,7 +18,7 @@ function getViteConfiguration() {
|
|||
'@lit-labs/ssr/lib/install-global-dom-shim.js',
|
||||
'@lit-labs/ssr/lib/render-lit-html.js',
|
||||
'@lit-labs/ssr/lib/lit-element-renderer.js',
|
||||
'@astrojs/lit/server.js'
|
||||
'@astrojs/lit/server.js',
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import type { AstroAdapter, AstroConfig, AstroIntegration, BuildConfig, RouteData } from 'astro';
|
||||
import type { Plugin as VitePlugin } from 'vite';
|
||||
import esbuild from 'esbuild';
|
||||
import * as fs from 'fs';
|
||||
import * as npath from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import type { Plugin as VitePlugin } from 'vite';
|
||||
import { createRedirects } from './shared.js';
|
||||
|
||||
export function getAdapter(): AstroAdapter {
|
||||
|
@ -115,13 +115,13 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {})
|
|||
chunk.code = `globalThis.process = { argv: [], env: {}, };${chunk.code}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
updateConfig({
|
||||
vite: {
|
||||
plugins: [injectPlugin]
|
||||
}
|
||||
plugins: [injectPlugin],
|
||||
},
|
||||
});
|
||||
},
|
||||
'astro:config:done': ({ config, setAdapter }) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue