[vite] Internal server error: Dynamic require of "@svgr/core" is not supported
See original GitHub issueI’m trying to use this package with vite and react, and I’ve followed the readme but I’m getting the following error during build:
[vite] Internal server error: Dynamic require of "@svgr/core" is not supported
This seems to be triggered from https://github.com/antfu/unplugin-icons/blob/038cf0e5431ff0f4889f5f150b18e74f19ebdced/src/core/compilers/jsx.ts#L6
Relevant parts of my vite.config.js:
import Icons from 'unplugin-icons/vite';
import { FileSystemIconLoader } from 'unplugin-icons/loaders';
export default defineConfig({
plugins: [
Icons({
compiler: 'jsx',
jsx: 'react',
customCollections: {
myproject: FileSystemIconLoader('./src/assets/icons'),
},
}),
],
});
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Vitejs | Uncaught Error: Dynamic require of "<path>.svg" is not ...
I'm trying to use react-flagpack in my project that uses Vite, but whenever I use ...
Read more >Troubleshooting - Vite
Syntax Error / Type Error happens #. Vite cannot handle and does not support code that only runs on non-strict mode (sloppy mode)....
Read more >Netlify Serverless Typescript functions fail with dynamic requires
Typescript serverless functions seem to be failing for me with {"errorType":"Error","errorMessage":"Dynamic require of \"util\" is not supported" ...
Read more >Compare Versions | @elliemae/pui-cli - Open Source Insights
We found errors while resolving dependencies that may result in an incomplete or inaccurate dependency graph. Show details. could not find a version...
Read more >vite-plugin-dynamic-import - npm
Enhance Vite builtin dynamic import. Latest version: 1.2.4, last published: a month ago. Start using vite-plugin-dynamic-import in your ...
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 FreeTop 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
Top GitHub Comments
This can be triggered by adding
"type": "module"
to the example’s package.json file.In the meantime, I can workaround it by changing my config file to commonjs and using
--config vite.config.cjs
(vite doesn’t seem to find the .cjs file automatically).