-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Failed to minify the code from this file #3734
Comments
I empathize with your frustration but the solution you propose (run Babel with the app config on dependencies) is unsafe and incorrect. It seems correct from your point of view because it would solve your immediate problem. But I know that if we do this, we’ll get equally frustrated people with different kinds of breakages. We are tracking this problem in #1125. If you want to send a PR to fix it in the correct way as explained in that issue, you’re most welcome. If you don’t, unfortunately you’ll have to wait for somebody else to come around and fix it. |
(That said there’s also an unrelated problem of Uglify not handling ES6 code which will be fixed separately. But even if we do this, and minification works, your code still won’t work in order browsers.) |
FYI, we're starting the work to compile deps with Let us know if you have feedback about how this should work. |
@gaearon I don't have any special work flow for this, I have a gulp task that compiles the dependency in the node_modules folder before I building using CRA and so far it seems to be working for me. |
Hello I just started using react. I'm running
The app works fine with @rbndg can you link to solutions you mentioned? |
@kirkins The issue is that CRA currently doesn't compile dependencies. So you should either move the dependency to outside of the node_modules folder and run build |
@kirkins Please follow the link in the error message you posted, it literally explains the problem. If something isn’t clear there we’re happy to clarify but please try to read the information we specifically put at that link URL first 🙂 Thank you! |
@gaearon thanks, I was tired, didn't see the link at first. I found it last night and made the issue as suggested. Apparently it's not supposed to work with front-end, but I've already used it and it works perfectly fine in my React app, aside from compiling. So I want to compile myself as I don't want to re-write the app right now. I'm getting an error on Is it possible to compile this to ES5? |
Yes, it's probably using a dropped or outdated Babel proposal. Maybe ticking |
@gaearon thanks seems to be working. https://www.npmjs.com/package/fb-es5 |
I'm getting a similar error (Failed to minify the code from this file), but the package that makes the build fail is a dev dependency. Shouldn't it be ignored in a production build? |
If you see this error you are importing that package. |
Indeed it's actually a JS file that is only meant for development that is importing it. But how can I remove that file from the build? |
Don’t import it? Sorry, it’s hard to help based on a vague description. Perhaps you can create a new issue with a reproducing project? |
It's not really an issue, I just haven't figured out how to do this in the docs. I'll be more specific. I have a file called scraper.js that I use to crawl a website and store some of its data in a JSON file. To do so I import in that file an npm package called image-downloader. My problem is that I don't want scraper.js to be part of the build generated by After some research I found a similar issue. However the solution you gave ( I hope that's clearer. Thanks for the help anyway (and on a sunday!) |
Sorry, this is still not very clear 🙂
It won’t be a part of the build unless you explicitly import it in your app. If it’s just something you manually run once in a while I don’t see why it would end up in the build. My only guess is you’re doing some dynamic require like It’s really hard to help at this point without a reproducing project. If you experience this please file an issue with a minimal example and we will take a look. But rest assured that a file won’t be included in the build unless your code (traced from |
The only mention I have of that file throughout my app Could that be what imports the file in the build? edit: After some testing I see that this line in |
At this point we can’t help without a reproducing file. Yes, it should crash the build. The only case that I’m aware of in which it wouldn’t is related to dynamic imports (the case I described in my above comment). |
Sorry for the delay, I couldn't reproduce the issue and kinda gave up, but found a fix eventually. The file was simply included in the build because it was in the |
referring to #3734 (comment) I tried compiling wagenaartje/neataptic#81 myself but i am still getting the error.
I've read that we should be raising an issue with authors but wagenaartje/neataptic#112 he is no longer actively maintaining it, can someone point me in the right direction and i'll send him a PR |
Have a similar issue with npm run build, shows an error: Failed to minify the code from this file: Failed at the pwa-experiment@0.1.0 build script |
@chandas you can use qs package.
I solved it this way |
@mikdatdogru thanks for your suggestions. Kindly pardon my mistakes if any with this code as I am totally new to this development in React. I have the following code snippet:
and now as per your suggestion when I changed the import from 'query-string' to 'qs', then I am getting the following error: So is there any way I can refactor this code snippet to make it work with import of 'qs' Thanks for your suggestions. |
@chandas |
importing "qs" solved this particular problem but in my case it has introduced another one. While |
We have started compiling node modules in the 2.0 beta (next tag) release. This should mitigate majority of these problems. Search for the 2.0 roadmap for more details! |
This shipped in 2.0. |
- Replaced query-string with qs npm module - Issue : facebook/create-react-app#3734 - Fix : facebook/create-react-app#3734 (comment)
Failed to minify the code from this file
I keep running to this error with many packages that i'm using in my project, most notably bitcoinjs-lib.
The current solutions provided in the documentation are in my opinion unhelpful, basically requiring other libraries to work with CRA instead of other way around.
I know that this project doesn't want to developer to mess around with webpack/babel settings but allowing the user to skip minification for some files/folders without ejecting would be very helpful or make CRA work libs in node_modules.
Thanks
The text was updated successfully, but these errors were encountered: