Skip to content
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

Object spread is supported in Node >= 8.3 but polyfilled by esbuild #2060

Closed
tinovyatkin opened this issue Feb 26, 2022 · 2 comments
Closed

Comments

@tinovyatkin
Copy link

Object spread syntax is supported in Node starting 8.3 (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax#browser_compatibility) but esbuild currently outputs __spreadValues polyfill for anything higher than --target=node8.3.0 (I've checked with node16 also) - see repl

Compare the output with --target=es2018 that is what we should get for the Node target.

@evanw
Copy link
Owner

evanw commented Feb 26, 2022

This is deliberate. V8's native implementation of object spread is being avoided because it has performance issues. See also: #951, #1365, #1583.

@tinovyatkin
Copy link
Author

Wow. Number of times this issue was raised probably is the best indicator that this deliberate decision are confusing and misleading for users.

esbuild is a great tool (thank you!) that have 3 documented functions: transpiling, bundling and minifying. All of them are optional. But now it happens that there is a speed optimizer also, that even in case when user provides precise target can make deliberate decision to change syntax from supported by the target. And not for bug fixing, etc, but for a performance optimization?

I understand you don't want to create a lot of switches of that features, but can we, similar to mangle/minify, have an option to switch off performance optimizations?

There are lot of similar performance optimization exists (almost with every iterable), why object spread was chosen as the only optimization target? Or there are other language syntax constructions that are transforming for performance reasons?

@evanw evanw closed this as completed in 0d4fae1 Jun 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants