-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
'Uncaught ReferenceError: y is not defined' - uglify went wrong in v2.0.x #10240
Comments
I see this as well. I tried experimenting with using rewire and my own build.js, but I just get an assorted set of errors all related. I was able to get it to produce a more readable error:
This is my build.js
|
Same Problem occurs when using create-react-app. When investigating I also get _createClass is not defined as an error. |
I'm running into the same issue but downgrading to 1.13.0 has fixed things (thanks @brdv for the workaround!). Not ideal, but will have to do for now. |
I faced the same issue and it had me stuck for a good couple of hours. Then, I saw this issue and downgraded to 1.13.0. It worked. Hope this is fixed in the new version soon. |
Essentially a duplicate of #10173. Latest update / workarounds are here #10173 (comment) |
Yeah, it's a duplicate, but the workaround doesn't work. Looking forward to trying the patch. |
@mourner Thanks, will try this asap! |
That's because |
my issue was that I had put the workaround before I imported mapbox-gl 2.0.1 when I placed the code after, it worked as expected. |
Is there a solution for this? |
how to downgrade the version |
Downgrading worked for me. Thanks. I hope there will be a permanent fix for this soon. |
@adilgrover npm i mapbox-gl@1.13.0 That's how to downgrade. You might need to uninstall mapbox-gl from your project before downgrading |
For anyone who is still struggling with this in a create-react-app environment. My solution was to fix all the warnings related to maplibre thrown by npm start. |
mapbox-gl-js 2.0.1:
If something in this issue is not set up properly or unclear, please let me know so I can fix it.
Project Setup
Using Mapbox 2.0.1 in a create-react-app with react v17.0.1 and typescript 4.0.3. Initiated the project with create-react-app, using react-scripts 4.0.1.
Problem
When trying to deploy the app, firstly we run
yarn build
. This seems to do it's job, no build errors. However, when we actually deploy it, e.g. serve the build. We run in to a 'referenceError: y is not defined'.Now this is a problem that, when googling, used to come up a lot more on versions like 0.4x.x. See the following examples.
This should give you an idea of the problem. There are some possible fixes included as well, however, after applying these do not seem to work. A little digging into the react-scripts shows why (they already fixed this):
Steps to Trigger Behavior
Clone my demo repo: mapbox-build-error which was created with CRA and the mapbox react tutorial. (For simplicity this repo is using JavaScript in stead of TypeScript.)
My following steps (macos) are as follows:
yarn install
yarn build
serve -s build
Go to the link in the console and there will probably not be a map.
The console will show: 'Uncaught ReferenceError: y is not defined'
Current fix
When downgrading the version of Mapbox-gl to 1.13.0. The build works just fine. This is what we will have to do until the issue is fixed.
Thanks in advance!
The text was updated successfully, but these errors were encountered: