Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exports key in @tabler/icons obscures main export #718

Open
frabarz opened this issue Jul 13, 2023 · 1 comment
Open

exports key in @tabler/icons obscures main export #718

frabarz opened this issue Jul 13, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@frabarz
Copy link

frabarz commented Jul 13, 2023

I need to obtain a hashmap of the SVG source strings for the icons, so I'm using the @tabler/icons package.
Due to project constraints, I can only use import statement, but when trying to do import * as tablerIcons from "@tabler/icons", I'm getting this error:

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

This is caused by having the following exports key:

  "exports": {
    "./*": [
      "./icons/*"
    ]
  },

I'm not sure about the spec, but when bundlers see a "exports" in the manifest, they ignore "main" and "module" and abide only by what exports say, and since there's no "." key in there, is not possible to import _ from "@tabler/icons" from the main dist file; this only allows individual imports of the SVG files.
Also, as "exports" obscures the whole package contents, is not possible to do import * as icons from "@tabler/icons/dist/es/tabler-icons.js" either.

The solution would be adding this to "exports":

".": ["./dist/es/tabler-icons.js"],
@jacktrusler
Copy link

Related: I upgraded from version 1.114.0 to 2.29 today for my next project and I'm getting this error

Package path . is not exported from package <project-path>/node_modules/@tabler/icons (see exports field in <project-path>/node_modules/@tabler/icons/package.json)

Here is the working 1.114.0 Version in the package.json:

"exports": {
    ".": {
      "import": "./icons-react/dist/index.esm.js",
      "require": "./icons-react/dist/index.cjs.js"
    },
    "./iconfont/*": "./iconfont/*",
    "./*": [
      "./icons/*",
      "./icons-png/*"
    ]
  },

And here is the broken 2.29.0 version in the package.json:

"exports": {
    "./*": [
      "./icons/*"
    ]
  },

squishyu added a commit to squishyu/tabler-icons that referenced this issue Dec 8, 2023
@BG-Software-BG BG-Software-BG added the bug Something isn't working label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants