0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

[ci] format

This commit is contained in:
FredKSchott 2022-07-19 05:21:24 +00:00 committed by fredkbot
parent 04070c0c12
commit 4bb96ac8e5
3 changed files with 14 additions and 15 deletions

View file

@ -4,7 +4,7 @@ import { defineConfig } from 'astro/config';
export default defineConfig({ export default defineConfig({
vite: { vite: {
ssr: { ssr: {
noExternal: ['@example/my-component'] noExternal: ['@example/my-component'],
}, },
}, },
}); });

View file

@ -6,7 +6,7 @@ import { fileURLToPath } from 'url';
import * as vite from 'vite'; 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 { prependForwardSlash } from '../../core/path.js';
import { emptyDir, removeDir, resolveDependency } from '../../core/util.js'; import { emptyDir, removeDir } from '../../core/util.js';
import { runHookBuildSetup } from '../../integrations/index.js'; import { runHookBuildSetup } from '../../integrations/index.js';
import { rollupPluginAstroBuildCSS } from '../../vite-plugin-build-css/index.js'; import { rollupPluginAstroBuildCSS } from '../../vite-plugin-build-css/index.js';
import type { ViteConfigWithSSR } from '../create-vite'; import type { ViteConfigWithSSR } from '../create-vite';
@ -67,7 +67,9 @@ export async function staticBuild(opts: StaticBuildOptions) {
const ssrResult = (await ssrBuild(opts, internals, pageInput)) as RollupOutput; const ssrResult = (await ssrBuild(opts, internals, pageInput)) as RollupOutput;
info(opts.logging, 'build', dim(`Completed in ${getTimeStat(timer.ssr, performance.now())}.`)); info(opts.logging, 'build', dim(`Completed in ${getTimeStat(timer.ssr, performance.now())}.`));
const rendererClientEntrypoints = opts.astroConfig._ctx.renderers.map((r) => r.clientEntrypoint).filter(a => typeof a === 'string') as string[] const rendererClientEntrypoints = opts.astroConfig._ctx.renderers
.map((r) => r.clientEntrypoint)
.filter((a) => typeof a === 'string') as string[];
const clientInput = new Set([ const clientInput = new Set([
...internals.discoveredHydratedComponents, ...internals.discoveredHydratedComponents,
@ -169,7 +171,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
async function clientBuild( async function clientBuild(
opts: StaticBuildOptions, opts: StaticBuildOptions,
internals: BuildInternals, internals: BuildInternals,
input: Set<string>, input: Set<string>
) { ) {
const { astroConfig, viteConfig } = opts; const { astroConfig, viteConfig } = opts;
const timer = performance.now(); const timer = performance.now();

View file

@ -35,17 +35,17 @@ const ALWAYS_NOEXTERNAL = new Set([
]); ]);
function getSsrNoExternalDeps(projectRoot: URL): string[] { function getSsrNoExternalDeps(projectRoot: URL): string[] {
let noExternalDeps = [] let noExternalDeps = [];
for (const dep of ALWAYS_NOEXTERNAL) { for (const dep of ALWAYS_NOEXTERNAL) {
try { try {
resolveDependency(dep, projectRoot) resolveDependency(dep, projectRoot);
noExternalDeps.push(dep) noExternalDeps.push(dep);
} catch { } catch {
// ignore dependency if *not* installed / present in your project // ignore dependency if *not* installed / present in your project
// prevents hard error from Vite! // prevents hard error from Vite!
} }
} }
return noExternalDeps return noExternalDeps;
} }
/** Return a common starting point for all Vite actions */ /** Return a common starting point for all Vite actions */
@ -116,11 +116,8 @@ export async function createVite(
conditions: ['astro'], conditions: ['astro'],
}, },
ssr: { ssr: {
noExternal: [ noExternal: [...getSsrNoExternalDeps(astroConfig.root), ...thirdPartyAstroPackages],
...getSsrNoExternalDeps(astroConfig.root), },
...thirdPartyAstroPackages,
],
}
}; };
// Merge configs: we merge vite configuration objects together in the following order, // Merge configs: we merge vite configuration objects together in the following order,
@ -147,8 +144,8 @@ function findPluginIndexByName(pluginOptions: vite.PluginOption[], name: string)
return pluginOptions.findIndex(function (pluginOption) { return pluginOptions.findIndex(function (pluginOption) {
// Use isVitePlugin to ignore nulls, booleans, promises, and arrays // Use isVitePlugin to ignore nulls, booleans, promises, and arrays
// CAUTION: could be a problem if a plugin we're searching for becomes async! // CAUTION: could be a problem if a plugin we're searching for becomes async!
return isVitePlugin(pluginOption) && pluginOption.name === name return isVitePlugin(pluginOption) && pluginOption.name === name;
}) });
} }
function sortPlugins(pluginOptions: vite.PluginOption[]) { function sortPlugins(pluginOptions: vite.PluginOption[]) {