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

babel-polyfill and es6-shim #467

Open
gnh1201 opened this issue Apr 29, 2021 · 8 comments
Open

babel-polyfill and es6-shim #467

gnh1201 opened this issue Apr 29, 2021 · 8 comments

Comments

@gnh1201
Copy link
Contributor

gnh1201 commented Apr 29, 2021

Related items

Description

To run ES5 or higher Javascript on WSH(Windows Scripting Host), we need a babel-polyfill. for example:

function _extend(dst) {
  for (var _len = arguments.length, sources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    sources[_key - 1] = arguments[_key];
  }

  if (dst && sources) {
    var _loop = function _loop(src) {
      if ((typeof src === 'undefined' ? 'undefined' : _typeof(src)) === 'object') {
        Object.getOwnPropertyNames(src).forEach(function (key) {
          dst[key] = src[key];
        });
      }
    };

    var _iteratorNormalCompletion = true;
    var _didIteratorError = false;
    var _iteratorError = undefined;

    try {
      for (var _iterator = sources[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
        var src = _step.value;

        _loop(src);
      }
    } catch (err) {
      _didIteratorError = true;
      _iteratorError = err;
    } finally {
      try {
        if (!_iteratorNormalCompletion && _iterator.RETURN) {  // es5: _iterator.return, babel: _iterator.RETURN
          _iterator.RETURN();
        }
      } finally {
        if (_didIteratorError) {
          throw _iteratorError;
        }
      }
    }
  }

  return dst;
};

This code works well with only babel-polyfill and es5 shim and sham. The problem occurs when adding es6-shim here.

In this case, it should be changed as below to works.

  var defineProperty = function (object, name, value, force) {
    if (!object || (!force && name in object)) { return; }

This change has also been proposed in #466.

I think that this change should apply. Or a better idea?

@gnh1201
Copy link
Contributor Author

gnh1201 commented Apr 29, 2021

This code works well with only babel-polyfill and es5 shim and sham. The problem occurs when adding es6-shim here.

@ljharb
Copy link
Collaborator

ljharb commented Apr 29, 2021

Is this still an issue after #466 is merged?

@gnh1201
Copy link
Contributor Author

gnh1201 commented Apr 30, 2021

Yes. This seems to be another problem. I'll track it down.

@gnh1201
Copy link
Contributor Author

gnh1201 commented Apr 30, 2021

@zloirock
Copy link

@gnh1201 why do you need both - core-js and es-shims? It's a bad practice. What does es-shims fix in this case? BTW babel-polyfill is obsolete for a long time ago and the actual version of core-js should be used directly.

@gnh1201
Copy link
Contributor Author

gnh1201 commented Apr 30, 2021

@zloirock I had no choice but to choose babel-polyfill and es5-shim. It worked well and successfully executed the JS library file written in ES5. Trying es6-shim was an option for me, but I thought I'd still test it.

@ljharb
Copy link
Collaborator

ljharb commented Apr 30, 2021

While most of the es-shims should work fine alongside core-js, it's definitely odd to mix them.

I would expect that es5-shim and es6-shim alone could get you mostly up to speed, except for the Symbol shams that core-js includes but es6-shim does not.

gnh1201 added a commit to gnh1201/es6-shim that referenced this issue Jul 29, 2021
* Reverted from paulmillr#466 - No need to check that this is 'undefined'.
* This pull request fix the following issue: paulmillr#470 paulmillr#467
@gnh1201
Copy link
Contributor Author

gnh1201 commented Jul 29, 2021

I tested core-js and confirmed that the example code works well. But I still have to wait and see. I think I need to check the impact when es-shims is excluded from my project.

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