-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Error while rendering map with mapbox-gl: "_typeof is not defined" #1128
Comments
_typeof is not defined
i'm running into the same problem. my guess is that it's related to Web Workers. the |
you might wanna just "disable" babel see #509 (comment) |
Related: #670 Running into this exact issue for a work project and really need a fix 😇 |
Here's my "fun with Babel" contribution. Fiddling with my .babelrc I discovered limiting it to modern browsers worked. {
"presets": [
["env", {
"targets": {
"browsers": "last 2 Firefox versions, last 2 Chrome versions, last 2 Edge versions, last 2 Safari versions"
}
}]
]
} After a bunch of fiddling, it seems Babel's transformation for IE and Android Browser are causing the problem. If I use the browser string "defaults, not ie <999, not Android < 999" to exclude those browsers, Bob's your uncle. Put either of those two browsers back in the pool, But, if I run the Mapbox GL JS library through the Babel command line (Babel CLI 6.26.0, adds 2kb to the file) and then link to it directly in the example at the top, it works fine (note no <script src="mapbox-babeled.js"></script>
<script>
mapboxgl.accessToken = 'pk.eyJ1IjoiZG9sYnl6ZXJyIiwiYSI6InhIS25oN0EifQ.QQrwwFUZu6trJNjGsrpTFQ'
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v9'
});
</script> So, it looks like it's something with Babel combined with the import bundler, but only when Babel is correcting for those browsers. I guess. |
I tried @tobinbradley's solution (changing the .babelrc browsers, not the second option) and it did not work for me. Maybe something has changed between there and now, but I get the same error as in the original bug. Any other ideas about how to deal with this? |
I can confirm I have the same issue here using
Any suggestions, ideas, …? |
I ran out of ideas. I ended up using another bundler/boilerplate solution much to my chagrin. It looks to me like this won't be fixed until Parcel 2 arrives |
Confirmed same issue with |
May be you should try excluding /mapbox-gl from transpiling. It worked for me. My final .babelrc looks like this
|
I have the same issue, still can't find any good solution. |
I cannot find a fix for this. I have tried all of the above in .babelrc and nothing works. |
Please for god sake. "Just don't transpile the module lol" is not an answer at all. Some are actually using it in production with facing customers. Everything about Babel here is not about fixing the issue; but avoiding the issue, making somehow Babel avoid mapbox transpilation in some context. We need an answer. Doesn't mapbox work in certain browser contexts because of webworkers ? Fine, please we figure it out and spell it, list it. Shouldn't we ? |
@cyrilchapon while I understand your frustration, this is not the right tone. This is open source software, you're not paying a dime for Parcel and the root issue has been identified and open. I'm sure the core devs would welcome your contribution (#670) but otherwise I think you should be more respectful of all the work they have done. |
@jotasolano was I revendicative on my previous answer ? Or disrespectful against contributors ? Or even acting like a "customer" ? I don't agree actually. I'm pretty aware this is open source software, and I did not even mention the fact this issue not being tackled. I was complaining about bad issue triaging and commenting. "Just don't transpile" is not a clever answer, and that's all I'm saying. Everyone coming to this issue will now know this issue is being tackled, thanks to the link you posted. Please notice no-one could guess that before your answer. In that sense, this issue moved on a little bit; and that's my way of contributing. |
Excluding mapbox-gl in .babelrc did the trick for me as suggested above, but only after forcing Parcel to rebuild everything. Try --no-cache on parcel. |
@cyrilchapon If you scroll up you'll see that the issue I referenced was posted pretty early (comment 4) #1128 (comment) I just re-referenced for you. |
Is there a workaround to this issue that doesn't involve dropping support for most browsers? The solution suggested #1128 (comment) works but not if I set the browser list to Is Parcel ignoring the excludes list? If so, why? |
I am encountering the same issue but using Babel 7 (@babel/...). The solutions mentioned above, therefore, don't work for me. It seems the options for env have changed. I spent a lot of time trying to find a solution and understanding the extremely obscure Babel documentation, but to be honest, I failed. And can't wait to be able to code again. Surely there is a better way than switching back to Webpack? :( Would love to have your ideas. I can't be the only one using Babel 7, Parcel, and MapBox. |
I got to fix this error using Babel 7, and
According to the Babel docs, the |
Has anyone been able to solve this with TypeScript (no babel)? |
I have the same issue. but for fixing this bug, I used the Mapbox CDN instead of module bundler and finally the map area is rendered without Grey area . |
Following @tobinbradley solution, I found that just creating a
I'm using new mapbox-gl 2.0.0 |
Appears to work correctly in Parcel 2 nightly. |
This a 🐛 bug report
🎛 Configuration (.babelrc, package.json, cli command)
🤔 Expected Behavior
A map should be rendered.
😯 Current Behavior
Grey area is rendered:

The error in console:
Uncaught ReferenceError: _typeof is not defined
💁 Possible Solution
As far as I understood from the error and this issue from mapbox mapbox/mapbox-gl-js#3422 it happens because parcel transpiling mapbox file that already being transpiled. Is there any way to alter that behaviour?
💻 Code Sample
🌍 Your Environment
The text was updated successfully, but these errors were encountered: