Skip to content
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

Suggestion: drop dependency on React.createElement #207

Closed
axefrog opened this issue May 7, 2018 · 2 comments · Fixed by #210
Closed

Suggestion: drop dependency on React.createElement #207

axefrog opened this issue May 7, 2018 · 2 comments · Fixed by #210

Comments

@axefrog
Copy link

axefrog commented May 7, 2018

Not sure if you're aware, but JSX is used for other projects too, such as virtual-dom, snabbdom, surplus and others. It would definitely be worthwhile making the element factory function configurable, rather than hardcoding it to React.createElement.

@alangpierce
Copy link
Owner

alangpierce commented May 7, 2018

Makes sense! I've wanted to keep it low-configuration with good defaults, but agreed that non-React JSX would be good to support.

From the docs for https://github.com/Swizz/snabbdom-pragma, looks like I can probably just add a new option jsxPragma that's a string for the code to use instead of React.createElement. Note that the React needs to get transformed to _react2.default in some cases (example), so it's a little less trivial than just dropping the new code in, but still shouldn't be so bad, I think.

@axefrog
Copy link
Author

axefrog commented May 7, 2018

Snabbdom's a popular example, but there are many other projects too, so it might not be quite as simple as that, as you'd only be able to say you support projects that explicitly implement that feature. Keep the sensible default, I agree, but being able to optionally override the name of the factory function would allow everyone to use sucrase as-is, without bothering you about it, and without bothering the owners of whatever platforms they want to integrate with.

Just my $0.02 :)

alangpierce added a commit that referenced this issue May 19, 2018
Fixes #208

Configuration for the pragma will wait until I implement #207.
alangpierce added a commit that referenced this issue May 19, 2018
Fixes #208

Configuration for the pragma will wait until I implement #207.
alangpierce added a commit that referenced this issue May 20, 2018
Fixes #207

As with Babel, we assume the pragma is a dot-separated list of identifiers (or
just an identifier), which we parse so that we can replace the base name if
necessary.
alangpierce added a commit that referenced this issue May 20, 2018
Fixes #207

As with Babel, we assume the pragma is a dot-separated list of identifiers (or
just an identifier), which we parse so that we can replace the base name if
necessary.
alangpierce added a commit that referenced this issue May 20, 2018
Fixes #207

As with Babel, we assume the pragma is a dot-separated list of identifiers (or
just an identifier), which we parse so that we can replace the base name if
necessary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants