You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Greetings
I would like to ask you if this is a bug or if something must be configured to enable the proper importing.
In a module/ESM project, when trying to import an icon from library "@tabler/icons", one person can try to import either a .svg file directly, or its equivalent javascript file, which is a const that exports the icon.
I have tried to import an icon in both ways. I also tried to import from index of icons.
I don't even tried yet to make use of the icon, I just try to import firstly.
Whenever I try to build the project using Vite, I see an error in console. It seems that the package is being imported as if it was commonjs. Or maybe it is something related to the name, which contains a @ character.
The same error is observed when trying to import .png files from "@tabler/icons-png" library. I suspected it may be an error in how their package.json is defined. However, it is worth noting that they do offer commonjs and modules definitions in their package.json.
/* stackblitz */
[vite]: Rollup failed to resolve import "@tabler/icons-png/icons/2fa.png" from "/home/projects/vitejs-vite-uws8wh/main.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to build.rollupOptions.external
error during build:
Error: [vite]: Rollup failed to resolve import "@tabler/icons-png/icons/2fa.png" from "/home/projects/vitejs-vite-uws8wh/main.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to build.rollupOptions.external
at viteWarn (/home/projects/vitejs-vite-uws8wh/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:67362:27)
at onRollupWarning (/home/projects/vitejs-vite-uws8wh/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:67390:17)
at onwarn (/home/projects/vitejs-vite-uws8wh/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:67107:28)
at getDefaultOnLog/< (/home/projects/vitejs-vite-uws8wh/node_modules/rollup/dist/es/shared/node-entry.js:17423:19)
at logger (/home/projects/vitejs-vite-uws8wh/node_modules/rollup/dist/es/shared/node-entry.js:19081:14)
at handleInvalidResolvedId (/home/projects/vitejs-vite-uws8wh/node_modules/rollup/dist/es/shared/node-entry.js:18027:26)
at getResolveStaticDependencyPromises/< (/home/projects/vitejs-vite-uws8wh/node_modules/rollup/dist/es/shared/node-entry.js:17985:26)
/* local */
[vite]: Rollup failed to resolve import "@tabler/icons-png/icons/2fa.png" from "/.../MyFile.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to build.rollupOptions.external
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Instead of import icon from '@tabler/icons-png/icons/2fa.png', the import should be import icon from '@tabler/icons-png/2fa.png', because exports field declares like that.
Describe the bug
Greetings
I would like to ask you if this is a bug or if something must be configured to enable the proper importing.
In a module/ESM project, when trying to import an icon from library "@tabler/icons", one person can try to import either a .svg file directly, or its equivalent javascript file, which is a const that exports the icon.
I have tried to import an icon in both ways. I also tried to import from index of icons.
I don't even tried yet to make use of the icon, I just try to import firstly.
Whenever I try to build the project using Vite, I see an error in console. It seems that the package is being imported as if it was commonjs. Or maybe it is something related to the name, which contains a @ character.
The same error is observed when trying to import .png files from "@tabler/icons-png" library. I suspected it may be an error in how their package.json is defined. However, it is worth noting that they do offer commonjs and modules definitions in their package.json.
I would appreciate if you could review this issue, and I appreciate if possible, a solution is available for https://github.com/tabler/tabler-icons or here.
PS - maybe it is related: https://stackoverflow.com/questions/71203455/rollup-failed-to-resolve-alias-in-vite
Reproduction
https://stackblitz.com/edit/vitejs-vite-uws8wh?file=package.json
Steps to reproduce
No response
System Info
Used Package Manager
npm
Logs
/* stackblitz */
[vite]: Rollup failed to resolve import "@tabler/icons-png/icons/2fa.png" from "/home/projects/vitejs-vite-uws8wh/main.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
build.rollupOptions.external
error during build:
Error: [vite]: Rollup failed to resolve import "@tabler/icons-png/icons/2fa.png" from "/home/projects/vitejs-vite-uws8wh/main.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
build.rollupOptions.external
at viteWarn (/home/projects/vitejs-vite-uws8wh/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:67362:27)
at onRollupWarning (/home/projects/vitejs-vite-uws8wh/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:67390:17)
at onwarn (/home/projects/vitejs-vite-uws8wh/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:67107:28)
at getDefaultOnLog/< (/home/projects/vitejs-vite-uws8wh/node_modules/rollup/dist/es/shared/node-entry.js:17423:19)
at logger (/home/projects/vitejs-vite-uws8wh/node_modules/rollup/dist/es/shared/node-entry.js:19081:14)
at handleInvalidResolvedId (/home/projects/vitejs-vite-uws8wh/node_modules/rollup/dist/es/shared/node-entry.js:18027:26)
at getResolveStaticDependencyPromises/< (/home/projects/vitejs-vite-uws8wh/node_modules/rollup/dist/es/shared/node-entry.js:17985:26)
/* local */
[vite]: Rollup failed to resolve import "@tabler/icons-png/icons/2fa.png" from "/.../MyFile.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
build.rollupOptions.external
Validations
The text was updated successfully, but these errors were encountered: