Closed conartist6 closed 8 years ago
As long as you're ready to maintain the code (i.e. fix problems with it) I'd love to get further sourcemap improvements into ng-annotate so hack away! :-)
Sure, I can do that. I'll see what I can work up.
:+1:
There are also two other open sourcemap issues - one that I think should be easy to fix (perhaps as a side-effect of your planned PR) and the other one bigger. #201 and #202. :-)
ngAnnotate sourcemaps are generally bad citizens that tend to expose the buggiest side of sourcemap implementations especially when they are one of many source mapping steps which need to be combined into a single map definitive map.
The reason is that ngAnnotate tokenizes the code and then emits a mapping for every token. When other upstream transformations generate mappings that are less granular than ngAnnotate's all hell breaks loose. I've crashed sourcemap debuggers with the results and seen dev tools do the wildest things.
The solution is simple, emit only line mappings when at all possible, like such:
Maps to -> line 1 pos 0 maps to line 1 pos 0 line 2 pos 4 maps to line 2 pos 4 line 3 pos 0 maps to line 3 pos 0 line 5 pos 0 maps to line 4 pos 0
In my testing output like the above works great. I have a patch that does the above, but mine assumes that it will always be using $inject and never creating an inline injection parameter. I'd be willing to help get it right for both cases, but I'd like to be sure there's interest first.