Skip to content

Commit f987e60

Browse files
committed
feat: emit d.cts files in src/cjs
1 parent daa58b1 commit f987e60

File tree

5 files changed

+40
-35
lines changed

5 files changed

+40
-35
lines changed

package.json

+9-4
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,21 @@
3434
"types": "src/cjs/index.d.ts",
3535
"exports": {
3636
".": {
37-
"import": "./src/esm/index.js",
38-
"require": "./src/cjs/index.cjs",
39-
"types": "./src/cjs/index.d.ts"
37+
"import": {
38+
"types": "./src/esm/index.d.ts",
39+
"default": "./src/esm/index.js"
40+
},
41+
"require": {
42+
"types": "./src/cjs/index.d.cts",
43+
"default": "./src/cjs/index.cjs"
44+
}
4045
}
4146
},
4247
"scripts": {
4348
"build": "npm run clean && tsc -p ./tsconfig.json && tsc -p ./tsconfig.cjs.json",
4449
"clean": "rimraf src",
4550
"gitdiff": "npm run build && git diff --exit-code",
46-
"postbuild": "find src/cjs -type f -name \"*.js\" -exec bash -c 'mv \"$0\" \"${0%.js}.cjs\"' {} \\;",
51+
"postbuild": "find src/cjs -type f \\( -name \"*.js\" -o -name \"*.ts\" \\) -exec bash -c 'ext=\"${0##*.}\"; mv \"$0\" \"${0%.$ext}.c$ext\"' {} \\;",
4752
"standard": "ts-standard --ignore src --ignore test",
4853
"test": "npm run standard && npm run unit",
4954
"unit": "tape test/index.js"
File renamed without changes.

src/esm/index.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import basex from 'base-x';
2+
declare const _default: basex.BaseConverter;
3+
export default _default;

tsconfig.base.json

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
2-
"compilerOptions": {
3-
"target": "ES5",
4-
"module": "commonjs",
5-
"outDir": "./src",
6-
"rootDir": "./ts_src",
7-
"types": ["node"],
8-
"allowJs": false,
9-
"strict": true,
10-
"noImplicitAny": true,
11-
"strictNullChecks": true,
12-
"strictFunctionTypes": true,
13-
"strictBindCallApply": true,
14-
"strictPropertyInitialization": true,
15-
"noImplicitThis": true,
16-
"alwaysStrict": true,
17-
"esModuleInterop": true,
18-
"noUnusedLocals": true,
19-
"noUnusedParameters": true
20-
},
21-
"include": ["ts_src/**/*.ts"],
22-
"exclude": ["node_modules/**/*"]
23-
}
24-
2+
"compilerOptions": {
3+
"target": "ES5",
4+
"module": "commonjs",
5+
"outDir": "./src",
6+
"rootDir": "./ts_src",
7+
"types": ["node"],
8+
"declaration": true,
9+
"allowJs": false,
10+
"strict": true,
11+
"noImplicitAny": true,
12+
"strictNullChecks": true,
13+
"strictFunctionTypes": true,
14+
"strictBindCallApply": true,
15+
"strictPropertyInitialization": true,
16+
"noImplicitThis": true,
17+
"alwaysStrict": true,
18+
"esModuleInterop": true,
19+
"noUnusedLocals": true,
20+
"noUnusedParameters": true
21+
},
22+
"include": ["ts_src/**/*.ts"],
23+
"exclude": ["node_modules/**/*"]
24+
}

tsconfig.cjs.json

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
{
2-
"extends": "./tsconfig.base.json",
3-
"compilerOptions": {
4-
"declaration": true,
5-
"emitDeclarationOnly": false,
6-
"outDir": "src/cjs",
7-
"module": "commonjs"
8-
}
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"outDir": "src/cjs",
5+
"module": "commonjs"
96
}
10-
7+
}

0 commit comments

Comments
 (0)