Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Breaks on Node 6 #98

Closed
franjohn21 opened this issue Jan 29, 2019 · 4 comments
Closed

Breaks on Node 6 #98

franjohn21 opened this issue Jan 29, 2019 · 4 comments

Comments

@franjohn21
Copy link

franjohn21 commented Jan 29, 2019

This package's built code is shipping Object.getOwnPropertyDescriptors which is not supported in Node v6. https://node.green/#ES2017-features-Object-static-methods-Object-getOwnPropertyDescriptors

Since this repo is using babel-preset-env and targeting a Node version of 6, I wouldn't expect this to break and it may be indicative of an error in babel itself. E.g. potentially related to babel/babel#9382

Code snippet that is breaking:

function _objectSpread(target) {
  for (let i = 1; i < arguments.length; i++) {
    if (i % 2) {
      var source = arguments[i] != null ? arguments[i] : {};
      let ownKeys = Object.keys(source);
      if (typeof Object.getOwnPropertySymbols === 'function') {
        ownKeys = ownKeys.concat(
          Object.getOwnPropertySymbols(source).filter(
            sym => Object.getOwnPropertyDescriptor(source, sym).enumerable
          )
        );
      }
      ownKeys.forEach(key => {
        _defineProperty(target, key, source[key]);
      });
    } else {
      Object.defineProperties(
        target,
        Object.getOwnPropertyDescriptors(arguments[i]) // <---- This is the problem
      );
    }
  }
  return target;
}

My current workaround is to import @babel/polyfill in my .eslintrc.js until we can upgrade our versions of Node.


Version Info

  • eslint-import-resolver-babel-module: 5.0.0
  • Node: 6.3.0 || 6.10.0
  • eslint: 5.12.1
  • @babel/core: 7.2.2
  • babel-plugin-module-resolver: 3.1.3
@tleunen
Copy link
Owner

tleunen commented Jan 29, 2019

Afaik, Object.getOwnPropertyDescriptor is supported in Node 6. (see https://node.green/#ES2015-misc-Object-static-methods-accept-primitives-Object-getOwnPropertyDescriptor)

The link you shared is for Object.getOwnPropertyDescriptors (with a trailing "s"), which, indeed is not part of node 6.

Are you sure it's breaking? The code run in node 6 on the CI without issue.
Could you provide more info on the error maybe?

@franjohn21
Copy link
Author

franjohn21 commented Jan 29, 2019

^^ Good catch. The code I pasted uses both getOwnPropertyDescriptor and getOwnPropertyDescriptors however. I'll update my original description to reference the one that is actually problematic

@tleunen
Copy link
Owner

tleunen commented Jan 29, 2019

Oh my. I should have paid more attention.
I believe they indeed fixed the issue in the latest version, because I cannot reproduce the issue when I recompile the code.

I'm on it to fix it and release a new version. Thanks for reporting the issue.

@franjohn21
Copy link
Author

@tleunen Really appreciate the fast turn around. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants