question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[vite] Internal server error: Dynamic require of "@svgr/core" is not supported

See original GitHub issue

I’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:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
IanVScommented, Sep 16, 2021

This can be triggered by adding "type": "module" to the example’s package.json file.

0reactions
IanVScommented, Oct 12, 2021

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).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found