-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instead of rewriting the source, what about creating a sourcemap? #182
Comments
A great idea! Do you know anything about creating sourcemaps with Babel or similar tools? I think usually Babel creates sourcemaps that start from the original file and you end up with a sourcemap mapping from the end result (e.g. a minified file) to the original file. In Humanify's case we'd need to do the reverse: Start with a minified file, apply Prettier, Webcrack and Babel transformations, and end up with a source map mapping from the original (minified) file to the end result (un-minified file). If anybody has ideas on how to do this with any existing tools, I'd be happy to give it a look |
Renaming itself has many edge cases ( Here's a snippet to reverse it: https://gist.github.com/j4k0xb/0d76d103db9696b515ce9c51c45b76b8
and you probably need a way to combine multiple source-maps |
^Big agree on this.
I haven't looked deeply into this, but I switched from Even if neither of these tools can; I wonder if it would be possible to take the 'before formatting' and 'after formatting' code, and then generate a sourcemap based on the diff between them? See also: |
It will be challenging to compare before and after to generate the sourcemap. I didn't look into humanity's source code detailly, but you should be able to let babel generate the sourcemap since most of the operation is renaming. Prettier does not support sourcemap, but I have no idea what other alternatives provide this functionality. |
I have tried using https://github.com/Rich-Harris/magic-string to do some code transformation with source map support, but I'm not sure if it fits into the use case here. |
No description provided.
The text was updated successfully, but these errors were encountered: