-
Notifications
You must be signed in to change notification settings - Fork 24
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
line numbers inaccurate #83
Comments
Interesting! Thanks for the detailed report. I'm adding my preliminary reply here but potentially expect more this weekend (the rest of this week is very busy for me). My initial thoughts would be that esbuild/svelte/esbuild-svelte is reporting the error location after it does preprocessing (for typescript etc.), so that screws up the line numbers? Not sure how that works with your js example error though. Rough example (haven't tested, and doesn't include imports/lang declaration) <script>
interface LabeledValue {
label: string;
}
function printLabel(labeledObj: LabeledValue) {
console.log(labeledObj.label);
}
onMount(()=>printLabel({label: "Hello world"}));
</script>
<div> whatever, lets just say error here </div> If the interface code gets removed during preprocessing then that shifts all the line numbers up by 3? Then when an error is found during actual compilation then it uses the incorrect numbers. It would surprise me if Svelte developers hadn't handled that though... Also possible that my recent preprocessor sourcemap change screwed things up somehow, maybe try I'll let you know if I find the problem or think of anything else |
Thanks for the quick reply. I just did some more tests.
I wish I could reproduce this issue in a way I could easily share. EDIT: perhaps it is related to evanw/esbuild#604 and https://github.com/evanw/esbuild/blob/4e25a16bbcf77a6f6714b09fa9401b5029ff00bd/CHANGELOG.md#unreleased
EDIT2: I opened an issue here, not sure if the response is new information to you, but thought I would post here evanw/esbuild#1746 |
This comment was marked as outdated.
This comment was marked as outdated.
Still don't know what happened here, the esbuild's example plugin -- https://esbuild.github.io/plugins/#svelte-plugin does have `start.line - 1` to get the lineText, but that was wrong in my current test. Maybe related: EMH333/esbuild-svelte#83
Still don't know what happened here, the esbuild's example plugin -- https://esbuild.github.io/plugins/#svelte-plugin does have `start.line - 1` to get the lineText, but that was wrong in my current test. Maybe related: EMH333/esbuild-svelte#83
I guess this was definitely a hidden issue in svelte itself… My fresh commit: hyrious/esbuild-plugin-svelte@5b88066 |
After much delay, I think I'm able to recreate this and have added a test in 3617764. My original prediction was correct, but it looks like this is squarely on this plugin to handle, not Svelte.
Update: The svelte language-server handles it properly but includes several things specific to VSCode that I would need to strip out. I need to investigate what other bundler plugins do and if they even handle this properly at all. |
This has been released as a part of |
Describe the bug
We have a fairly large production Svelte app and was trying to migrate off rollup to esbuild. Thanks for your plugin. We are running into an issue I was hoping you can give some hints too. We are running esbuild with
watch
and I am creating fake errors to test the error output so we can hook up an overlay screen. The issue I am running into, is the line numbers for svelte errors are off or strange.AppRoot.svelte
importsLeft.svelte
and the error i introduced does exist atLeft.svelte:321:7
but it is in the"text"
area, not the"location"
To Reproduce
Unfortunately I can't recreate this issue with a blank Svelte app.
Here is my build script though in case it helps.
Expected behavior
Location data would always be present in esbuild output on failure and point to correct line in file.
Environment (please complete the following information):
"svelte-preprocess": "^4.9.8",
"svelte-preprocess-esbuild": "^2.0.0"
Thanks in advance!
The text was updated successfully, but these errors were encountered: