tabler / tabler-icons

A set of over 5700 free MIT-licensed high-quality SVG icons for you to use in your web projects.
https://tabler.io/icons
MIT License
18.31k stars 917 forks source link

How to use this project - not working #1027

Closed ghost closed 8 months ago

ghost commented 8 months ago

I mean, there is something wrong with the way you set up exports in your package.json.

How to import a single icon from this package? The same applies to @tabler/icons-png, how to import any image? It doesn't work, while importing a single image works in every other project. You need to give attention to this. Your tutorial in the readme.md doesn't work,

I continuously read the following error message: Failed to resolve import "@tabler/icons/icons" from "src/app.js". Does the file exist?

when I do: import {IconAbc} from '@tabler/icons/icons';

And

Failed to resolve entry for package "@tabler/icons". The package may have incorrect main/module/exports specified in its package.json: Missing "." specifier in "@tabler/icons" package

when I do: import {IconAbc} from '@tabler/icons';

I am using Vite as package builder. But this problem happens without Vite also.

Related, but not directly, is: considering that all projects are migrating to only .mjs instead of .cjs, it would be handy if you could simplify your package.json to potentially remove this complex exports and aliases for different formats, that is the cause of error. I refer to this:

"main": "dist/cjs/tabler-icons.js", "main:umd": "dist/umd/tabler-icons.js", "exports": { "./": [ "./icons/" ] }, "module": "dist/esm/tabler-icons.js",

Problem mentioned several times:

https://github.com/vitejs/vite/issues/15550

https://github.com/vitejs/vite/issues/3250

"@tabler/icons doesn't have icons/settings.svg specified in their exports field. So it is hidden from external users. Vite is working as expected."

https://github.com/vitejs/vite/issues?q=is%3Aissue+tabler+is%3Aclosed