'ReactComponent' is not exported by lib
See original GitHub issueCurrent Behavior
I am trying to bundle a svg publishable React ibrary, but when I try run build it fails with below error
Error during bundle: Error: 'ReactComponent' is not exported by <path/to/svg>
Expected Behavior
Build should be sucessful
Steps to Reproduce
Update project’s worspace.json with
"webpackConfig": "@nrwl/react/plugins/webpack",
Add typing to base tsconfig.base.json
"files": ["./node_modules/@nrwl/react/typings/image.d.ts"],
run
nx affected:build --base=remotes/origin/main --with-deps
Failure Logs
'elementType' is not exported by 'node_modules\prop-types\index.js'
'forwardRef' is not exported by 'node_modules\react\index.js'
'createElement' is not exported by 'node_modules\react\index.js'
'createElement' is not exported by 'node_modules\react\index.js'
Error during bundle: Error: 'ReactComponent' is not exported by <path to svg>
Bundle failed: iep-logos
Environment
node: 16.3
Appreciate it if someone could provide a fix this. We have tring to publish internal React library based on SVGs and this is turning out to be major blocker.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (1 by maintainers)
Top Results From Across the Web
'ReactComponent' is not exported from svg - Stack Overflow
Since you are using create-react-app the SVGR library is already installed and being used to process SVG files as a ReactComponent.
Read more >Extending Rollup configuration for NX - Anton Ball
Error during bundle: Error: 'ReactComponent' is not exported by libs/library-name/src/lib/Icons/activity-log.svg Bundle failed: library-name.
Read more >JavaScript default exports aren't always fun, or how I wasted 4 ...
Normally React components are default exports, and other things such as PropTypes and functions / hooks are exported as named exports. But in ......
Read more >Rollup Config for React Component Library With TypeScript + ...
I am by no means a master in Rollup nor this is a definitive guide in building a React Component Library. I am...
Read more >How to Create and Publish a React Component Library
Because we are creating a library, we are going to create index files for each tier, and export our components from each one...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Can confirm that this is still an issue in the default setup for Nx
Moved past this today by patching the rollup config to include svgr,