diff --git a/.changeset/soft-frogs-tap.md b/.changeset/soft-frogs-tap.md new file mode 100644 index 000000000..7f9b58ac9 --- /dev/null +++ b/.changeset/soft-frogs-tap.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Preserve wasm stack trace when verbose logging is enabled diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index 9e6dc419c..80fd870c0 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -50,7 +50,7 @@ export async function createVite(inlineConfig: ViteConfigWithSSR, { astroConfig, }, plugins: [ configAliasVitePlugin({ config: astroConfig }), - astroVitePlugin({ config: astroConfig, devServer }), + astroVitePlugin({ config: astroConfig, devServer, logging }), markdownVitePlugin({ config: astroConfig, devServer }), jsxVitePlugin({ config: astroConfig, logging }), astroPostprocessVitePlugin({ config: astroConfig, devServer }), diff --git a/packages/astro/src/vite-plugin-astro/index.ts b/packages/astro/src/vite-plugin-astro/index.ts index 8fae5dc3b..484949823 100644 --- a/packages/astro/src/vite-plugin-astro/index.ts +++ b/packages/astro/src/vite-plugin-astro/index.ts @@ -1,5 +1,6 @@ import type vite from '../core/vite'; import type { AstroConfig } from '../@types/astro'; +import type { LogOptions } from '../core/logger'; import esbuild from 'esbuild'; import { fileURLToPath } from 'url'; @@ -11,11 +12,12 @@ import { cachedCompilation, invalidateCompilation } from './compile.js'; const FRONTMATTER_PARSE_REGEXP = /^\-\-\-(.*)^\-\-\-/ms; interface AstroPluginOptions { config: AstroConfig; + logging: LogOptions; devServer?: AstroDevServer; } /** Transform .astro files for Vite */ -export default function astro({ config }: AstroPluginOptions): vite.Plugin { +export default function astro({ config, logging }: AstroPluginOptions): vite.Plugin { let viteTransform: TransformHook; return { name: '@astrojs/vite-plugin-astro', @@ -118,8 +120,11 @@ export default function astro({ config }: AstroPluginOptions): vite.Plugin { Please open a GitHub issue using the link below: ${err.url}`; - // TODO: remove stack replacement when compiler throws better errors - err.stack = ` at ${id}`; + + if(logging.level !== 'debug') { + // TODO: remove stack replacement when compiler throws better errors + err.stack = ` at ${id}`; + } } throw err;