ryansolid / babel-plugin-jsx-dom-expressions

A JSX to DOM plugin that wraps expressions for fine grained change detection
MIT License
60 stars 10 forks source link

Bad transpiling when using @babel/preset-env to transform ES6+ code #5

Closed raulgg closed 5 years ago

raulgg commented 5 years ago

Hi Ryan, I'm setting up a new project in which I want to use Solid.js to test your library and I found a very minimal issue when trying it with babel presets.

I'm using using @babel/preset-env and I first set it up without specifying a target for browserlist, which would transform every ES6+ code. As a result the transpiled code wouldn't work, getting the following:

var _el$ = _tmpl$["content.firstChild.cloneNode"](true);

Instead of:

var _el$ = _tmpl$.content.firstChild.cloneNode(true);

I dug a bit into the plugin's code, but my knowledge on @babel/types API is very limited. I tried using memberExpressions instead of the identifiers with dot notation name in them, but they would need to be computed expressions and that wouldn't work either.

Anyway, this shouldn't be an important issue as it only happens when trying to transform code to support old browsers. But someone might hit a snag in here if they don't set up a proper target.

Thank you and congratulations for this great idea of Solid.

ryansolid commented 5 years ago

Thanks for reporting this issue. I didn't realize the way I had written it had any negative side effects. I believe I have fixed this now. Please let me know if you continue to have issues.

raulgg commented 5 years ago

Thank you Ryan for making the changes. I tested the fix and it's transpiling the code correctly.