Skip to content

Commit

Permalink
fix: fixed commonjs typings export mapping (#341)
Browse files Browse the repository at this point in the history
* fix: fixed commonjs typings export mapping

* build: use js script
  • Loading branch information
favna authored Jan 19, 2024
1 parent 3c27a4c commit a5518aa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"module": "dist/esm/index.mjs",
"browser": "dist/iife/index.global.js",
"unpkg": "dist/iife/index.global.js",
"types": "dist/cjs/index.d.ts",
"types": "dist/cjs/index.d.cts",
"exports": {
"import": {
"types": "./dist/esm/index.d.mts",
"default": "./dist/esm/index.mjs"
},
"require": {
"types": "./dist/cjs/index.d.ts",
"types": "./dist/cjs/index.d.cts",
"default": "./dist/cjs/index.cjs"
},
"browser": "./dist/iife/index.global.js"
Expand All @@ -27,7 +27,8 @@
"format": "prettier --write \"{src,tests}/**/*.ts\"",
"docs": "typedoc-json-parser",
"test": "vitest run",
"build": "tsup",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "node scripts/rename-cjs-index.mjs",
"clean": "rimraf dist",
"typecheck": "tsc -p tsconfig.eslint.json",
"bump": "cliff-jumper",
Expand Down
13 changes: 13 additions & 0 deletions scripts/rename-cjs-index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { green } from 'colorette';
import { rename } from 'node:fs/promises';
import { join } from 'node:path';

const inputPath = 'dist/cjs/index.d.ts';
const outputPath = 'dist/cjs/index.d.cts';

const fullInputPathUrl = join(process.cwd(), inputPath);
const fullOutputPathUrl = join(process.cwd(), outputPath);

await rename(fullInputPathUrl, fullOutputPathUrl);

console.log(green(`✅ Renamed index.d.ts to index.d.cts`));

0 comments on commit a5518aa

Please sign in to comment.