question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Production build fails but dev works fine

See original GitHub issue

I’ve spotted production build fail with error Uncaught ReferenceError: y is not defined (See screenshot below) image

Steps to reproduce - create fresh react app with TypeScript. Add dependencies npm install react-mapbox-gl mapbox-gl --save

Try to build with npm run build

And after check with npm serve -s build

Code from my new App

import React from 'react';
import ReactMapboxGl, {Feature, Layer} from "react-mapbox-gl";
import logo from './logo.svg';
import './App.css';

const mapToken = "your_token_here";
const MapBox = ReactMapboxGl({accessToken: mapToken})


const polygonPaint = {
  'fill-color': '#6F788A',
  'fill-opacity': 1
};

const AllShapesPolygonCoords = [
  [
    [-0.13235092163085938, 51.518250335096376],
    [-0.1174163818359375, 51.52433860667918],
    [-0.10591506958007812, 51.51974577545329],
    [-0.10831832885742188, 51.51429786349477],
    [-0.12531280517578122, 51.51429786349477],
    [-0.13200759887695312, 51.517823057404094]
  ]
];


const Map: React.FC = ({children}) => {

  const mapParams = {
    style: "mapbox://styles/mapbox/light-v8",
    containerStyle: {height: "60vh", width: "100%"}
  }

  return (
    <MapBox {...mapParams}>
      <>
        {children}
      </>
    </MapBox>
  );
};

function App() {
  return (
    <div className="App">
      <Map>
        <Layer type="fill" paint={polygonPaint} />
        <Feature coordinates={AllShapesPolygonCoords}/>
      </Map>
    </div>
);
}

export default App;

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:9

github_iconTop GitHub Comments

1reaction
EmmanuelTheCodercommented, Apr 5, 2022

@naseemkhan7021 that didn’t work for me. I wonder why. I’m on React by the way.

0reactions
matiasfittipaldicommented, Sep 28, 2022

@naseemkhan7021 very thanks!!! work for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.js production fails but dev works - Stack Overflow
The reason why it's doing that in prod and not dev is because nextjs will only check types on a production build (as...
Read more >
Troubleshooting build errors and crashes - Expo Documentation
This particular error means that the app is importing ./src/Routes and it is not found. The cause could be that the filename case...
Read more >
ng serve fails but ng build works : r/angular - Reddit
But if I try to use ng serve the "compile" fails with ~20… ... is weird since A. the thing is a module...
Read more >
Troubleshooting Node.js Deploys - Heroku Dev Center
Check the buildpack · Compare Node and npm Versions · Make sure the lockfile is up to date · Don't check in generated...
Read more >
Deployment | Create React App
npm run build creates a build directory with a production build of ... It also works well when integrated into an existing server...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found