-
Notifications
You must be signed in to change notification settings - Fork 361
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
Spread syntax in array incorrectly converts to [].concat() #945
Comments
There is no config for this, Microbundle assumes spreads are Arrays in order to produce the smallest output for ES5 targets. I would recommend using |
I have just run into this. Took me a couple of hours to track it. export function test() {
const testArr = [...new Set([1, 3, 4, 4])]
} get compiled to: function t() {
var t = [].concat(new Set([1, 3, 4, 4]))
} this happens with format:
There is a new option in babel |
Yes as mentioned here loose mode transpiles ES6 code to ES5 code that is less faithful to ES6 semantics and isn't generally recommended to use. Removing it or at the very using the |
Hm, there might be a misunderstanding here? This is working as intended, there's nothing to "help" or "fix". Yes, Microbundle does use loose mode, and yes this might introduce edge cases, but the goal of Microbundle is the tiniest output possible for most modules. Removing loose mode isn't likely in the near future; when modern output becomes consumed more often than not, it may make sense to allow the ES5 to grow to the bigger, more correct form, as it'll rarely ever be used, but we're not there yet.
That 7 year old link might not recommend them, but far more often than not,
|
Going to close this out as there's nothing actionable here and the suggested replacement code should resolve the issue. |
Am I understanding correctly that |
Sorta, but defensively calling |
1 character for |
|
When I do:
I get:
elements
ends up being an array of NodeList instead of the intended array of elements.Is there a config change I can do to avoid this?
The text was updated successfully, but these errors were encountered: