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.64k stars 32.22k forks source link

Can't build with yarn2 #20797

Closed bbigras closed 4 years ago

bbigras commented 4 years ago

Current Behavior šŸ˜Æ

When I run yarn start I get:

Failed to compile.

./.yarn/cache/jss-plugin-rule-value-function-npm-10.1.1-f63c97f8af-2.zip/node_modules/jss-plugin-rule-value-function/dist/jss-plugin-rule-value-function.esm.js
Module not found: jss-plugin-rule-value-function tried to access tiny-warning, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Expected Behavior šŸ¤”

Steps to Reproduce šŸ•¹

Steps:

  1. mkdir test
  2. cd test
  3. yarn set version berry
  4. yarn dlx create-react-app my-app --template typescript
  5. cd my-app
  6. yarn add @material-ui/core
  7. add a simple <Button>Test</Button> to App.tsx (with import Button from '@material-ui/core/Button';)
  8. yarn start

Context šŸ”¦

I'm trying to use yarn2 to get that sweet zero-Installs feature.

Your Environment šŸŒŽ

OS: NixOS unstable

Tech Version
Material-UI v4.9.12
React 16.13.1
Browser Firefox
TypeScript 3.7.2
yarn 2.0.0-rc.32

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react"
  },
  "include": [
    "src"
  ]
}
oliviertassinari commented 4 years ago

@bbigras Please open the issue in JSS, It's an issue on their end. Also, I would be in favor of dropping the dependency on tiny-warning.

eps1lon commented 4 years ago

Requires the release of https://github.com/cssinjs/jss/pull/1315

jozsi commented 4 years ago

I am getting a similar issue on v4.9.12 when react and react-dom are added as a peer dependency in my app (moving them to a normal dependency made the issue disappear):

./.yarn/$$virtual/@material-ui-core-virtual-613969f2c4/0/cache/@material-ui-core-npm-4.9.12-eaaa062c1e-2.zip/node_modules/@material-ui/core/Modal/TrapFocus.js
Module not found: @material-ui/core tried to access react (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.
eps1lon commented 4 years ago

I am getting a similar issue on v4.9.12 when react and react-dom are added as a peer dependency in my app (moving them to a normal dependency made the issue disappear):

peer dependencies of a library need to be added as normal dependencies in your app. This is unrelated to this issue.

eps1lon commented 4 years ago

If you want to be notified when this issue is fixed watch https://github.com/cssinjs/jss for releases (click "watch" and then "releases only"). More specifically, watch for the next release of jss-plugin-rule-value-function.

oliviertassinari commented 4 years ago

JSS v10.2.0 was released, problem solved.