evanw / esbuild

An extremely fast bundler for the web
https://esbuild.github.io/
MIT License
38.08k stars 1.14k forks source link

Feature Request: Minify Nested SourceMaps when one or more Plugins are used to change the input. #3844

Open mitcoding opened 2 months ago

mitcoding commented 2 months ago

while trouble shooting css sourcemap issue reported here, I found that esbuild doesn't merge nested SourceMaps. I think it would be a good idea for esbuild to handle this natively instead of having to use a javascript lib like sorcery as esbuild can handle doing that in memory while that lib currently only supports writing to the fs first. On top of that it should help with performance when plugins are required to do additional transpiling that esbuild has no plans of sporting natively like SASS.

evanw commented 2 months ago

That's strange because esbuild does merge nested source maps, and has for many years (since version 0.6.5). Here is an example. As you can see from the source map visualization, the final source map maps all the way back to the original code (respecting the nested source map) instead of the intermediate code (ignoring the nested source map).

I'm marking this issue as unactionable because it lacks any reproduction instructions, so there's nothing I can do with it.

mitcoding commented 2 months ago

I just uploaded the bundle files that cause the issue. with that said the specific merge I'm asking for that sorcery does that esbuild doesn't do, which you can see by removing sorcery step in the example repository is that sorcery minifies the nested source maps. as I had stated in the origional issue opened with esbuild-sass-plugin without sorcery the final map file is twice as large because it includes source code for origional files and the initial bundled sass version generated by sass-embeded.

https://github.com/mitcoding/esbuild-sass-source-map-issue