Giter Site home page Giter Site logo

Comments (8)

MonstraG avatar MonstraG commented on May 24, 2024 13

For now, I've dealt with this by adding it to transpilePackages in my Next.js app:

next.config.js

/** @type {import('next').NextConfig} */
module.exports = {
  reactStrictMode: true,
  transpilePackages: ['@mui/x-charts'],
};

from mui-x.

oliviertassinari avatar oliviertassinari commented on May 24, 2024 3

I faced the same problem with Next.js's Material UI starter example (the most used one).

Error: require() of ES Module /Users/oliviertassinari/nextjs-with-typescript/node_modules/d3-shape/src/index.js from /Users/oliviertassinari/nextjs-with-typescript/node_modules/@mui/x-charts/BarChart/formatter.js not supported.

Screenshot 2023-08-29 at 00 33 48

#9826 (comment) 's workaround did the trick.

from mui-x.

cherniavskii avatar cherniavskii commented on May 24, 2024

@alexfauquette This might be coming from the main entry point https://unpkg.com/browse/@mui/[email protected]/context/CartesianContextProvider.js

from mui-x.

alexfauquette avatar alexfauquette commented on May 24, 2024

Yes, but the export of the package.json should import those files from https://unpkg.com/browse/@mui/[email protected]/esm/context/CartesianContextProvider.js which does not have this issue 🤔

  "exports": {
    ".": {
      "require": "./index.js",
      "import": "./esm/index.js"
    },
    "./*": {
      "require": "./*",
      "import": "./esm/*"
    }
  },

from mui-x.

alexfauquette avatar alexfauquette commented on May 24, 2024

Did you also had to transpile the d3-* libraries?

from mui-x.

MonstraG avatar MonstraG commented on May 24, 2024

No (at least I did not need to include them in the list). I'm unsure on whether it's done for dependencies automatically or not.

from mui-x.

MonstraG avatar MonstraG commented on May 24, 2024

Updated to @mui/[email protected], tried removing charts from transpilePackages, now when importing charts like this:

import { PieChart } from "@mui/x-charts";

I get

Error: Cannot find module /home/project/node_modules/@mui/x-charts/PieChart'
  at createEsmNotFoundErr (node:internal/modules/cjs/loader:1096:15)
  at finalizeEsmResolution (node:internal/modules/cjs/loader:1089:15)

.

Adding modularizeImports (like I already do with @mui/material):

	modularizeImports: {
		"@mui/material": {
			transform: "@mui/material/{{member}}"
		},
		...
		"@mui/x-charts": {
			transform: "@mui/x-charts/{{member}}"
		}
	},

Gives me the same error but with a bunch of

 Attempted import error: '@mui/x-charts/BarChart' does not contain a default export (imported as 'BarChart').

So for now, I'm leaving charts in transpilePackages, and out of modularizeImports.

from mui-x.

tedma4 avatar tedma4 commented on May 24, 2024

@oliviertassinari What version of Next were you using?

from mui-x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.