-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Support for other JSX factories #6146
Conversation
- added jsxNamespace compile option - when jsx mode is "react", jsxNamespace optionally specifies the emit namespace for React calls, eg "--jsxNamespace MyDOMLib" will emit calls as MyDOMLib.createElement (instead of React.createElement) - symbol specified by jsxNamespace must be present, else compile error is generated (same handling as is done for React symbol when no jsxNamespace is specified)
Hi @rwyborn, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! The agreement was validated by Microsoft and real humans are currently evaluating your PR. TTYL, MSBOT; |
I think we need to tweak the naming a bit here. This change is still very useful but doesn't directly address #3788 because it still requires that the library have the same shape ( I'm thinking: let x = <Foo />;
|
If you have |
I would suggest to "pollute the global" with a meaningful namespace, such as |
@RyanCavanaugh I had exactly the same thought originally re: your --jsx make example. The problem is this doesn't define what to do with the JSX spread handling, which emits a call to React.__spread. So my compromise was to let the namespace be configured instead, ie --jsxNamespace MyDOMHandler emits
Client code can then map those to whatever custom library implementation it wants. |
What about?
I think the option |
Sorry for the delay. Discussed with @billti and @mhegazy and we landed on the following
The only change I'd like to see here (other than removal of merge conflicts 😉) is that Thanks! |
@rwyborn please change the option name to |
merged manually after updating the name and adding tests. |
thanks @rwyborn! |
@mhegazy I just got back from holiday, thanks for fixing this up! |
Thank! I'll take a look at it. It's been a while ago, I need to refresh what is my original needs. 🌷 |
PR for Issue #3788
Current implementation adds a new jsxNamespace compile option that can specify the JSX namespace (factory) when jsx mode is react.
--jsx react --jsxNamespace MyDOMLib
results in emits being MyDOMLib.createElement
I was thinking an alternative would be to just use the existing --jsx option where "preserve" and "react" are special reserved values. In this setup the above would be achieved by just doing
-- jsx MyDOMLib