-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
6.x.x production build error "x is not defined" #1266
Comments
Do you see any error in the console? Might be caused by mapbox/mapbox-gl-js#10173 |
Thanks, it seems related, I will follow that issue! |
@Velidoss please visit the Mapbox issue I linked above. The bug is in [email protected]. There is a temporary work around by adding additional bundler settings. |
Same issue here. As a quick workaround I downgraded to v5.2.11 of
|
Downgrading to v5.2.11 of For those out there in a similar spot, I was able to hack around things for the time being by adapting the suggestions in mapbox/mapbox-gl-js#10173: Install
In your map component:
I hope the Mapbox team can provide a long term solution soon. |
Having the same issue |
use the above work around for mapbox worker class it works gr8 for now 👍 |
looks like they are working on a PR to address this here - https://github.com/mapbox/mapbox-gl-js-docs/pull/461 Looks like the "right" way might be to add this code: import mapboxgl from 'mapbox-gl/dist/mapbox-gl';
import MapboxWorker from 'mapbox-gl/dist/mapbox-gl-csp-worker';
mapboxgl.workerClass = MapboxWorker; |
Could someone explain why this works? |
Mapbox has now published the official solution to this issue: https://docs.mapbox.com/mapbox-gl-js/api/#transpiling-v2 |
I am still struggling to get this to work. I am able to get Mapbox-GL to work by using: but still getting: sure i am missing something obvious but any help would be appreciated |
@JG145 what I had to do was the following (as a create react app and typescript user)
|
Still hitting the same issue? gone with:
Changing the above to:
elicits this error:
|
Also get no clue how to solve this issue in versions above 5.3.4. Downgrade to v 5.3.4 solves it for now for me. If someone got a result on versions 6.0.0 and above for React, please give some code example here. |
If you use typescript, just add |
* Add sdorsys boilerplate * Add sharp w typescript * Add frontend mock * Refactor backend into /electron * Add FE module * Add dynamic loading of FE assets * Add TS support to the FE * Add basic yarn workspace (shared/frontend) * Add waiting to electron module & update module import in electron * Update readme * Add storybook support * Add eslint to the electron ts code * Add jest support in the backend * Add tests to FE * Clean FE styles * Add render to render IPC communications * Add atoms and molecules (component library) * Add molecules and organisms * Add navBar molecule * Update molecules * Add start page, add static and clean tests * Add pre-processing and settings pages * Fix gallery bug and add dashboard page * Add shared types and add component type inference * Add redux dependency to FE * Add redux and real types * Update shared module types, message bug, and todos * Add BE messageBus handler skeleton & ML * Add DB module and tests * Add destroy handler, type refactors and twitter link * Add reset handler dep injection and tests * Update handlers and add utils * Break down services and add dependency injection * Add tests for the date service * Add file service types and tests * Add test coverage and comments to image service * Add exposed types in services and handlers * Fix webId population, add handler dep injection * Clean up sharp loading and add processing (not working yet) * Add test skeleton for the ML operations and test-images * Add tag tests, update classification services and types * Add custom tag types * Update tests * Add filter images with location, update types and message bus * Fix backend tests and clean up FE dead tests * Update FE build leftovers * Enable loading local image files * Add FE fonts * Add ML dependencies to BE * Add box shadow to UI buttons * Clean up isProcessing dependency from FE -> Redux * Remove unused prop isProcessing from store and UI * Fix flanky test (jest --clearCache) * Add fallback to map component * Fix shared build error (due to TF) * Fix button shadow * Silence process errors and fix image paths * Add react and redux extensions to electron main * Clean up unused config * Fix filtering bug * Add app icon and update todos * Update app naming in FE * Remove isDev dependency + skeleton of docs * Add CI support * Update CI workflow files * Add craco to fix map bug visgl/react-map-gl#1266 * Clean up sharp dependency * Fix the map issue by rolling back * Hide backend window in prod * Update isDev flag * Clean tasks * Add partial README * Add documentation * Optimize build * Update tests * Update CI to only run on PRs * Clean up old README * Remove CI * Add screenshot
Thanks so much for this. I'd tried a few other solutions and wasn't sure what do try next! |
Is it for production fixes also because i tried and it is working fine on development mode.. Can we use this version on prod as well.. |
Update: There was a fix on Nextjs, but still in canary branch. |
Is there any elegant solution for that (react-scripts)? |
downgrade to version @5.2.11 and it will be ok |
Hi there, I'm writing from 2022 and downgrading did the trick for me. |
hi, i still recommend ejecting from create-react-app and specifying the webpack config like in my previous comment, it means i can upload as i find fit. |
Had the same problem using react-map-gl together with maplibre. I could manage to fix it by using craco (https://github.com/gsoft-inc/craco). Here is my craco.config.js: const CracoWorkboxPlugin = require('craco-workbox');
module.exports = {
babel: {
loaderOptions: {
// this option lets us display the map-pin marker layer - without this it does not work: https://github.com/visgl/react-map-gl/issues/1266
ignore: ['./node_modules/maplibre-gl/dist/maplibre-gl.js']
}
},
plugins: [{
plugin: CracoWorkboxPlugin
}],
webpack: {
alias: {
'mapbox-gl': 'maplibre-gl',
},
},
}; Hope this helps someone. |
Speaking from 2022 as well - after trying many things, this is the comment to follow for a direct few line fix on a create react-app without having to eject |
does this still not work, tried #1266 (comment) but i get an error with typescript and does not work, feels mega hacky - update this did work just had to add the // @ts-ignore
thanks everyone for figuring it out |
throws Do not use import syntax to configure webpack loaders in react |
@emekaokoli, I have similar issue with maplibregl after building production build.
to
solves the issue, but obviously it's not suitable for production. |
solved: https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling |
While i could fix the initial error by using the The Map and tiles are loading, but city names f.e. will not show up. It works locally, so only on a production build this fails. Javascript console error from the mapbox worker file is Any ideas how to fix this? Edit: I've digged a little deeper. So while this works
As soon as i use any mapboxgl related import it fails again. For example i'm doing some pan and zooming depending on boundaries and calculate them using But when using the above technic it fails, both locally and in production
While developing locally everything worked, using default imports.
any ideas what causes this? |
INSANE WOKS ! THANKS , THIS MAN IS SO GOOD |
Hey! I hosted my app on Netlify and was getting similar problems. The below steps fixed my issues:
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all",
"not safari < 10",
"not chrome < 51",
"not android < 5",
"not ie < 12"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
} |
I upgraded to 6.0.0 (also tried 6.0.1) and everything works fine in development mode, but in the production build the background map doesn't render using. I'm using a mapbox token.
I have an IconLayer that renders just fine, but on top of a grey background :/
The text was updated successfully, but these errors were encountered: