ef4 / fast-sourcemap-concat

Fast sourcemap generation & concatenation.
16 stars 31 forks source link

consider a fast sourcemap mode where we map only to files, but have no inter-file mappings #32

Open hjdivad opened 7 years ago

hjdivad commented 7 years ago

This would enable things like ⌘-o in chrome to open "files" without incurring the overhead of mapping individual names within input files.

It's a compromise idea intended to be a balance between performance and productivity.

cc @stefanpenner

ef4 commented 7 years ago

This would have the potential to massively troll people. We would need to map an entire input file to some place (presumably the first line) in the original file. That will cause all stack traces and breakpoints to look like they're happening on that line.

The implementation this addon already uses when there are no input sourcemaps is already about as low-resolution as you can do: it maps lines 1-to-1, doesn't maintain any within-line mappings, and doesn't try to map identifiers.

stefanpenner commented 7 years ago

@ef4 the idea is to offer people an optional low-resolution mode. That gives per-file debugging experience. Today, we offer high fidelity, or no fidelity.

ef4 commented 7 years ago

How low resolution? Because if it's any lower than lines, it will be super painful to use.

It's not possible to just get a pleasant ⌘-o without also breaking everybody's stack traces.

ef4 commented 7 years ago

I think a better way to do the low resolution thing you're describing is to produce non-concatenated builds.

stefanpenner commented 7 years ago

@ef4 you are correct, the babel module shifting (which we do get today) would pwn stack traces. But, for things in vendor (things we ourselves don't transpile). We likely wouldn't pwn stack traces then. hmmm...

stefanpenner commented 7 years ago

It seems like to get fast concats, sans loading 5000-8000 script tags / http pushes (as you propose) for big apps. is Investing in https://github.com/krisselden/fast-source-map or explorer the sourcemap "Sections" stuff for supported browsers may be the best path forward..

I really wish sourcemaps, had some small tweaks to them. Could make this all be a non-problem.


I should investigate actually, if 5000/8000 HTTP pushes are reasonable for dev or not. I honestly don't know.

ef4 commented 7 years ago

But, for things in vendor (things we ourselves don't transpile). We likely wouldn't pwn stack traces then. hmmm...

They would still get pwned. As long as they are concatenated and there is a sourcemap present, if you don't have line numbers for each line the stack traces will be broken.

It may be possible that browsers will intelligently interpolate if you leave gaps in the sourcemap and simply adjust the start point of each file. But I am dubious. It would be easy to test if somebody wants to hand-craft a tiny sourcemap for the concatenation of two files that contains only mappings for the start of each.

stefanpenner commented 7 years ago

@ef4 yes, but it should be sufficiently efficient to adjust those line mappings, but continue to disregard the input maps for this "low resolution" map. In-browser debugging would be fine, although char/char back to true source would not be.

ef4 commented 7 years ago

That would be a simple change. Just an ignoreInputMap: true option, at which point we will go down our existing pretty-fast adjustment path.

stefanpenner commented 7 years ago

@ef4 ya, I suspect we did a poor job explaining our goal above (we largely left this issue as a placeholder so we wouldn't forget) but that is more or less what we were trying to articulate.