mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.87k stars 32.26k forks source link

[Bug] Production JSS is different to Dev JSS #18615

Closed harveyconnor closed 4 years ago

harveyconnor commented 4 years ago

Current Behavior 😯

When running the application in a development build with no minification. The css looks correct and all of my styling matches what I have coded.

However when I build a production version, the jss seems to be mixed up and out of order. My overrides in my custom theme file are no longer being applied. And the defaults are overriding my overrides.

Even some of the styling used with makeStyles is being overridden by the defaults making my application's style very messed up.

Expected Behavior 🤔

Dev jss should match the production build.

Steps to Reproduce 🕹

Steps:

  1. Create a standard mui application and apply overrides in the custom theme.
  2. Build the application with parcel js and notice that the overrides do not work.

Context 🔦

Your Environment 🌎

tsconfig.json:

{
  "compilerOptions": {
    "target": "es2019",  
    "module": "commonjs",           
    "lib": ["dom", "es6", "webworker", "webworker.importscripts"],  
    "allowJs": true,       
    "jsx": "react",  
    "strict": true,           
    "moduleResolution": "node",         
    "allowSyntheticDefaultImports": true,  
    "esModuleInterop": true ,                 
    "inlineSourceMap": true,               
    "inlineSources": true,                 
    "experimentalDecorators": true,        
    "emitDecoratorMetadata": true,         
  },
  "include": [
    "src/**/*", "globals.d.ts"
  ],
  "exclude": [
    "node_modules",
    "**/*.spec.ts",
    "dist",
    ".cache"
  ]
}
Tech Version
Material-UI v4.7.0
React 16.12.0
Browser Chrome
TypeScript 3.7.2
harveyconnor commented 4 years ago

SOLVED! Using --experimental-scope-hoisting flag when running parcel build causes this weird bug. Related to: https://github.com/parcel-bundler/parcel/issues/1984