Skip to content
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: ./node_modules/material-ui/es/styles/withStyles.js:36 #11044

Closed
tugrulyilmazer opened this issue Apr 17, 2018 · 9 comments
Labels
duplicate This issue or pull request already exists

Comments

@tugrulyilmazer
Copy link

tugrulyilmazer commented Apr 17, 2018

I have an error while creating an optimized production build of react application.

Error message is:
Failed to compile. Failed to minify the code from this file: ./node_modules/material-ui/es/styles/withStyles.js:36 Read more here: http://bit.ly/2tRViJ9

Error log: 2018-04-17T08_28_43_938Z-debug.log

  • [ x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Should compile with success for react production.

Current Behavior

Creating an optimized production build... Failed to compile.

Your Environment

Tech Version
Material-UI ^1.0.0-beta.42
React 16.3.1
@oliviertassinari oliviertassinari added the support: question Community support but can be turned into an improvement label Apr 17, 2018
@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 17, 2018

@tugrulyilmazer The relevant parts of the documentation:

@wyaeld
Copy link

wyaeld commented Jun 11, 2018

@oliviertassinari I'm not understanding a solution here

create-react-app is a logical starting point for many people doing app development, and material-ui appears to be published in a way that is not compatible OOTB with it trying to run a production build.

The docs about reducing a bundle size don't give any obvious answers. I'm not trying to be more efficient, I'm only importing what I need, but since withStyles is core to the entire theming experience, I can't avoid it, and the react-scripts build command can't get through it.

Specifically this line in @material-ui/core/es/styles/withStyles.js:L31

let indexCounter = Number.MIN_SAFE_INTEGER; // Exported for test purposes

results in this error

yarn run v1.7.0
$ react-scripts build
Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file: 

 	./node_modules/@material-ui/core/es/styles/withStyles.js:31 

Read more here: http://bit.ly/2tRViJ9

If there is a simple configuration workaround, could you please explain it. Some of us aren't as skilled at webpack and the like, and would greatly appreciate a little more guidance

@wyaeld
Copy link

wyaeld commented Jun 11, 2018

Following the docs referenced, attempted to solve problem by changing

import { withStyles}  from '@material-ui/core/styles';

to

import withStyles from '@material-ui/core/styles/withStyles';

but results in the same error.

Reading #11281 makes me think the issue is connected, and no matter how I specify the import webpack is still going to follow index.es.js and run into problems.

Is there another way around it?

@oliviertassinari
Copy link
Member

@wyaeld Something must be wrong with your setup. We can't help without a reproduction. The example we host in examples/create-react-app is working.

@wyaeld
Copy link

wyaeld commented Jun 13, 2018 via email

@Jaujon
Copy link

Jaujon commented Jun 19, 2018

I had the same issue, turned out I imported a component with the following statement: import Component from 'material-ui/es/Component/Component'. The es/ part in the import path was the problem.

@oliviertassinari oliviertassinari added duplicate This issue or pull request already exists and removed support: question Community support but can be turned into an improvement labels Jul 3, 2018
@oliviertassinari
Copy link
Member

It's a duplicate of #9056

@aemc
Copy link

aemc commented Jul 16, 2018

@Jaujon Thanks! I've had a similar issue. My IntelliJ auto imports for me so it decided to insert one of the options that had es/ in it. Removing all instances of it fixed the problem.

@joeflack4
Copy link

Much thanks to Jaujon. Should probably update these docs with this fix or otherwise print a better error message: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

6 participants