Crash in production React app
See original GitHub issueHello @tmcw !
We’re currently using v4.3.0 (also tested in v4.2.0) of togeojson.
When calling tj.kml
with this kml file in our React v16.12.0 production app, based on create-react-app, We get the following console error:
TypeError: u is not a function
at kml.js:296
at l (runtime.js:63)
at Generator._invoke (runtime.js:293)
at Generator.next (runtime.js:118)
at Function.from (<anonymous>)
at e.kml (kml.js:316)
at Object.KML (index.es.js:32035)
at setTimeout.format (index.es.js:32063)
at index.es.js:32225
This error does not occur when running locally in development, and when using your online tool, again there is no problems. Therefore we think the issue lies in the minified build.
Just to clarify, KML files without the StyleMap element do not have this problem.
I’d appreciate any assistance you could provide 😃
Using as below:
import * as toGeoJSON from '@tmcw/togeojson';
...
const dom = (new DOMParser()).parseFromString(kmlString, 'text/xml');
const parsedGeojson = toGeoJSON.kml(dom);
Issue Analytics
- State:
- Created 3 years ago
- Comments:12
Top Results From Across the Web
React App crashes when running the production build
My React app was crashing on only one specific screen on the production build, but not in the dev environment.
Read more >[IOS] Random app crash on production build #2327 - GitHub
I'm hosting my shared values in react context, so that these values can later be accessed by various components on the screen. The...
Read more >Eight Practices in React That Will Crash Your App in the Future
If you're currently building an application using react or thinking of using react for upcoming projects, then this tutorial is for you.
Read more >8 Practices In React That Will Crash Your App In The Future
If you're currently building an application using react or thinking of using react for upcoming projects, then this tutorial is for you.
Read more >Error Boundaries - React
These errors were always caused by an earlier error in the application code, ... and display a fallback UI instead of the component...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Great, good to have an example of the workaround. As far as this issue, it’s upstream, in Terser. There’s no way for this project to avoid the bug in Terser.
@tmcw , so we’ve managed to get around the issue, but still not 100% sure what the cause was.
We have a map module which relied on
@tmcw/togeojson
as a peer dependency, and we installed both the map module and your package as hard dependencies in our create-react-app.During the build (where we use the default build settings of create-react-app), for whatever reason, the uglified code was using the same variable for the
nodeVal
function and thehash
variable inkmlGen
of your source code.FIX
We changed
@tmcw/togeojson
from a peer dependency to a hard dependency of our map module.This changed the structure of the dependency graph during webpacks build process, causing the uglified code to be slightly different, and removing the variable name scope issue laid out above.
Thanks again @tmcw for all the help!