diff --git a/.changeset/smart-crabs-lick.md b/.changeset/smart-crabs-lick.md new file mode 100644 index 000000000000..05f603cfc359 --- /dev/null +++ b/.changeset/smart-crabs-lick.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': minor +--- + +feat: redact internal stack trace when reporting config errors diff --git a/packages/kit/src/core/config/index.js b/packages/kit/src/core/config/index.js index a6e37d794277..cb2a44670bfd 100644 --- a/packages/kit/src/core/config/index.js +++ b/packages/kit/src/core/config/index.js @@ -69,7 +69,15 @@ export async function load_config({ cwd = process.cwd() } = {}) { const config = await import(`${url.pathToFileURL(config_file).href}?ts=${Date.now()}`); - return process_config(config.default, { cwd }); + try { + return process_config(config.default, { cwd }); + } catch (e) { + const error = /** @type {Error} */ (e); + + // redact the stack trace — it's not helpful to users + error.stack = `Could not load svelte.config.js: ${error.message}\n`; + throw error; + } } /**