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

Do not transpile typeof helper with itself in babel/runtime #10788

Merged

Conversation

nicolo-ribaudo
Copy link
Member

Q                       A
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

I noticed that the typeof.js helper also contained a copy of itself as _typeof2: https://unpkg.com/browse/@babel/runtime@7.7.4/helpers/typeof.js
This PR removes it:

function _typeof(obj) {
  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
    module.exports = _typeof = function _typeof(obj) {
      return typeof obj;
    };
  } else {
    module.exports = _typeof = function _typeof(obj) {
      return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
    };
  }

  return _typeof(obj);
}

module.exports = _typeof;

In other helpers it is still transformed:

var _typeof = require("../helpers/typeof");

var toPrimitive = require("./toPrimitive");

function _toPropertyKey(arg) {
  var key = toPrimitive(arg, "string");
  return _typeof(key) === "symbol" ? key : String(key);
}

module.exports = _toPropertyKey;

@nicolo-ribaudo nicolo-ribaudo added the PR: Polish 💅 A type of pull request used for our changelog categories label Dec 1, 2019
@nicolo-ribaudo
Copy link
Member Author

CircleCI is failing because of core-js 3.4.6. It's fixed in 3.4.7, but I don't know how to clear the cache before triggering a build.

@Andarist
Copy link
Member

Andarist commented Dec 3, 2019

Could we exclude this plugin altogether and only allow using typeof helper as an explicit dependency of other helpers when needed? This probably cannot be done right now as the expectation is to ship es5-compatible code.

@nicolo-ribaudo
Copy link
Member Author

I have a better alternative to this PR.

@nicolo-ribaudo
Copy link
Member Author

Nevermind, it doesn't work. (I was trying to rewrite the helper so that it wouldn't be transformed by the typeof plugin)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Polish 💅 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants