Skip to content

Commit

Permalink
fix: change the order of exports field keys to fix type resolution
Browse files Browse the repository at this point in the history
As both `./min` and `.` points to the same type definition file,
sometimes TypeScript will resolve the type definition file to the
`./min` key as it appears first.

microsoft/TypeScript#56290 (comment)

While this is not incorrect behavior, it breaks compatibility with older
build environments that do not support the `exports` field. (e.g.
TypeScript with `moduleResolution: "node"` instead of `bundler` or
`node16`), as the `./min` entry is only available through the `exports`
field.

Some Vue.js users are experiencing this issue:
vuejs/core#9521
  • Loading branch information
haoqunjiang committed Nov 6, 2023
1 parent 7ea4716 commit 4cb8fbe
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@
"main": "./dist/cjs/index.js",
"module": "./dist/mjs/index.js",
"exports": {
"./min": {
".": {
"import": {
"types": "./dist/mjs/index.d.ts",
"default": "./dist/mjs/index.min.js"
"default": "./dist/mjs/index.js"
},
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.min.js"
"default": "./dist/cjs/index.js"
}
},
".": {
"./min": {
"import": {
"types": "./dist/mjs/index.d.ts",
"default": "./dist/mjs/index.js"
"default": "./dist/mjs/index.min.js"
},
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
"default": "./dist/cjs/index.min.js"
}
}
},
Expand Down

0 comments on commit 4cb8fbe

Please sign in to comment.