-
Notifications
You must be signed in to change notification settings - Fork 47
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
Material-ui and Typescript error when bundling #29
Comments
For those who would have the same issue, this post helped me a lot : styled-components/styled-components#1654 (comment) |
I have this issue, and the linked issue doesn't have a solution |
The linked issue resolved mine with an additional step: in rollup.config.js: const commonjsOptions = {
include: 'node_modules/**',
// left-hand side can be an absolute path, a path
// relative to the current directory, or the name
// of a module in node_modules
namedExports: {
'node_modules/react/index.js': [
'cloneElement',
'createContext',
'Component',
'createElement',
],
'node_modules/react-dom/index.js': ['render', 'hydrate'],
'node_modules/react-is/index.js': [
'isElement',
'isValidElementType',
'ForwardRef',
'Memo',
],
},
} and then, every time you have a |
I ended up adding |
For me it seems that an specific import path of the styled component from Material UI causes issues whenever is imported on one path rather than the other: Bad one that causes errors:
Good one that causes no errors
The two paths have a component with the same name, but one causes errors on build and the other does not. Probably if you @qramilq have a place where a component or you are using styled from material styles that can be the issue. Here you can also see in which places the function and imports that cause the issues are being used: https://github.com/mui-org/material-ui/search?q=getDisplayName |
I experienced this issue when I mistakenly import Box component from import { Typography } from "@mui/material"
import { Box } from "@mui/system"
import React from "react"
export const MyBox = ()=><Box><Typography>I am a box.</Typography></Box> When run
Changing Box import statement to |
Steps to reproduce:
npx create-react-library
yarn add @material-ui/core
src/TextField
folder withindex.tsx
file, which has this code:Expected behavior
no errors
Actual behavior
rollup v0.62.0
bundles src/index.tsx → dist\index.js, dist\index.es.js...
[!] Error: 'ForwardRef' is not exported by node_modules\react-is\index.js
https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
node_modules@material-ui\utils\esm\getDisplayName.js (2:9)
1: import _typeof from "@babel/runtime/helpers/typeof";
2: import { ForwardRef } from 'react-is'; // Simplified polyfill for IE 11 support
The text was updated successfully, but these errors were encountered: