Skip to content

Commit c90534b

Browse files
fix(package): fix esm and cjs types
Errors: 1. pkg.exports.import.types is ./esm/index.d.mts but the file does not exist. 2. pkg.exports.require.types is ./cjs/index.d.ts but the file does not exist. 3. pkg.types is ./esm/index.d.mts but the file does not exist.
1 parent 303e8d3 commit c90534b

File tree

4 files changed

+21
-30
lines changed

4 files changed

+21
-30
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,8 @@ jobs:
3535
- name: Run module tests
3636
run: npm run test:esm
3737

38-
- name: Build artifacts
38+
- name: Build package
3939
run: npm run build
40+
41+
- name: Lint package
42+
run: npm run lint:package

.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
npm run build
22
npm run test:ci
3+
npm run test:esm
4+
npm run lint:package
35
npx lint-staged

package-lock.json

Lines changed: 11 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@
1111
"default": "./esm/index.mjs"
1212
},
1313
"require": {
14-
"types": "./cjs/index.d.ts",
14+
"types": "./cjs/index.d.cts",
1515
"default": "./cjs/index.js"
1616
}
1717
},
1818
"scripts": {
1919
"build": "run-s build:*",
20-
"build:cjs": "rollup --config rollup.cjs.config.mjs --failAfterWarnings",
21-
"build:esm": "rollup --config rollup.esm.config.mjs --failAfterWarnings",
20+
"build:cjs": "rollup --config rollup.cjs.config.mjs --failAfterWarnings && cp index.d.ts cjs/index.d.cts",
21+
"build:esm": "rollup --config rollup.esm.config.mjs --failAfterWarnings && cp index.d.ts esm/index.d.mts",
2222
"build:umd": "rollup --config rollup.umd.config.mjs --failAfterWarnings",
2323
"clean": "rm -rf cjs dist esm",
2424
"lint": "eslint .",
2525
"lint:fix": "npm run lint -- --fix",
26+
"lint:package": "publint",
2627
"prepare": "husky",
2728
"prepublishOnly": "npm run lint && npm run build && npm test",
2829
"test": "jest --colors --testPathIgnorePatterns=test/index.test.mjs",

0 commit comments

Comments
 (0)