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

target node14 uses spread polyfill #1365

Closed
reconbot opened this issue Jun 11, 2021 · 1 comment
Closed

target node14 uses spread polyfill #1365

reconbot opened this issue Jun 11, 2021 · 1 comment

Comments

@reconbot
Copy link

Node14 supports the object spread syntax, however when bundling the __spreadValues helper is used instead.

config

build({
      entryPoints: ['index.ts],
      outfile: 'index.js',
      bundle: true,
      platform: 'node',
      minify: false,
      target: ['node14'],
    })

input

const foo = { a: 4}
const bar = { ...foo }

output

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;
};

// ts-src/events/utility/index.ts
var foo = { a: 4 };
var bar = __spreadValues({}, foo);
@reconbot
Copy link
Author

I did some digging and found a comment in the source code that lead to #951 which explains why we're not using object spread operators right now.

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

1 participant