babel-jsx-lit-html icon indicating copy to clipboard operation
babel-jsx-lit-html copied to clipboard

Syntax propositions

Open jmaguirrei opened this issue 5 years ago • 0 comments

Hi!

Are you using this plugin in a real app?

I come from React apps world and want to try lit-html as a renderer target because of it's simplicity, performance and logical step towards web-components.

But, I still want to be able to write JSX in the render method of my components, because:

  • JSX can be mapped to React or any other library with the same nested-calls structure (like hyperscript). This also means that this plugin could be converted to (for example) hyperscript-to-lit using the same logic.
  • There are already a lot of components written in React, that could be used in non-react apps (with this plugin for example)
  • It would be "a dream" to take a purely functional React app and change "a little Babel" and have other rendering engine doing the same job (for example lit-html).

In terms of the syntax, what I found non-react compliant was the following:

  • Event Handlers: In React on-click is not a valid property, is it possible to transform any on followed by a capital letter to the correspondent @ form?
  • Event Handlers mapping: Related to the former, in lit-html there is no 1-1 mapping to React events, so for example the <input onChange={onChange} /> should be transpiled to <input @input=${onChange} />.
  • Attributes: In React type$='text' is not a valid property. Is there any way to avoid writting the $(for example have a collection of property names or detect if it's mapped to a string).

Thanks

jmaguirrei avatar Dec 21 '18 13:12 jmaguirrei