Skip to content

Commit 57b0b75

Browse files
committed
fix: polyfill import.meta.resolve
1 parent d7fc5a2 commit 57b0b75

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

.changeset/long-bugs-press.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'phosphor-icons-tailwindcss': patch
3+
---
4+
5+
polyfill `import.meta.resolve` to better support older Node versions and Tailwind v3

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"exports": {
88
".": {
99
"types": "./src/plugin.d.ts",
10-
"import": "./src/plugin.js"
10+
"import": "./src/plugin.js",
11+
"default": "./src/plugin.js"
1112
}
1213
},
1314
"types": "src/plugin.d.ts",
@@ -45,7 +46,8 @@
4546
"ci:publish": "changeset publish && pnpm install"
4647
},
4748
"dependencies": {
48-
"@phosphor-icons/core": "^2.1.1"
49+
"@phosphor-icons/core": "^2.1.1",
50+
"import-meta-resolve": "^4.1.0"
4951
},
5052
"peerDependencies": {
5153
"tailwindcss": ">=3.4.14 || >=4.0.0-alpha.34"

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/plugin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { readFileSync, existsSync } from 'fs';
22

33
import { icons } from '@phosphor-icons/core';
4+
import { resolve } from 'import-meta-resolve';
45
import createPlugin from 'tailwindcss/plugin.js';
56

67
const VARIANTS = ['thin', 'light', 'regular', 'bold', 'fill', 'duotone'];
@@ -51,8 +52,9 @@ export default createPlugin.withOptions(
5152
let url = 'icon-not-found';
5253
if (ICON_SET.has(name) && VARIANTS.includes(weight)) {
5354
const fileUrl = new URL(
54-
import.meta.resolve(
55+
resolve(
5556
`@phosphor-icons/core/assets/${weight}/${name}${weight === 'regular' ? '' : `-${weight}`}.svg`,
57+
import.meta.url,
5658
),
5759
);
5860
const path = fileUrl.pathname;

0 commit comments

Comments
 (0)