Plugins: Add plugins API and JSX support #68
Conversation
🦋 Changeset detectedLatest commit: 0c332f1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
manuel3108
left a comment
There was a problem hiding this comment.
This was a really fast one! Thanks for your work. I really like the idea of making stuff pluggable as you did here. Also seperating the TS and JS parts totally makes sense.
Haven't been able to play around with this, but left comments here and there, nothing large though.
Further thoughts (that i might be able to answer myself once play around with this):
- is the README updated?
- is this potentially breaking in any way? Try around with a local svelte install, as we had unexpected issues with this before
- If someone for some reason that i don't understand right would like to change the behavior of printing
Literal, but still use all the other parts fromesrap. is this possible? I think it should be, but untested as well
No, not yet, will add docs.
i don't believe so, as unless you pass custom handlers, it defaults to
yes! you just need to do something like print(..., {
handlers: {
...ecmascript,
Literal(node, state) {
state.commands.push('this is my really cool literal that overrides the default one!');
}
}
}) |
Nitpicky, but it does make things more clear
|
i can't test on svelte right now, my |
commit: |
|
Thank you! This is a wonderful start. For this to be truly pluggable, visitors can't rely on internals like Tested with |
|
This could probably use some more JSX tests (for now I've just marked JSX support as experimental), but other than that I think it's ready for review. The one thing I can't figure out is the type errors I'm seeing on sveltejs/svelte#16188 |
elliott-with-the-longest-name-on-github
left a comment
There was a problem hiding this comment.
LGTM, very clean overall.
AFAICT whatever typing issues we're seeing are coming from the fact that:
Contextis not generic (but should be)- When made generic, TypeScript throws a fit about index signatures and mismatches between
Visitors<T>andBaseNodetypes.
I'm pretty stumped on it as well.
I believe the title to be self-explanatory.
Used the API suggested by Rich Harris, with some slight tweaks in naming.