GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support for other JSX factories by rwyborn · Pull Request #6146 · microsoft/TypeScript

Conversation

@rwyborn

@rwyborn Rowan Wyborn (rwyborn) commented Dec 18, 2015

Copy link
Copy Markdown

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Rowan Wyborn added 2 commits December 18, 2015 21:56
Rowan Wyborn
Initial check in - Support other JSX factories Issue #3788
b7f6070
- 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)
Rowan Wyborn
Merge branch 'master' into react-factory-option
9d11f2b
@msftclas

Microsoft Contribution License Agreements (msftclas) commented Dec 18, 2015

Copy link
Copy Markdown

Hi Rowan Wyborn (@rwyborn), I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by Microsoft and real humans are currently evaluating your PR.

TTYL, MSBOT;

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-already-signed label Dec 18, 2015
Rowan Wyborn
fix trailing whitespace
2395890
@RyanCavanaugh

Ryan Cavanaugh (RyanCavanaugh) commented Dec 18, 2015

Copy link
Copy Markdown
Member

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 (.createElement) as React.

I'm thinking:

let x = <Foo />;
  • --jsx preserve
    • let x = <Foo />;
  • --jsx react
    • let x = React.createElement(Foo);
  • --jsx react --reactNamespace rt
    • let x = rt.createElement(Foo);
  • --jsx make
    • let x = make(Foo);
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@RyanCavanaugh Ryan Cavanaugh (RyanCavanaugh) mentioned this pull request Dec 18, 2015
Support other JSX factories #3788
Closed
@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Dec 18, 2015

Copy link
Copy Markdown
Member

If you have --jsx make, why exactly do you need --reactNamespace rt?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@unional

Homa Wong (unional) commented Dec 18, 2015

Copy link
Copy Markdown
Contributor

I would suggest to "pollute the global" with a meaningful namespace, such as JSX.make() or JSX.compose(). But simple make() might work too, just that it is a bit less convenience when I customize it in code (i.e. couldn't have a proper singleton such as JSX to hold states, when needed).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rwyborn

Rowan Wyborn (rwyborn) commented Dec 18, 2015

Copy link
Copy Markdown
Author

Ryan Cavanaugh (@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

  • MyDOMHandler.createElement
  • MyDOMHandler.__spread

Client code can then map those to whatever custom library implementation it wants.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tinganho

Tingan Ho (tinganho) commented Dec 19, 2015

Copy link
Copy Markdown
Contributor

Namespace for me, means only MyDOMHandler and not with the method name MyDOMHandler.createElement. createElement is occupying the namespace of MyDOMHandler so itself is not a namespace IMO.

What about?

--react for preserving current behavior of --jsx react.
--jsxElementFactory [value] for defining the factory function for JSX.

I think the option --jsx was a little bit ambiguous. And since --jsx preserve doesn't make so much sense anymore when this got landed maybe deprecate --jsx option?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@unional Homa Wong (unional) mentioned this pull request Jan 2, 2016
Jsx transform #6318
Closed
@RyanCavanaugh

Ryan Cavanaugh (RyanCavanaugh) commented Jan 6, 2016

Copy link
Copy Markdown
Member

Sorry for the delay.

Discussed with Bill Ticehurst (@billti) and Mohamed Hegazy (@mhegazy) and we landed on the following

  • This PR is 👍 (see one comment below)
  • More complex changes to emit semantics will wait until Ron Buckton (@rbuckton) tree-transform-based emitter is checked in. At that point we can re-evaluate (e.g. we may end up with fully-pluggable JSX transforms)

The only change I'd like to see here (other than removal of merge conflicts 😉) is that jsxNamespace should be reactNamepsace since this is specific to React emit (and I don't want confusion with the real namespace JSX { which is not changing names).

Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mhegazy

Mohamed Hegazy (mhegazy) commented Jan 7, 2016

Copy link
Copy Markdown
Contributor

Rowan Wyborn (@rwyborn) please change the option name to reactNamespace and refresh the PR, and we should be good to go.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mhegazy
Mohamed Hegazy (mhegazy) merged commit 2395890 into microsoft:master Jan 7, 2016
@mhegazy

Mohamed Hegazy (mhegazy) commented Jan 7, 2016

Copy link
Copy Markdown
Contributor

merged manually after updating the name and adding tests.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mhegazy

Mohamed Hegazy (mhegazy) commented Jan 7, 2016

Copy link
Copy Markdown
Contributor

thanks Rowan Wyborn (@rwyborn)!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rwyborn

Rowan Wyborn (rwyborn) commented Jan 8, 2016

Copy link
Copy Markdown
Author

Mohamed Hegazy (@mhegazy) I just got back from holiday, thanks for fixing this up!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mhegazy Mohamed Hegazy (mhegazy) mentioned this pull request Jan 13, 2016
Customizable JSX/TSX mode #5546
Closed
@unional

Homa Wong (unional) commented Nov 21, 2016

Copy link
Copy Markdown
Contributor

More complex changes to emit semantics will wait until Ron Buckton (@rbuckton) tree-transform-based emitter is checked in. At that point we can re-evaluate (e.g. we may end up with fully-pluggable JSX transforms)

How is that doing?
It is this one? #6987

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mhegazy

Mohamed Hegazy (mhegazy) commented Nov 21, 2016

Copy link
Copy Markdown
Contributor

Homa Wong (@unional) looks like you are looking for #12135

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@unional

Homa Wong (unional) commented Nov 21, 2016

Copy link
Copy Markdown
Contributor

Thank! I'll take a look at it.

It's been a while ago, I need to refresh what is my original needs. 🌷

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@rwyborn @msftclas @RyanCavanaugh @DanielRosenwasser @unional @tinganho @mhegazy
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.