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

[DataGrid] The DataGrid is not compatible with the new package name of the core repository #2527

Closed
2 tasks done
alb7h opened this issue Sep 3, 2021 · 17 comments · Fixed by #2571
Closed
2 tasks done
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! v5.x

Comments

@alb7h
Copy link

alb7h commented Sep 3, 2021

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

When you replace the old @material-ui/* with the newer @mui/* packages for the rc versions, the datagrid is breaking.

Could not find dependency: '@material-ui/core' relative to '/node_modules/@mui/x-data-grid/dist/index-esm.js'

Expected behavior 🤔

It should work with the new package names

Steps to reproduce 🕹

Click link https://codesandbox.io/s/vigilant-noyce-xx89p?file=/src/Demo.tsx

or alternatively:

  1. Remove any @material-ui/* packages
  2. Add @mui/* packages
  3. Restart app
  4. 💥

Context 🔦

No context, but a simple workaround for now.

You can add this to package.json to alias the new packages to the old

    "@material-ui/core": "npm:@mui/material@5.0.0-rc.0",
    "@material-ui/styles": "npm:@mui/styles@5.0.0-rc.0",

You can also do this via webpack but for some reason, it worked with storybook's webpack but not with nextjs's webpack.

Your environment 🌎

`npx @mui/envinfo`
npx: installed 2 in 3.184s

  System:
    OS: macOS 11.4
  Binaries:
    Node: 14.17.3 - ~/.volta/tools/image/node/14.17.3/bin/node
    Yarn: 3.0.1 - ~/.volta/tools/image/yarn/1.22.10/bin/yarn
    npm: 6.14.13 - ~/.volta/tools/image/node/14.17.3/bin/npm
  Browsers:
    Chrome: 92.0.4515.159
    Edge: Not Found
    Firefox: Not Found
    Safari: 14.1.1

Order ID 💳 (optional)

28357

@alb7h alb7h added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 3, 2021
@Edelf
Copy link

Edelf commented Sep 3, 2021

Same is happening here:

<dir>/node_modules/@mui/x-data-grid/dist/index-esm.js
Module not found: Can't resolve '@material-ui/core/Badge' in '<dir>\node_modules\@mui\x-data-grid\dist'

@flaviendelangle
Copy link
Member

flaviendelangle commented Sep 3, 2021

The problem with the last version is that x-data-grid depends on @material-ui/core and since the last release of the core, the package is now named @mui/material (see /~https://github.com/siriwatknp/material-ui/blob/release/5.0.0-rc.0/CHANGELOG.md#muimaterial500-rc0)

The next release of the Grid should solve it

@flaviendelangle flaviendelangle added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 3, 2021
@flaviendelangle flaviendelangle changed the title Incompatibility with @mui/material@5.0.0-rc.0 [bug] The DataGrid is not compatible with the new package name of the core repository Sep 3, 2021
@Edelf
Copy link

Edelf commented Sep 3, 2021

Is there any temporary solution to allow @mui/x-data-grid with @mui/core? Or are we forced to keep using the @material-ui beta?

@m4theushw
Copy link
Member

Is there any temporary solution to allow @mui/x-data-grid with @mui/core? Or are we forced to keep using the @material-ui beta?

Yes, you can add a few aliases to your webpack.config.js or babel.config.js. We use this trick to make the docs work with the RC version.

'@material-ui/core': '../node_modules/@mui/material'
'@material-ui/styles': '../node_modules/@mui/styles'
'@material-ui/icons': '../node_modules/@mui/icons-material'
'@material-ui/lab': '../node_modules/@mui/material'

@m4theushw m4theushw changed the title [bug] The DataGrid is not compatible with the new package name of the core repository [DataGrid] The DataGrid is not compatible with the new package name of the core repository Sep 3, 2021
@oliviertassinari oliviertassinari added this to the Sprint 22 milestone Sep 6, 2021
@rart
Copy link

rart commented Sep 8, 2021

@m4theushw is that achievable with CRA without ejecting or using things like cra rewired and such?

@stevenkampen
Copy link

@rart No I don't believe so.

@m4theushw
Copy link
Member

m4theushw commented Sep 8, 2021

@rart @stevenkampen Yes, I managed to make it work with v5 by using /~https://github.com/aze3ma/react-app-rewire-aliases. I didn't have to eject. I used the following aliases:

// config-overrides.js
const rewireAliases = require('react-app-rewire-aliases');
const path = require('path');

module.exports = function override(config, env) {
  config = rewireAliases.aliasesOptions({
    '@material-ui/core': path.resolve(__dirname, './node_modules/@mui/material'),
    '@material-ui/styles': path.resolve(__dirname, './node_modules/@mui/styles'),
  })(config, env);
  return config;
};

@rart
Copy link

rart commented Sep 8, 2021

I did yarn add @material-ui/core@npm:@mui/material@5.0.0-rc.1 @material-ui/styles@npm:@mui/styles@5.0.0-rc.1 which in theory should just work.

It did give me some trouble...

warning Pattern ["@mui/material@^5.0.0-rc.1"] is trying to unpack in the same destination "/Users/rart/Library/Caches/Yarn/v6/npm-@material-ui-core-5.0.0-rc.1-456218bfeb659dfb17c516ecc03f86013feaf253-integrity/node_modules/@material-ui/core" as pattern ["@material-ui/core@npm:@mui/material@5.0.0-rc.1"]. This could result in non-deterministic behavior, skipping.
warning Pattern ["@mui/styles@^5.0.0-rc.1"] is trying to unpack in the same destination "/Users/rart/Library/Caches/Yarn/v6/npm-@material-ui-styles-5.0.0-rc.1-479c082afbdef116ad5323e15e3f1324efd29205-integrity/node_modules/@material-ui/styles" as pattern ["@material-ui/styles@npm:@mui/styles@5.0.0-rc.1"]. This could result in non-deterministic behavior, skipping.

...but after clearing node modules and yarn add/remove a couple of times it seems to be working.

Despite the hiccups, no rewiring or eject is needed using this route.

Hope the bug is solved soon.

@callmeberzerker
Copy link

This is kinda stupid @material-ui team. Before release -> naming "tidying up" is non-sensical. The upgrade path from v4 to v5 should have been smoother, and while I understand that breaking changes need to happen - at least plan them accordingly and let people who migrated early on the @next train to have smooth sailing. Now it's just a clusterfuck, massive renames, semi working codemods and on top of that core libraries that don't work with each other. 🤦

Do better.

@rodrigonzalz
Copy link

Is there any temporary solution to allow @mui/x-data-grid with @mui/core? Or are we forced to keep using the @material-ui beta?

Yes, you can add a few aliases to your webpack.config.js or babel.config.js. We use this trick to make the docs work with the RC version.

'@material-ui/core': '../node_modules/@mui/material'
'@material-ui/styles': '../node_modules/@mui/styles'
'@material-ui/icons': '../node_modules/@mui/icons-material'
'@material-ui/lab': '../node_modules/@mui/material'

Tried this and unless I am doing it wrong (possibly xd) it is not working for me.
In my case I use Next and set up on the next.config.js the following

config.resolve.alias = {
      ...config.resolve.alias,
      '@material-ui/core': path.resolve(__dirname, './node_modules/@mui/material'),
      '@material-ui/styles': path.resolve(__dirname, './node_modules/@mui/styles'),
      '@material-ui/icons': path.resolve(__dirname, './node_modules/@mui/icons-material'),
      '@material-ui/lab': path.resolve(__dirname, './node_modules/@mui/lab'),
    };

I have tried without the whole path.resolve and multiple variations, but none have worked.
I think this only works with your own imports, will not work for the imports of an external dependency.
For example I get the same issue with notistack, that also hasn't made a release for the @mui packages.

@Khatib-Abbas
Copy link

Khatib-Abbas commented Sep 9, 2021

For Next.js version  i use this config, work with 95% (litle css problem).

If you have any sugestions

//.babelrc

{
  "presets": ["next/babel"],
  "plugins": [
    ["module-resolver", {
      "root": ["./"],
      "alias": {
        "@material-ui/core": "../node_modules/@mui/material",
        "@material-ui/styles": "../node_modules/@mui/styles",
        "@material-ui/icons": "../node_modules/@mui/icons-material",
        "@material-ui/lab": "../node_modules/@mui/material"
      }
    }]
  ]
}

@leolozes
Copy link

leolozes commented Sep 9, 2021

After some testing, I got it working with:

    resolve: {
      alias: {
        '@material-ui/core': '@mui/material',
        '@material-ui/styles': '@mui/styles',
        '@material-ui/icons': '@mui/icons-material',
        '@material-ui/lab': '@mui/material'
      }
    }

in my webpack.config.ts.

Thanks!

@m4theushw
Copy link
Member

m4theushw commented Sep 9, 2021

For people that need a v5 compatible version and don't want to wait for the next release, you can use packages generated by #2571.

"@mui/x-data-grid-pro": "https://pkg.csb.dev/mui-org/material-ui-x/commit/9f39f255/@mui/x-data-grid-pro",
"@mui/x-data-grid": "https://pkg.csb.dev/mui-org/material-ui-x/commit/9f39f255/@mui/x-data-grid",

Example: https://codesandbox.io/s/material-demo-forked-shhg4?file=/demo.js


@Khatib-Abbas What is your "little css problem"? It might be some conflict between jss and emotion, it happed with me.

@rart
Copy link

rart commented Sep 9, 2021

"@mui/x-data-grid-pro": "https://pkg.csb.dev/mui-org/material-ui-x/commit/9f39f255/@mui/x-data-grid-pro",
"@mui/x-data-grid": "https://pkg.csb.dev/mui-org/material-ui-x/commit/9f39f255/@mui/x-data-grid",

Thanks, @m4theushw!

Sorry for the off-topic question but this is pretty useful: how is it that one manages to publish like that? I didn't manage to find docs or anything for pkg.csb.dev.

@m4theushw
Copy link
Member

@rart https://codesandbox.io/docs/ci

@jb-thery
Copy link

jb-thery commented Sep 14, 2021

@flaviendelangle Hello, there is any update with this issue ?

@flaviendelangle
Copy link
Member

flaviendelangle commented Sep 14, 2021

@jbty you can follow this comment to have the new naming today #2527 (comment)

Otherwise, we have merged the migration.
We will release the version v5.0.0-beta.0 by the end of the week with full v5 and @mui/* migration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! v5.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.