Skip to content

Commit

Permalink
List types separately in each dist type
Browse files Browse the repository at this point in the history
The uglier more correct work around for TypeScript's strange interaction
with package.json exports in hybrid modules.
  • Loading branch information
isaacs committed Jan 15, 2023
1 parent 20a9dcb commit a08200d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
"main": "./dist/cjs/src/index.js",
"module": "./dist/mjs/src/index.js",
"bin": "./dist/cjs/src/bin.js",
"types": "./dist/cjs/src/index.d.ts",
"exports": {
".": {
"types": "./dist/cjs/src/index.d.ts",
"import": "./dist/mjs/src/index.js",
"require": "./dist/cjs/src/index.js"
"import": {
"default": "./dist/mjs/src/index.js",
"types": "./dist/mjs/src/index.d.ts"
},
"require": {
"default": "./dist/cjs/src/index.js",
"types": "./dist/cjs/src/index.d.ts"
}
}
},
"files": [
Expand Down
11 changes: 8 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ t.same(
require('../package.json').exports,
{
'.': {
types: './dist/cjs/src/index.d.ts',
import: './dist/mjs/src/index.js',
require: './dist/cjs/src/index.js',
import: {
default: './dist/mjs/src/index.js',
types: './dist/mjs/src/index.d.ts',
},
require: {
default: './dist/cjs/src/index.js',
types: './dist/cjs/src/index.d.ts',
},
},
},
'nothing else exported except main'
Expand Down

0 comments on commit a08200d

Please sign in to comment.