Skip to content

Commit

Permalink
Emit type definitions with cjs format
Browse files Browse the repository at this point in the history
- Currently there is no difference between emitting type definitions with `cjs` or `esm` format, the only difference is the file extension. So we emit the type definitions with a `cjs` format to preserve the previous `.d.ts` extension as opposed to the new `.d.mts` extension.
  • Loading branch information
aryaemami59 committed Jun 19, 2024
1 parent 7e33eee commit 9abd7b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"description": "Selectors for Redux.",
"main": "./dist/cjs/index.js",
"module": "./dist/reselect.legacy-esm.js",
"types": "./dist/reselect.d.mts",
"types": "./dist/reselect.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dist/reselect.d.mts",
"types": "./dist/reselect.d.ts",
"import": "./dist/reselect.mjs",
"default": "./dist/cjs/index.js"
}
Expand Down
9 changes: 7 additions & 2 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ export default defineConfig((options): Options[] => {
name: 'Modern ESM',
target: ['esnext'],
format: ['esm'],
outExtension: () => ({ js: '.mjs' }),
dts: true
outExtension: () => ({ js: '.mjs' })
},

// Support Webpack 4 by pointing `"module"` to a file with a `.js` extension
Expand Down Expand Up @@ -93,6 +92,12 @@ export default defineConfig((options): Options[] => {
onSuccess: async () => {
await writeCommonJSEntry()
}
},
{
...commonOptions,
name: 'Type definitions',
format: ['cjs'],
dts: { only: true }
}
]
})

0 comments on commit 9abd7b2

Please sign in to comment.