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

Why esbuild transform spread operator but not transform nullish coalescing operator #1759

Closed
wmzy opened this issue Nov 9, 2021 · 2 comments

Comments

@wmzy
Copy link

wmzy commented Nov 9, 2021

$ echo 'window ?? { ...{} }' | esbuild --target=chrome80
var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
window ?? __spreadValues({}, {});
@hyrious
Copy link

hyrious commented Nov 9, 2021

Because spread is faster than ... in V8.
see #1583

@evanw
Copy link
Owner

evanw commented Nov 10, 2021

Closing as a duplicate of #1583 and #1365. See also #951.

@evanw evanw closed this as completed Nov 10, 2021
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

3 participants