Skip to content

Commit 4d88a43

Browse files
committed
fix: Fix "Masquerading as ESM"
1 parent 121f901 commit 4d88a43

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
"module": "./dist/index.js",
1313
"exports": {
1414
".": {
15-
"types": "./dist/index.d.ts",
15+
"types": {
16+
"require": "./dist/index.d.cts",
17+
"import": "./dist/index.d.ts"
18+
},
1619
"require": "./dist/index.cjs",
1720
"import": "./dist/index.js"
1821
}

rollup.config.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,31 @@ export default [
1212
input: "./src/index.ts",
1313
output: {
1414
file: packageJSON.exports["."].require,
15-
format: "cjs",
15+
format: "commonjs",
1616
},
1717
plugins: [json(), typescript(), autoExternal()],
1818
},
1919
{
2020
input: "./src/index.ts",
2121
output: {
2222
file: packageJSON.exports["."].import,
23-
format: "esm",
23+
format: "module",
2424
},
2525
plugins: [commonjs(), json(), typescript(), autoExternal()],
2626
},
2727
{
2828
input: "./src/index.ts",
2929
output: {
30-
file: packageJSON.exports["."].types,
31-
format: "esm",
30+
file: packageJSON.exports["."].types["require"],
31+
format: "commonjs",
32+
},
33+
plugins: [commonjs(), dts()],
34+
},
35+
{
36+
input: "./src/index.ts",
37+
output: {
38+
file: packageJSON.exports["."].types["import"],
39+
format: "module",
3240
},
3341
plugins: [dts()],
3442
},

0 commit comments

Comments
 (0)