Don't overwrite the stack when using verbose logging (#2290)
* Don't overwrite the stack when using verbose logging This makes it so that if the compiler panics and `--verbose` logging is on (debug level), we don't replace the stack trace. * Adds a changeset
This commit is contained in:
parent
ae5255dd25
commit
c77cf52e16
3 changed files with 14 additions and 4 deletions
5
.changeset/soft-frogs-tap.md
Normal file
5
.changeset/soft-frogs-tap.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Preserve wasm stack trace when verbose logging is enabled
|
|
@ -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 }),
|
||||
|
|
|
@ -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,9 +120,12 @@ export default function astro({ config }: AstroPluginOptions): vite.Plugin {
|
|||
Please open
|
||||
a GitHub issue using the link below:
|
||||
${err.url}`;
|
||||
|
||||
if(logging.level !== 'debug') {
|
||||
// TODO: remove stack replacement when compiler throws better errors
|
||||
err.stack = ` at ${id}`;
|
||||
}
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue