Skip to content

Commit

Permalink
fix: fixed commonjs typings export mapping (#526)
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 committed Jan 19, 2024
1 parent 7012a16 commit b7787cb
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 @@ -6,29 +6,30 @@
"license": "MIT",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.mjs",
"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"
}
},
"sideEffects": false,
"homepage": "https://github.com/sapphiredev/type",
"scripts": {
"install": "node-pre-gyp install --fallback-to-build",
"build": "yarn gyp:configure && yarn gyp:build && yarn gyp:package && yarn ts:build",
"build": "yarn gyp:configure && yarn gyp:build && yarn gyp:package && yarn ts:build && yarn ts:build:rename-cjs-index",
"clean": "node scripts/clean.mjs",
"docs": "typedoc-json-parser",
"test": "yarn gyp:configure && yarn gyp:build && vitest run",
"lint": "eslint src tests --ext ts --fix",
"prettier": "prettier --ignore-path=.prettierignore",
"prepack": "yarn build",
"ts:build": "tsup",
"ts:build:rename-cjs-index": "node scripts/rename-cjs-index.mjs",
"gyp:build-from-source": "node-pre-gyp install --fallback-to-build --build-from-source",
"gyp:configure": "node-pre-gyp configure",
"gyp:build": "node-pre-gyp build",
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 b7787cb

Please sign in to comment.