Skip to content

Commit

Permalink
Add separate type file for esm per TypeScript guidelines (#1886)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowspawn committed May 14, 2023
1 parent ffc7897 commit a4c96e6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Expand Up @@ -14,7 +14,7 @@ const javascriptSettings = {
};

const typescriptSettings = {
files: ['*.ts'],
files: ['*.ts', '*.mts'],
parserOptions: {
project: './tsconfig.json'
},
Expand Down
18 changes: 14 additions & 4 deletions package.json
Expand Up @@ -33,17 +33,27 @@
"lib/*.js",
"esm.mjs",
"typings/index.d.ts",
"typings/esm.d.mts",
"package-support.json"
],
"type": "commonjs",
"main": "./index.js",
"exports": {
".": {
"types": "./typings/index.d.ts",
"require": "./index.js",
"import": "./esm.mjs"
"require": {
"types": "./typings/index.d.ts",
"default": "./index.js"
},
"import": {
"types": "./typings/esm.d.mts",
"default": "./esm.mjs"
},
"default": "./index.js"
},
"./esm.mjs": "./esm.mjs"
"./esm.mjs": {
"types": "./typings/esm.d.mts",
"import": "./esm.mjs"
}
},
"devDependencies": {
"@types/jest": "^29.2.4",
Expand Down
3 changes: 3 additions & 0 deletions typings/esm.d.mts
@@ -0,0 +1,3 @@
// Just reexport the types from cjs
// This is a bit indirect. There is not an index.js, but TypeScript will look for index.d.ts for types.
export * from './index.js';

0 comments on commit a4c96e6

Please sign in to comment.