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-runtime/helpers/typeof requires itself (T6644) #3711
Comments
And it's invoking itself recursively too :\ exports.default = function (obj) {
|
seeing this issue as well. i noticed that if i downgrade to babel-runtime@5, it works, but it does not work with babel-runtime@6 |
The issue is also tracked by: https://phabricator.babeljs.io/T2954 |
Probably related: https://github.com/fholzer/babel-issue |
I assume that the original code is in [[ https://github.com/babel/babel/blob/master/packages/babel-helpers/src/helpers.js | the If I understand Babel's internals correctly, one of the transforms should be made aware of the fact that this is the only Do we know which of the transforms is breaking the code? Is it a Babel issue or a core-js one? |
Minimalistic reproduce scenario: babel/website#612 |
It seems that |
@plievone Many thanks for documenting this! I'd started to dig into the code myself but I never finished my write-up. I assume there now needs to be a way to convey to transform-es2015-typeof-symbol that the typeof in question is the platform-native one rather than a polyfill? Is anyone aware of similar scenarios in the Babel source? I.e., is there another operator that's being transformed except where it falls back to the native one? That would allow us to apply an existing pattern. |
@timdp: +1 Looks good and can be reused for other purposes as well. Can this be integrated soon so that we can use the new babel 6.x without having to patch the typeof helper on every npm install or npm update? |
I just had a stab at a fix for this issue. Please bear in mind that I'm new to Babel development. (Also, I had quite a bit of trouble getting the build to work on Windows, so that'll probably trigger a PR at some point as well.) So. My [[ https://github.com/timdp/babel/tree/native-typeof | native-typeof branch ]] adds support for a global
The example above gets transpiled into a native In theory, the new transform could be extended to support any construct. It doesn't look great, but hey, it works. Building upon this new feature, I [[ https://github.com/timdp/babel/commit/7bbf06e30464f5802514e91411082e67758961ab | replaced ]] the
I welcome any feedback and/or improvements. Edit: [[ https://github.com//pull/3126 | Here's the PR. ]] |
Okay, there are a ton of people subscribed to this so I'd like some feedback. Reviewing this, it seems like this may be two related by separate cases, and it's hard to say which is the one people are actually seeing.
#1 seems like it may be more user error than Babel error, but if you're running into that, I'd like to get an example repo that demos the issue, if you can. Ideally fully commit node_modules so I have the exact code to run. I'm actually not 100% clear on how to reproduce this. #2 is a real issue that we'll resolve. |
Done. https://github.com/jamestalmage/__babel-typeof-repro/tree/master |
Perfect, thank you! |
You don't need async/await and friends. Here's a more minimal version: https://github.com/timdp/babel-typeof-repro/tree/minimal All it contains is transform-es2015-typeof-symbol + transform-es2015-modules-commonjs + transform-runtime. A simple typeof causes infinite recursion on my system. Doesn't seem like user error to me. |
Yup, feel free to ignore my comments about #1. It's definitely a bug. The repro case was perfect, thanks. |
I'm going to split case #2 into a separate issue, https://phabricator.babeljs.io/T6777, since this one is already primarily focused |
@loganfsmyth Cool. Do you think my PR is a good solution to the loopback? |
@timdp The global solution is a little iffy in my mind, but I've posted another potential fix: #3142 |
@loganfsmyth Yeah, I'm certainly open to suggestions. Once I figure out how your fix works, I'll let you know why I prefer it over mine. :-) |
Is there workaround or a patch for this issue? After looking at the potential fix repos above, I am not entirely sure where or what files to patch. EDIT: I was able to figure out how to patch my environment based on the fix proposed by @loganfsmyth above: https://gist.github.com/patrickheeney/0e7f6324457d0c786acb . |
The PR that appears to fix this has been up for a week. This is currently a showstopper on migrating to 6, so is there anything more than needs to happen to make the PR acceptable? |
This should be all set if you load |
Just to let you know, I still have the |
It still happens in babel-runtime 6.11.6 when using rollup, please reopen:
|
This is
|
@sheerun, did you come up with a workaround for this? |
@arbesfeld No, I've opened a ticket on in #4829 |
Bug information
Options
Input code
Description
When I run
npm install babel-runtime
,node_modules/babel-runtime/helpers/typeof.js
contains this code:var _typeof2 = require("babel-runtime/helpers/typeof"); ... var _typeof3 = _interopRequireDefault(_typeof2); ... _typeof3.default
This is causing failures with
TypeError: (0 , _typeof3.default) is not a function
.It looks like this code is itself being compiled, and needs to be changed to use the
typeof
operator rather than itself.The text was updated successfully, but these errors were encountered: