Skip to content

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

Merged
nicolo-ribaudo merged 3 commits intobabel:masterfrom
nicolo-ribaudo:transform-typeof-runtime
Dec 4, 2019
Merged

Do not transpile typeof helper with itself in babel/runtime#10788
nicolo-ribaudo merged 3 commits intobabel:masterfrom
nicolo-ribaudo:transform-typeof-runtime

Conversation

@nicolo-ribaudo
Copy link
Copy Markdown
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
Comment thread packages/babel-plugin-transform-runtime/scripts/build-dist.js Outdated
Comment thread packages/babel-plugin-transform-runtime/scripts/build-dist.js Outdated
Comment thread packages/babel-plugin-transform-runtime/scripts/build-dist.js Outdated
@nicolo-ribaudo
Copy link
Copy Markdown
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.

@nicolo-ribaudo nicolo-ribaudo force-pushed the transform-typeof-runtime branch from 345761c to d327889 Compare December 2, 2019 21:30
@nicolo-ribaudo nicolo-ribaudo force-pushed the transform-typeof-runtime branch from d327889 to 8c163fa Compare December 2, 2019 21:31
@Andarist
Copy link
Copy Markdown
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
Copy Markdown
Member Author

I have a better alternative to this PR.

@nicolo-ribaudo
Copy link
Copy Markdown
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.

3 participants