Proposal: Limit sourcemap support to bundled/optimized/minified output in v3.0 #1876
Replies: 12 comments 14 replies
-
I'll just echo a sentiment expressed in many of the other sourcemap threads: not being able to debug with external tooling like VS Code is a big papercut. This isn't limited to languages like TypeScript either. Babel in particular likes to generate code that is onerous to read + difficult to set breakpoints in. Perhaps there's a better solution than sourcemaps for this, In which case I'd have no objections. Or perhaps Snowpack could present this up-front as a philosophical decision—it's fine to be opinionated! In the absence of either of those though, claiming that sourcemap-less debugging is generally preferable and should only be done in browser devtools doesn't sit particularly well. Edit: I'm not sure how sourcemaps are necessarily in conflict with 1:1 file builds either. The first paragraph talks about a "big JS bundle", but I was using per-file sourcemaps with TypeScript back in Snowpack 1.0! |
Beta Was this translation helpful? Give feedback.
-
As someone who has been in the sourcemap trenches on many occasions, I relate to the drawbacks listed above. But sourcemaps really are essential, particularly for those of using things like Svelte and Vue, and whatever other compile-to-JS tools come to exist in future (the last thing we want is for future toolmakers to recommend against using Snowpack because it makes debugging impossible). To say that debugging without sourcemaps is somehow 'preferable' really doesn't bear scrutiny, in my view. Developer iteration speed is hindered by slow transformations, yes. But it's hindered a lot more by anything that prevents efficient debugging. Given Snowpack's nature it would have to be an egregiously slow plugin for it to have a noticeable impact outside the cold start scenario. I'd also push back on the notion that sourcemaps are more valuable for a production build. They're useful in production if you're using something like Sentry, but in general, you're likely to encounter errors and warnings far more frequently during development (as the code is still being written) than in production.
This is changing! It has always been our intention to fully support sourcemaps with preprocessors, and we recently shipped a version that includes sourcemap support, with more work planned. |
Beta Was this translation helpful? Give feedback.
-
As someone who uses a Stylus -> PostCSS -> CSS chain, source map support is a good feature for me. In my use-case, I actually made a plugin to properly compile and include source maps with my CSS. However, this compile-chain means that to translate CSS back to Stylus in-browser requires source-maps, regardless of EDIT: I'll also say, albeit slightly unrelated, that due to bundling, optimization, etc. there is/can-be significant differences between the |
Beta Was this translation helpful? Give feedback.
-
I agree that small modifications, like injecting HMR code, is generally not a huge dealbreaker. In the context of the snowpack plugin for web test runner, one challenge for us is that snowpack changes the paths of files (a file at |
Beta Was this translation helpful? Give feedback.
-
There are about 150 engineers in my direct group at work and over 1000 at the company. I'm working on an internally facing React/TS web app. In our case there are many people making PRs to our code base who aren't front-end developers and overall don't need to care about complexities of the front-end world (my team takes care of that). Not being able to see the true source code in the browser during debugging and stepping through would be a big disconnect in our case. This especially applies to call stacks during run time errors. I started evaluating snowpack as webpack alternative and just hit the "sourcemap issue". I would have to echo what others have said as well. For snowpack to become part of the enterprise world, source maps would have to be fully supported. |
Beta Was this translation helpful? Give feedback.
-
I just want to echo that especially for things Svelte, source-maps are essential. The code which appears in your browser bears no relation to the original Svelte code you wrote, and is therefore incredibly difficult to debug. I've lost many hours already when developing relatively trivial apps which I'm using Snowpack for. In my mind, sourcemaps are absolutely critical. If development speed is a concern, then by all means provide a way to turn sourcemaps off in configuration, but equally, in terms of development speed, without sourcemaps, trying to debug compiled Svelte output is so difficult, obtuse and time consuming that I'm actually slower with Snowpack, as it currently stands. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the feedback everyone! @antony @alexgorbatchev @LarsDenBakker @Monkatraz @Rich-Harris @ToucheSir thank you for taking the time to comment and share your experience. As someone who doesn't use sourcemaps myself (and only sees the maintenance overhead) this was a good reminder of how much value they still bring to others. Resolution: Proposal rejected, we'll continue to support source maps in dev in v3.0 and will work to fix any known bugs in our source map support before v3.0 is released. |
Beta Was this translation helpful? Give feedback.
-
Regarding the maintenance overhead, https://github.com/Rich-Harris/magic-string is excellent for simple string manipulation while updating the source maps. |
Beta Was this translation helpful? Give feedback.
-
Great news! Does this mean we will have source maps working for TypeScript for v3.0? |
Beta Was this translation helpful? Give feedback.
-
Its great that you've decided to keep sourcemap support. I generally have sourcemaps turned off as well and very rarely even look at the sources tab in chrome, let alone hook it up to my ide. I've also done a bunch of source-map handling myself, and I know how brittle it can be. |
Beta Was this translation helpful? Give feedback.
-
Not exclusively for React and TypeScript developers, also userfull for vanilla js 😁 !
A think a picture is worth 1000 words !! allow debugging in vscode give a lot of feature and powerful tool for diagnostic.
I agree with the comments above ! i think this is the last crucial thing that SnowPack lacks. (allow pro debugging with IDE) |
Beta Was this translation helpful? Give feedback.
-
Maybe those can be a solution for implementation ? |
Beta Was this translation helpful? Give feedback.
-
Note: We are looking for constructive feedback from the Snowpack community! This is not a decision that we are 100% on, and your feedback matters!
Background
Sourcemaps allow you to map any line of code in a built JS file to the original line in a source file (JS, JSX, TS, Svelte, Vue, etc). Sourcemaps can be an invaluable debugging tool in browsers, letting you step through a big JS bundle line-by-line in your debugger, but see the original source code that each line maps to.
But sourcemaps have some drawbacks:
In bundled output, it is more likely that the pros outweigh the cons, since a giant compiled 10000+ line JS file is impossible to map back to any individual source code file without some help. In Snowpack, however, we build each file 1:1 during dev. This makes debugging without a source map possible and in many ways, preferable. While compiled output is generally less easy to read than source code, in the context of a single file you can mentally map the source file to the output 1:1, and get the benefit of debugging the actual code that the browser is running (without the cons mentioned above).
For this reason, Snowpack has always had limited sourcemap support. For Snowpack v3.0, I'd like us to finally decide whether we fully support sourcemaps (and fix all outstanding bugs) or whether we explicitly do not support them during dev (and reduce maintenance cost for us and our plugin authors aka ship new features faster).
Proposal
optimize
, Webpack, Rollup, etc)optimize
, Terser, etc).snowpack dev
build outputsnowpack build
outputThis proposal is built on two main ideas:
Impact
Keep in mind that most files are already minimally transformed in Snowpack:
import.meta
HMR + env support.import.meta
import.meta
Svelte and Vue are two groups that do see more aggressive transformations, since Single File Components (SFCs) aren't as close to JS as JSX & TypeScript.
Although note that Svelte itself also has limited sourcemap support related to preprocessors.Fast Refresh is another factor that can lead to more aggressive code transformations that might make mental source->build output mapping difficult. If we decide to stop supporting source maps during development then we should also work with those plugin authors to make sure that the compiled output doesn't completely break the structure of the source code.
/cc @snowpackjs/maintainers @Rich-Harris @JoviDeCroock
Beta Was this translation helpful? Give feedback.
All reactions