Giter Club home page Giter Club logo

Comments (6)

jeberly avatar jeberly commented on May 26, 2024 2

Thanks for the quick reply. I just did some more tests.

  1. by downgrading to esbuild-svelte: v0.5.6 line numbers still off
  2. removed svelte-preprocess-esbuild and let sveltePreprocess do ts transpilation. Numbers reported were very low like line 3 instead of line 250

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

You must not be using esbuild as a bundler. When bundling, esbuild needs to assume that it's not seeing a partial file because the bundling process requires renaming symbols to avoid cross-file name collisions.

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

from esbuild-svelte.

EMH333 avatar EMH333 commented on May 26, 2024

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 esbuild-svelte: v0.5.6?

I'll let you know if I find the problem or think of anything else

from esbuild-svelte.

EMH333 avatar EMH333 commented on May 26, 2024

Could be related to sveltejs/svelte#6440 and maybe sveltejs/svelte-preprocess#377

I still haven't had time to look into this closely, but definitely on my radar

from esbuild-svelte.

hyrious avatar hyrious commented on May 26, 2024

I guess this was definitely a hidden issue in svelte itself…

My fresh commit: hyrious/esbuild-plugin-svelte@5b88066

from esbuild-svelte.

EMH333 avatar EMH333 commented on May 26, 2024

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.

The solution could get complex because it needs to undo the work done by the preprocessors to find the original line of source. This likely involves some sourcemap work so I'll need to figure out the best way to approach this

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.

from esbuild-svelte.

EMH333 avatar EMH333 commented on May 26, 2024

This has been released as a part of v0.8.0. Thank you for your patience! Please open new issues if you discover any bugs!

from esbuild-svelte.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.