[ci] format

This commit is contained in:
matthewp 2022-06-21 12:33:55 +00:00 committed by github-actions[bot]
parent f5afaf2498
commit 948f82048b
17 changed files with 61 additions and 73 deletions

View file

@ -61,7 +61,8 @@ function shouldSkipDraft(pageModule: ComponentInstance, astroConfig: AstroConfig
// Drafts are disabled // Drafts are disabled
!astroConfig.markdown.drafts && !astroConfig.markdown.drafts &&
// This is a draft post // This is a draft post
('frontmatter' in pageModule && (pageModule as any).frontmatter.draft === true) 'frontmatter' in pageModule &&
(pageModule as any).frontmatter.draft === true
); );
} }
@ -133,7 +134,7 @@ async function generatePage(
); );
} }
if(shouldSkipDraft(pageModule, opts.astroConfig)) { if (shouldSkipDraft(pageModule, opts.astroConfig)) {
info(opts.logging, null, `${magenta('⚠️')} Skipping draft ${pageData.route.component}`); info(opts.logging, null, `${magenta('⚠️')} Skipping draft ${pageData.route.component}`);
return; return;
} }

View file

@ -1,4 +1,4 @@
import type { GetModuleInfo, ModuleInfo, OutputChunk } from 'rollup'; import type { GetModuleInfo, ModuleInfo } from 'rollup';
import { resolvedPagesVirtualModuleId } from '../app/index.js'; import { resolvedPagesVirtualModuleId } from '../app/index.js';
// This walks up the dependency graph and yields out each ModuleInfo object. // This walks up the dependency graph and yields out each ModuleInfo object.

View file

@ -8,7 +8,6 @@ import * as colors from 'kleur/colors';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import { debug } from '../logger/core.js'; import { debug } from '../logger/core.js';
import { removeTrailingForwardSlash } from '../path.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 { callGetStaticPaths, RouteCache, RouteCacheEntry } from '../render/route-cache.js';
import { matchRoute } from '../routing/match.js'; import { matchRoute } from '../routing/match.js';
import { isBuildingToSSR } from '../util.js'; import { isBuildingToSSR } from '../util.js';
@ -132,7 +131,7 @@ export async function collectPagesData(
moduleSpecifier: '', moduleSpecifier: '',
css: new Set(), css: new Set(),
hoistedScript: undefined, hoistedScript: undefined,
scripts: new Set() scripts: new Set(),
}; };
} }

View file

@ -4,10 +4,7 @@ import { bgGreen, bgMagenta, black, dim } from 'kleur/colors';
import type { RollupOutput } from 'rollup'; import type { RollupOutput } from 'rollup';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import * as vite from 'vite'; import * as vite from 'vite';
import { import { BuildInternals, createBuildInternals } from '../../core/build/internal.js';
BuildInternals,
createBuildInternals,
} from '../../core/build/internal.js';
import { prependForwardSlash } from '../../core/path.js'; import { prependForwardSlash } from '../../core/path.js';
import { emptyDir, removeDir } from '../../core/util.js'; import { emptyDir, removeDir } from '../../core/util.js';
import { runHookBuildSetup } from '../../integrations/index.js'; import { runHookBuildSetup } from '../../integrations/index.js';
@ -19,11 +16,11 @@ import { generatePages } from './generate.js';
import { trackPageData } from './internal.js'; import { trackPageData } from './internal.js';
import type { PageBuildData, StaticBuildOptions } from './types'; import type { PageBuildData, StaticBuildOptions } from './types';
import { getTimeStat } from './util.js'; import { getTimeStat } from './util.js';
import { vitePluginAnalyzer } from './vite-plugin-analyzer.js';
import { vitePluginHoistedScripts } from './vite-plugin-hoisted-scripts.js'; import { vitePluginHoistedScripts } from './vite-plugin-hoisted-scripts.js';
import { vitePluginInternals } from './vite-plugin-internals.js'; import { vitePluginInternals } from './vite-plugin-internals.js';
import { vitePluginPages } from './vite-plugin-pages.js'; import { vitePluginPages } from './vite-plugin-pages.js';
import { vitePluginSSR, injectManifest } from './vite-plugin-ssr.js'; import { injectManifest, vitePluginSSR } from './vite-plugin-ssr.js';
import { vitePluginAnalyzer } from './vite-plugin-analyzer.js';
export async function staticBuild(opts: StaticBuildOptions) { export async function staticBuild(opts: StaticBuildOptions) {
const { allPages, astroConfig } = opts; const { allPages, astroConfig } = opts;
@ -73,7 +70,7 @@ export async function staticBuild(opts: StaticBuildOptions) {
const clientInput = new Set<string>([ const clientInput = new Set<string>([
...internals.discoveredHydratedComponents, ...internals.discoveredHydratedComponents,
...internals.discoveredClientOnlyComponents, ...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, ...internals.discoveredScripts,
]); ]);
@ -90,7 +87,7 @@ export async function staticBuild(opts: StaticBuildOptions) {
} }
} else { } else {
// Inject the manifest // Inject the manifest
await injectManifest(opts, internals) await injectManifest(opts, internals);
info(opts.logging, null, `\n${bgMagenta(black(' finalizing server assets '))}\n`); info(opts.logging, null, `\n${bgMagenta(black(' finalizing server assets '))}\n`);
await ssrMoveAssets(opts); await ssrMoveAssets(opts);
@ -144,7 +141,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
// SSR needs to be last // SSR needs to be last
isBuildingToSSR(opts.astroConfig) && isBuildingToSSR(opts.astroConfig) &&
vitePluginSSR(opts, internals, opts.astroConfig._ctx.adapter!), vitePluginSSR(opts, internals, opts.astroConfig._ctx.adapter!),
vitePluginAnalyzer(opts.astroConfig, internals) vitePluginAnalyzer(opts.astroConfig, internals),
], ],
publicDir: ssr ? false : viteConfig.publicDir, publicDir: ssr ? false : viteConfig.publicDir,
root: viteConfig.root, root: viteConfig.root,

View file

@ -1,41 +1,33 @@
import type { Plugin as VitePlugin } from 'vite';
import type { PluginContext } from 'rollup'; import type { PluginContext } from 'rollup';
import type { Plugin as VitePlugin } from 'vite';
import type { AstroConfig } from '../../@types/astro'; import type { AstroConfig } from '../../@types/astro';
import type { BuildInternals } from '../../core/build/internal.js'; import type { BuildInternals } from '../../core/build/internal.js';
import type { PluginMetadata as AstroPluginMetadata } from '../../vite-plugin-astro/types'; import type { PluginMetadata as AstroPluginMetadata } from '../../vite-plugin-astro/types';
import { prependForwardSlash } from '../../core/path.js'; import { prependForwardSlash } from '../../core/path.js';
import { getPageDataByViteID, trackClientOnlyPageDatas } from './internal.js';
import { getTopLevelPages } from './graph.js'; import { getTopLevelPages } from './graph.js';
import { getPageDataByViteID, trackClientOnlyPageDatas } from './internal.js';
export function vitePluginAnalyzer( export function vitePluginAnalyzer(
astroConfig: AstroConfig, astroConfig: AstroConfig,
internals: BuildInternals internals: BuildInternals
): VitePlugin { ): VitePlugin {
function hoistedScriptScanner() { function hoistedScriptScanner() {
const uniqueHoistedIds = new Map<string, string>(); const uniqueHoistedIds = new Map<string, string>();
const pageScripts = new Map<string, Set<string>>(); const pageScripts = new Map<string, Set<string>>();
return { return {
scan( scan(this: PluginContext, scripts: AstroPluginMetadata['astro']['scripts'], from: string) {
this: PluginContext,
scripts: AstroPluginMetadata['astro']['scripts'],
from: string
) {
const hoistedScripts = new Set<string>(); const hoistedScripts = new Set<string>();
for(let i = 0; i < scripts.length; i++) { for (let i = 0; i < scripts.length; i++) {
const hid = `${from.replace('/@fs', '')}?astro&type=script&index=${i}`; const hid = `${from.replace('/@fs', '')}?astro&type=script&index=${i}`;
hoistedScripts.add(hid); hoistedScripts.add(hid);
} }
if (hoistedScripts.size) { if (hoistedScripts.size) {
for(const pageId of getTopLevelPages(from, this)) { for (const pageId of getTopLevelPages(from, this)) {
for(const hid of hoistedScripts) { for (const hid of hoistedScripts) {
if(pageScripts.has(pageId)) { if (pageScripts.has(pageId)) {
pageScripts.get(pageId)?.add(hid); pageScripts.get(pageId)?.add(hid);
} else { } else {
pageScripts.set(pageId, new Set([hid])); pageScripts.set(pageId, new Set([hid]));
@ -46,16 +38,16 @@ export function vitePluginAnalyzer(
}, },
finalize() { finalize() {
for(const [pageId, hoistedScripts] of pageScripts) { for (const [pageId, hoistedScripts] of pageScripts) {
const pageData = getPageDataByViteID(internals, pageId); const pageData = getPageDataByViteID(internals, pageId);
if(!pageData) continue; if (!pageData) continue;
const { component } = pageData; const { component } = pageData;
const astroModuleId = prependForwardSlash(component); const astroModuleId = prependForwardSlash(component);
const uniqueHoistedId = JSON.stringify(Array.from(hoistedScripts).sort()); const uniqueHoistedId = JSON.stringify(Array.from(hoistedScripts).sort());
let moduleId: string; let moduleId: string;
// If we're already tracking this set of hoisted scripts, get the unique id // If we're already tracking this set of hoisted scripts, get the unique id
if (uniqueHoistedIds.has(uniqueHoistedId)) { if (uniqueHoistedIds.has(uniqueHoistedId)) {
moduleId = uniqueHoistedIds.get(uniqueHoistedId)!; moduleId = uniqueHoistedIds.get(uniqueHoistedId)!;
@ -65,7 +57,7 @@ export function vitePluginAnalyzer(
uniqueHoistedIds.set(uniqueHoistedId, moduleId); uniqueHoistedIds.set(uniqueHoistedId, moduleId);
} }
internals.discoveredScripts.add(moduleId); internals.discoveredScripts.add(moduleId);
// Make sure to track that this page uses this set of hoisted scripts // Make sure to track that this page uses this set of hoisted scripts
if (internals.hoistedScriptIdToPagesMap.has(moduleId)) { if (internals.hoistedScriptIdToPagesMap.has(moduleId)) {
const pages = internals.hoistedScriptIdToPagesMap.get(moduleId); const pages = internals.hoistedScriptIdToPagesMap.get(moduleId);
@ -75,42 +67,42 @@ export function vitePluginAnalyzer(
internals.hoistedScriptIdToHoistedMap.set(moduleId, hoistedScripts); internals.hoistedScriptIdToHoistedMap.set(moduleId, hoistedScripts);
} }
} }
} },
}; };
} }
return { return {
name: '@astro/rollup-plugin-astro-analyzer', name: '@astro/rollup-plugin-astro-analyzer',
generateBundle() { generateBundle() {
const hoistScanner = hoistedScriptScanner(); const hoistScanner = hoistedScriptScanner();
const ids = this.getModuleIds(); const ids = this.getModuleIds();
for(const id of ids) { for (const id of ids) {
const info = this.getModuleInfo(id); const info = this.getModuleInfo(id);
if(!info || !info.meta?.astro) continue; if (!info || !info.meta?.astro) continue;
const astro = info.meta.astro as AstroPluginMetadata['astro']; const astro = info.meta.astro as AstroPluginMetadata['astro'];
for(const c of astro.hydratedComponents) { for (const c of astro.hydratedComponents) {
internals.discoveredHydratedComponents.add(c.resolvedPath || c.specifier); internals.discoveredHydratedComponents.add(c.resolvedPath || c.specifier);
} }
// Scan hoisted scripts // Scan hoisted scripts
hoistScanner.scan.call(this, astro.scripts, id); hoistScanner.scan.call(this, astro.scripts, id);
if(astro.clientOnlyComponents.length) { if (astro.clientOnlyComponents.length) {
const clientOnlys: string[] = []; const clientOnlys: string[] = [];
for(const c of astro.clientOnlyComponents) { for (const c of astro.clientOnlyComponents) {
const cid = c.resolvedPath || c.specifier; const cid = c.resolvedPath || c.specifier;
internals.discoveredClientOnlyComponents.add(cid); internals.discoveredClientOnlyComponents.add(cid);
clientOnlys.push(cid); clientOnlys.push(cid);
} }
for(const pageId of getTopLevelPages(id, this)) { for (const pageId of getTopLevelPages(id, this)) {
const pageData = getPageDataByViteID(internals, pageId); const pageData = getPageDataByViteID(internals, pageId);
if(!pageData) continue; if (!pageData) continue;
trackClientOnlyPageDatas(internals, pageData, clientOnlys); trackClientOnlyPageDatas(internals, pageData, clientOnlys);
} }
} }
@ -118,6 +110,6 @@ export function vitePluginAnalyzer(
// Finalize hoisting // Finalize hoisting
hoistScanner.finalize(); hoistScanner.finalize();
} },
}; };
} }

View file

@ -5,6 +5,7 @@ import type { BuildInternals } from './internal.js';
import type { StaticBuildOptions } from './types'; import type { StaticBuildOptions } from './types';
import glob from 'fast-glob'; import glob from 'fast-glob';
import * as fs from 'fs';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import { runHookBuildSsr } from '../../integrations/index.js'; import { runHookBuildSsr } from '../../integrations/index.js';
import { BEFORE_HYDRATION_SCRIPT_ID } from '../../vite-plugin-scripts/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 { serializeRouteData } from '../routing/index.js';
import { addRollupInput } from './add-rollup-input.js'; import { addRollupInput } from './add-rollup-input.js';
import { eachPageData } from './internal.js'; import { eachPageData } from './internal.js';
import * as fs from 'fs';
export const virtualModuleId = '@astrojs-ssr-virtual-entry'; export const virtualModuleId = '@astrojs-ssr-virtual-entry';
const resolvedVirtualModuleId = '\0' + virtualModuleId; const resolvedVirtualModuleId = '\0' + virtualModuleId;
@ -82,7 +82,7 @@ if(_start in adapter) {
internals.staticFiles.add(chunk.fileName); internals.staticFiles.add(chunk.fileName);
} }
} }
for (const [chunkName, chunk] of Object.entries(bundle)) { for (const [chunkName, chunk] of Object.entries(bundle)) {
if (chunk.type === 'asset') { if (chunk.type === 'asset') {
continue; continue;
@ -97,7 +97,7 @@ if(_start in adapter) {
} }
export async function injectManifest(buildOpts: StaticBuildOptions, internals: BuildInternals) { export async function injectManifest(buildOpts: StaticBuildOptions, internals: BuildInternals) {
if(!internals.ssrEntryChunk) { if (!internals.ssrEntryChunk) {
throw new Error(`Did not generate an entry chunk for SSR`); throw new Error(`Did not generate an entry chunk for SSR`);
} }

View file

@ -52,7 +52,8 @@ export class Metadata {
*hoistedScriptPaths() { *hoistedScriptPaths() {
for (const metadata of this.deepMetadata()) { 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) { while (i < metadata.hoisted.length) {
// Strip off the leading "/@fs" added during compilation. // Strip off the leading "/@fs" added during compilation.

View file

@ -113,7 +113,7 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
source, source,
ssr: Boolean(opts?.ssr), ssr: Boolean(opts?.ssr),
viteTransform, viteTransform,
pluginContext: this pluginContext: this,
}; };
if (query.astro) { if (query.astro) {
if (query.type === 'style') { if (query.type === 'style') {
@ -222,7 +222,7 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
const astroMetadata: AstroPluginMetadata['astro'] = { const astroMetadata: AstroPluginMetadata['astro'] = {
clientOnlyComponents: transformResult.clientOnlyComponents, clientOnlyComponents: transformResult.clientOnlyComponents,
hydratedComponents: transformResult.hydratedComponents, hydratedComponents: transformResult.hydratedComponents,
scripts: transformResult.scripts scripts: transformResult.scripts,
}; };
return { return {

View file

@ -2,8 +2,8 @@ import type { TransformResult } from '@astrojs/compiler';
export interface PluginMetadata { export interface PluginMetadata {
astro: { astro: {
hydratedComponents: TransformResult['hydratedComponents'], hydratedComponents: TransformResult['hydratedComponents'];
clientOnlyComponents: TransformResult['clientOnlyComponents'], clientOnlyComponents: TransformResult['clientOnlyComponents'];
scripts: TransformResult['scripts'] scripts: TransformResult['scripts'];
} };
} }

View file

@ -1,13 +1,12 @@
import type { GetModuleInfo, ModuleInfo, OutputChunk } from 'rollup'; import type { GetModuleInfo, OutputChunk } from 'rollup';
import { BuildInternals } from '../core/build/internal'; import { BuildInternals } from '../core/build/internal';
import type { PageBuildData } from '../core/build/types'; import type { PageBuildData } from '../core/build/types';
import crypto from 'crypto'; import crypto from 'crypto';
import esbuild from 'esbuild'; import esbuild from 'esbuild';
import { Plugin as VitePlugin } from 'vite'; 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 { getTopLevelPages, walkParentInfos } from '../core/build/graph.js';
import { getPageDataByViteID, getPageDatasByClientOnlyID } from '../core/build/internal.js';
import { isCSSRequest } from '../core/render/util.js'; import { isCSSRequest } from '../core/render/util.js';
interface PluginOptions { interface PluginOptions {

View file

@ -7,15 +7,14 @@ import matter from 'gray-matter';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import type { Plugin } from 'vite'; import type { Plugin } from 'vite';
import type { AstroConfig } from '../@types/astro'; import type { AstroConfig } from '../@types/astro';
import type { PluginMetadata as AstroPluginMetadata } from '../vite-plugin-astro/types';
import { pagesVirtualModuleId } from '../core/app/index.js'; import { pagesVirtualModuleId } from '../core/app/index.js';
import { collectErrorMetadata } from '../core/errors.js'; import { collectErrorMetadata } from '../core/errors.js';
import { prependForwardSlash } from '../core/path.js'; import { prependForwardSlash } from '../core/path.js';
import { resolvePages, viteID } from '../core/util.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 { PAGE_SSR_SCRIPT_ID } from '../vite-plugin-scripts/index.js';
import { getFileInfo } from '../vite-plugin-utils/index.js'; import { getFileInfo } from '../vite-plugin-utils/index.js';
interface AstroPluginOptions { interface AstroPluginOptions {
config: AstroConfig; config: AstroConfig;
} }
@ -212,7 +211,7 @@ ${tsResult}`;
const astroMetadata: AstroPluginMetadata['astro'] = { const astroMetadata: AstroPluginMetadata['astro'] = {
clientOnlyComponents: transformResult.clientOnlyComponents, clientOnlyComponents: transformResult.clientOnlyComponents,
hydratedComponents: transformResult.hydratedComponents, hydratedComponents: transformResult.hydratedComponents,
scripts: transformResult.scripts scripts: transformResult.scripts,
}; };
return { return {

View file

@ -19,7 +19,7 @@ describe('Astro Markdown with draft posts disabled', () => {
} catch (err) { } catch (err) {
expect(err.code).to.equal('ENOENT'); expect(err.code).to.equal('ENOENT');
} }
expect(renderedDraft).to.equal(false,'Rendered a draft post'); expect(renderedDraft).to.equal(false, 'Rendered a draft post');
}); });
}); });

View file

@ -7,7 +7,7 @@ document.getElementsByTagName = () => [];
document.currentScript = null; document.currentScript = null;
const ceDefine = customElements.define; const ceDefine = customElements.define;
customElements.define = function(tagName, Ctr) { customElements.define = function (tagName, Ctr) {
Ctr[Symbol.for('tagName')] = tagName; Ctr[Symbol.for('tagName')] = tagName;
return ceDefine.call(this, tagName, Ctr); return ceDefine.call(this, tagName, Ctr);
} };

View file

@ -9,7 +9,7 @@ function isCustomElementTag(name) {
function getCustomElementConstructor(name) { function getCustomElementConstructor(name) {
if (typeof customElements !== 'undefined' && isCustomElementTag(name)) { if (typeof customElements !== 'undefined' && isCustomElementTag(name)) {
return customElements.get(name) || null; return customElements.get(name) || null;
} else if(typeof name === 'function') { } else if (typeof name === 'function') {
return name; return name;
} }
return null; return null;
@ -28,7 +28,7 @@ async function check(Component, _props, _children) {
function* render(Component, attrs, children) { function* render(Component, attrs, children) {
let tagName = Component; let tagName = Component;
if(typeof tagName !== 'string') { if (typeof tagName !== 'string') {
tagName = Component[Symbol.for('tagName')]; tagName = Component[Symbol.for('tagName')];
} }
const instance = new LitElementRenderer(tagName); const instance = new LitElementRenderer(tagName);

View file

@ -18,7 +18,7 @@ function getViteConfiguration() {
'@lit-labs/ssr/lib/install-global-dom-shim.js', '@lit-labs/ssr/lib/install-global-dom-shim.js',
'@lit-labs/ssr/lib/render-lit-html.js', '@lit-labs/ssr/lib/render-lit-html.js',
'@lit-labs/ssr/lib/lit-element-renderer.js', '@lit-labs/ssr/lib/lit-element-renderer.js',
'@astrojs/lit/server.js' '@astrojs/lit/server.js',
], ],
}, },
}; };

View file

@ -1,9 +1,9 @@
import type { AstroAdapter, AstroConfig, AstroIntegration, BuildConfig, RouteData } from 'astro'; import type { AstroAdapter, AstroConfig, AstroIntegration, BuildConfig, RouteData } from 'astro';
import type { Plugin as VitePlugin } from 'vite';
import esbuild from 'esbuild'; import esbuild from 'esbuild';
import * as fs from 'fs'; import * as fs from 'fs';
import * as npath from 'path'; import * as npath from 'path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import type { Plugin as VitePlugin } from 'vite';
import { createRedirects } from './shared.js'; import { createRedirects } from './shared.js';
export function getAdapter(): AstroAdapter { export function getAdapter(): AstroAdapter {
@ -109,19 +109,19 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {})
const injectPlugin: VitePlugin = { const injectPlugin: VitePlugin = {
name: '@astrojs/netlify/plugin-inject', name: '@astrojs/netlify/plugin-inject',
generateBundle(_options, bundle) { generateBundle(_options, bundle) {
if(_buildConfig.serverEntry in bundle) { if (_buildConfig.serverEntry in bundle) {
const chunk = bundle[_buildConfig.serverEntry]; const chunk = bundle[_buildConfig.serverEntry];
if(chunk && chunk.type === 'chunk') { if (chunk && chunk.type === 'chunk') {
chunk.code = `globalThis.process = { argv: [], env: {}, };${chunk.code}`; chunk.code = `globalThis.process = { argv: [], env: {}, };${chunk.code}`;
} }
} }
} },
}; };
updateConfig({ updateConfig({
vite: { vite: {
plugins: [injectPlugin] plugins: [injectPlugin],
} },
}); });
}, },
'astro:config:done': ({ config, setAdapter }) => { 'astro:config:done': ({ config, setAdapter }) => {

View file

@ -19,7 +19,7 @@ Deno.test({
const doc = new DOMParser().parseFromString(html, `text/html`); const doc = new DOMParser().parseFromString(html, `text/html`);
const div = doc.querySelector('#thing'); const div = doc.querySelector('#thing');
assert(div, 'div exists'); assert(div, 'div exists');
} catch(err) { } catch (err) {
console.error(err); console.error(err);
} finally { } finally {
await close(); await close();