You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using https://unpkg.com/@babel/standalone@7.24.3/babel.min.js
...
(sorry for jQuery use here, its just a test case)
const c = $('script[type="text/babel"]').text()
var js = Babel.transform(c, { presets: ["react","es2015-no-commonjs"] }).code;
$("body").append($('<script type="module">').text(js))
...
<script type="text/babel" data-type="module" data-presets="react">
.......
.....Some react app stuff here
....
console.log({...tags,[newTag.current.key]:newTag.current.val}) //This is the important line, the thing here is to construct a new object from tags props adding a new key:value to the new object
....
</script>
This line is transpilled to:
console.log(_defineProperty({}, newTag.current.key, newTag.current.val));
loosing the prev tags object props...
I had to change this line to this in order to be well transpilled:
setTags({...tags,...{[newTag.current.key]:newTag.current.val}}) //Notice that now the new prop is encapsulated in a seconly destructured object, and now this is well interpreted as:
setTags({
...tags,
..._defineProperty({}, newTag.current.key, newTag.current.val)
});
Configuration file name
No response
Configuration
No response
Current and expected behavior
Tested the code widthout transpilling and works well so I supouse it is well formed.
Sorry if i dont make the ticket well, I just worked around, but think this could be a problem for someon else and too dificult to describe in a search engine.
Thnx in advance.
The text was updated successfully, but these errors were encountered:
Hey @marionicolas! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.
I dont, maybe Im doing something wrong?
Makes me think to ways, is there a way of setting a prest for no-commonjs but without es2015? (if there is, my fault)
But, if this pereset exists (the one i麓m using now), shouldnt it work ok? I mean, this error in transpilling could be weeeery difficult to debug because, it changes the way the result is affected but no error thrown and no alert of the situation, if one dont imagine something like this could happen in a more complex scenario... could be much of a problem to detect.
Sorry for my english thoug.
馃捇
How are you using Babel?
Programmatic API (
babel.transform
,babel.parse
)Input code
Using https://unpkg.com/@babel/standalone@7.24.3/babel.min.js
<script type="text/babel" data-type="module" data-presets="react"> ....... .....Some react app stuff here .... console.log({...tags,[newTag.current.key]:newTag.current.val}) //This is the important line, the thing here is to construct a new object from tags props adding a new key:value to the new object .... </script>...
(sorry for jQuery use here, its just a test case)
const c = $('script[type="text/babel"]').text()
var js = Babel.transform(c, { presets: ["react","es2015-no-commonjs"] }).code;
$("body").append($('<script type="module">').text(js))
...
This line is transpilled to:
console.log(_defineProperty({}, newTag.current.key, newTag.current.val));
loosing the prev tags object props...
I had to change this line to this in order to be well transpilled:
setTags({...tags,...{[newTag.current.key]:newTag.current.val}}) //Notice that now the new prop is encapsulated in a seconly destructured object, and now this is well interpreted as:
setTags({
...tags,
..._defineProperty({}, newTag.current.key, newTag.current.val)
});
Configuration file name
No response
Configuration
No response
Current and expected behavior
Tested the code widthout transpilling and works well so I supouse it is well formed.
Environment
Chrome Versi贸n 122.0.6261.129 (Build oficial) (64 bits)
Possible solution
No response
Additional context
Sorry if i dont make the ticket well, I just worked around, but think this could be a problem for someon else and too dificult to describe in a search engine.
Thnx in advance.
The text was updated successfully, but these errors were encountered: