-
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
In create-react-app v2 initialization throws Uncaught ReferenceError: _typeof is not defined #7354
Comments
Same issue. |
@maciekmp can you please provide a minimal reproduction of the issue you're seeing (for example on JSbin)? that will make it easier for us to diagnose if this is an issue with this library, your implementation, or the third party library. |
I'd guess this is related to this issue since create-react-app sets up Babel behind the scenes but it's hard to tell #3422 |
Hi. I have the same mistake. react-scripts: 2.0.3 |
I was able to resolve the issue by ejecting the CRA 2.x app and excluding mapbox-gl from one of the webpack rules. See below: // Process any JS outside of the app with Babel.
// Unlike the application JS, we only compile the standard ES features.
{
test: /\.js$/,
exclude: [/@babel(?:\/|\\{1,2})runtime/, /.*mapbox-gl.*/],
loader: require.resolve('babel-loader'),
options: {
babelrc: false,
configFile: false,
compact: false,
presets: [
[require.resolve('babel-preset-react-app/dependencies'), { helpers: true }]
],
cacheDirectory: true,
// Don't waste time on Gzipping the cache
cacheCompression: false,
// If an error happens in a package, it's possible to be
// because it was compiled. Thus, we don't want the browser
// debugger to show the original code. Instead, the code
// being evaluated would be much more helpful.
sourceMaps: false
}
}, |
@mollymerp |
Thanks @mollymerp for quick response, it is hard to repro on jsbin because it is connected with how npm package is prepared and how CRA v2 handle npm packages under the mask. I post it here first because I believe it can be fixed with the configuration of the build process for this package. Even example for @willrbc is quite nice it uses flow, I uploaded my version without it https://github.com/maciekmp/mapbox-cra2 |
My bad, Flow is not installed in this repo, I just left some type info in there from my main project |
Hey! I was looking at
To solve this, the bundles need to be pre-stringified during build time instead of at run time. |
This sounds similar to the cause of #4359 which was fixed with #6956. cc @mourner For what it's worth, @anandthakker seems to have ruled out the idea of inlining workers at build time with this comment
|
I'm not sure I understand what would become "duplicated"... is it because you create multiple workers that each share a chunk? If that's the case, what about wrapping it in an |
It looks like this issue was fixed in facebook/create-react-app#5278. Closing because I don't think this is actionable on our end. |
This issue shouldn't be closed, it's still a problem and will continue to break in odd ways. This should be fixed "once and for all" by this project. It'd be great to leave this open and brainstorm solutions, e.g. the eval solution proposed above. |
I believe the code duplication would come from the fact that our worker and main threads share quite a bit of code. Unfortunately, we can't use unsafe eval in this project. We removed the CSP requirement in #5665 for security compliance reasons. We can continue to brainstorm on this thread but right now it isn't actionable for us due to the constraints I've mentioned above. |
For what it's worth, I created a minimal test app just now and couldn't reproduce this particular bug so it seems like the fix @mollymerp mentioned helped out here. I'd argue that any further discussion is beyond the scope of this fairly limited bug report and should occur in a new issue created for that purpose, which would make tracking the discussion easier. That being said, I'm not sure there's a lot of options here. It seems to come down to a choice for us to either greatly increase our bundle size or adopt |
This is still an issue using
Getting
From webworker |
@cyrilchapon, did you ever find a solution? To everyone else:
I have tried all the suggestions in this and related threads to no avail. Fortunately we only use the Storybook internally. The component works in our projects, but it's a pain to npm link it to another project when being worked on. |
Fresh app installation with create react app v2 and mapbox was added as first extra package. After run app in browser all I get in console is:
mapbox-gl-js version: 0.49
browser: Google Chrome
Steps to Trigger Behavior
yarn create react-app mapbox-app
cd mapbox-app
yarn add mapbox-gl
yarn start
Expected Behavior
Display functional map container. Work without errors in console.
Actual Behavior
Display only canvas with solid background and get
Uncaught ReferenceError: _typeof is not defined
in console few times.The text was updated successfully, but these errors were encountered: