Open frabarz opened 1 year ago
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/*"
]
},
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 useimport
statement, but when trying to doimport * as tablerIcons from "@tabler/icons"
, I'm getting this error:This is caused by having the following
exports
key: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 toimport _ 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 doimport * as icons from "@tabler/icons/dist/es/tabler-icons.js"
either.The solution would be adding this to
"exports"
: