diff --git a/packages/astro/src/vite-plugin-astro/compile.ts b/packages/astro/src/vite-plugin-astro/compile.ts index 5a6e199d7..8c4590967 100644 --- a/packages/astro/src/vite-plugin-astro/compile.ts +++ b/packages/astro/src/vite-plugin-astro/compile.ts @@ -1,5 +1,5 @@ import type { TransformResult } from '@astrojs/compiler'; -import type { SourceMapInput } from 'rollup'; +import type { PluginContext, SourceMapInput } from 'rollup'; import type { AstroConfig } from '../@types/astro'; import type { TransformHook } from './styles'; @@ -33,13 +33,14 @@ function safelyReplaceImportPlaceholder(code: string) { const configCache = new WeakMap(); -interface CompileProps { +export interface CompileProps { config: AstroConfig; filename: string; moduleId: string; source: string; ssr: boolean; viteTransform: TransformHook; + pluginContext: PluginContext; } async function compile({ @@ -49,6 +50,7 @@ async function compile({ source, ssr, viteTransform, + pluginContext, }: CompileProps): Promise { const filenameURL = new URL(`file://${filename}`); const normalizedID = fileURLToPath(filenameURL); @@ -98,6 +100,7 @@ async function compile({ id: normalizedID, transformHook: viteTransform, ssr, + pluginContext, }); let map: SourceMapInput | undefined; diff --git a/packages/astro/src/vite-plugin-astro/index.ts b/packages/astro/src/vite-plugin-astro/index.ts index 3b957d5d5..b0e97c2e0 100644 --- a/packages/astro/src/vite-plugin-astro/index.ts +++ b/packages/astro/src/vite-plugin-astro/index.ts @@ -13,7 +13,7 @@ import { isRelativePath, startsWithForwardSlash } from '../core/path.js'; import { resolvePages } from '../core/util.js'; import { PAGE_SCRIPT_ID, PAGE_SSR_SCRIPT_ID } from '../vite-plugin-scripts/index.js'; import { getFileInfo } from '../vite-plugin-utils/index.js'; -import { cachedCompilation } from './compile.js'; +import { cachedCompilation, CompileProps } from './compile.js'; import { handleHotUpdate, trackCSSDependencies } from './hmr.js'; import { parseAstroRequest } from './query.js'; import { getViteTransform, TransformHook } from './styles.js'; @@ -106,13 +106,14 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu if (isPage && config._ctx.scripts.some((s) => s.stage === 'page')) { source += `\n