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

nicolo-ribaudo commented Dec 1, 2019

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;
@JLHwung
JLHwung approved these changes Dec 2, 2019
@nicolo-ribaudo

This comment has been minimized.

Copy link
Member Author

nicolo-ribaudo commented Dec 2, 2019

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.

@nicolo-ribaudo nicolo-ribaudo force-pushed the nicolo-ribaudo:transform-typeof-runtime branch from 345761c to d327889 Dec 2, 2019
@nicolo-ribaudo nicolo-ribaudo force-pushed the nicolo-ribaudo:transform-typeof-runtime branch from d327889 to 8c163fa Dec 2, 2019
@Andarist

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member Author

nicolo-ribaudo commented Dec 3, 2019

I have a better alternative to this PR.

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member Author

nicolo-ribaudo commented Dec 4, 2019

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

@nicolo-ribaudo nicolo-ribaudo merged commit 3d0c5d2 into babel:master Dec 4, 2019
4 of 5 checks passed
4 of 5 checks passed
test262 Workflow: test262
Details
Travis CI - Pull Request Build Passed
Details
codecov/project 88.14% (target 80%)
Details
e2e Workflow: e2e
Details
test Workflow: test
Details
@nicolo-ribaudo nicolo-ribaudo deleted the nicolo-ribaudo:transform-typeof-runtime branch Dec 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.