-
Notifications
You must be signed in to change notification settings - Fork 26
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
A babel-plugin would be nice! #68
Comments
My plan was to hold off on a babel plugin until/if I switched the compiler to Babel, because that would make it much easier. With the current code, I'd have to go babel AST -> plain JS -> Surplus compiler -> reparse babel AST, and I'd have to do all that in a way that preserved incoming and outgoing sourcemaps. Do you know if there are any babel plugins that have to go to plain sourcecode and back? If there are, it might be easy to copy and modify them. |
Although that path is less ideal, it definitely seems possible. Looks like you could use
If Surplus does not yet accept an incoming source map, that might be a problem, but at least it would work. On a different path, you may have better luck just using Recast from scratch. Using Recast is really easy, the API is really nice. It supports I found this to be helpful: https://astexplorer.net/. Once you have the AST, you can inspect it there to see what it looks like. There's a lot of neat tools here that you can use along the way: https://github.com/estools, for example It becomes easy as DOM manipulation once you have the nodes. For example, once you have the AST you can use https://github.com/estools/estraverse to traverse them. You might be able to use https://github.com/estools/esquery to find exactly specific nodes you want to manipulate. If you investigate all those tools and plan which ones to use, I bet you could write a whole new transform faster than the time it'll take for you to iron the limitations with source maps that your original compiler has, and you'll end up with perfect source maps from Recast! 👍 |
So we can use it with
@babel/register
(f.e. in an Electron app).The text was updated successfully, but these errors were encountered: