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

"_typeof is not a function" bug on production env #2483

Closed
wendellpbarreto opened this issue Mar 9, 2020 · 2 comments
Closed

"_typeof is not a function" bug on production env #2483

wendellpbarreto opened this issue Mar 9, 2020 · 2 comments
Labels
support Questions or unspecific problems

Comments

@wendellpbarreto
Copy link

When compiling in production, js dependencies that uses typeof expression will output "_typeof" instead and cause the error "_typeof is not a function"

I searched a lot and understand that @babel/preset-env is transforming "typeof" in "_typeof", but if we add "transform-typeof-symbol" to exclude rule, everything should work. But is not working with me.

The line of lib that uses typeof is this one: https://github.com/zenorocha/clipboard.js/blob/master/dist/clipboard.js#L516

The output code is:
image
image

And my babel.config.js generated by this gem:
image

Someone knows what I'm doing wrong?

@jakeNiemiec
Copy link
Member

And my babel.config.js generated by this gem

babel.config.js should contain a lot more than just that.

Someone knows what I'm doing wrong?

environment.loaders.delete('nodeModules'); like in #2131 (comment) will most likely solve your problem. You can read my explanation there for further details 👍.

@jakeNiemiec jakeNiemiec added the support Questions or unspecific problems label Mar 11, 2020
@wendellpbarreto
Copy link
Author

Thanks, @jakeNiemiec! This just solve the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Questions or unspecific problems
Projects
None yet
Development

No branches or pull requests

2 participants