Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: preprocess error reporting #260

Merged
merged 2 commits into from
Jan 27, 2022
Merged

Conversation

dominikg
Copy link
Member

see #259

include stack and filename in errors thrown from svelte.preprocess

This should give people enough information to track it down. new output looks like this

Error while preprocessing /home/dominikg/develop/sveltejs/vite-plugin-svelte/packages/playground/kit-demo-ts/src/routes/__layout.svelte - Cannot read properties of undefined (reading 'split')
TypeError: Error while preprocessing /home/dominikg/develop/sveltejs/vite-plugin-svelte/packages/playground/kit-demo-ts/src/routes/__layout.svelte - Cannot read properties of undefined (reading 'split')
    at Object.parseAttributes (/home/dominikg/develop/sveltejs/vite-plugin-svelte/node_modules/.pnpm/svelte-preprocess@4.9.0_svelte@3.46.2+typescript@4.5.5/node_modules/svelte-preprocess/dist/modules/markup.js:19:10)
    at getScriptContent (/home/dominikg/develop/sveltejs/vite-plugin-svelte/node_modules/.pnpm/svelte-preprocess@4.9.0_svelte@3.46.2+typescript@4.5.5/node_modules/svelte-preprocess/dist/transformers/typescript.js:47:38)
    at injectVarsToCode (/home/dominikg/develop/sveltejs/vite-plugin-svelte/node_modules/.pnpm/svelte-preprocess@4.9.0_svelte@3.46.2+typescript@4.5.5/node_modules/svelte-preprocess/dist/transformers/typescript.js:83:20)
    at mixedImportsTranspiler (/home/dominikg/develop/sveltejs/vite-plugin-svelte/node_modules/.pnpm/svelte-preprocess@4.9.0_svelte@3.46.2+typescript@4.5.5/node_modules/svelte-preprocess/dist/transformers/typescript.js:205:26)
    at transformer (/home/dominikg/develop/sveltejs/vite-plugin-svelte/node_modules/.pnpm/svelte-preprocess@4.9.0_svelte@3.46.2+typescript@4.5.5/node_modules/svelte-preprocess/dist/transformers/typescript.js:275:11)
    at Object.exports.transform (/home/dominikg/develop/sveltejs/vite-plugin-svelte/node_modules/.pnpm/svelte-preprocess@4.9.0_svelte@3.46.2+typescript@4.5.5/node_modules/svelte-preprocess/dist/autoProcess.js:37:12)
    at async /home/dominikg/develop/sveltejs/vite-plugin-svelte/node_modules/.pnpm/svelte-preprocess@4.9.0_svelte@3.46.2+typescript@4.5.5/node_modules/svelte-preprocess/dist/autoProcess.js:113:29
    at async script (/home/dominikg/develop/sveltejs/vite-plugin-svelte/node_modules/.pnpm/svelte-preprocess@4.9.0_svelte@3.46.2+typescript@4.5.5/node_modules/svelte-preprocess/dist/autoProcess.js:143:33)
    at async process_single_tag (file:///home/dominikg/develop/sveltejs/vite-plugin-svelte/node_modules/.pnpm/svelte@3.46.2/node_modules/svelte/compiler.mjs:32106:27)
    at async Promise.all (index 0)

Note: stack is omitted during dev for errors that include a code frame unless DEBUG environment variable is set. This is done to keep the noise down for compiler errors. The stack is huge and spammy and not nearly as helpful as the frame and message, in most cases.

@dominikg
Copy link
Member Author

@benmccann i think this is be best we can do from vite-plugin-svelte's side. For more information, svelte.preprocess or the preprocessor itself would have to add it to the error.

The stacktrace should give a pretty good idea of which preprocessor is at fault and the filename of the file it broke should help in reporting it to that.

Copy link
Member

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is way better. Thank you!

@dominikg dominikg merged commit d7c1618 into main Jan 27, 2022
@dominikg dominikg deleted the fix/preprocess-error-reporting branch January 27, 2022 13:45
@github-actions github-actions bot mentioned this pull request Jan 27, 2022
@github-actions github-actions bot mentioned this pull request Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants