Skip to content

Commit

Permalink
Merge pull request #56 from Nesopie/fix/cjs-types
Browse files Browse the repository at this point in the history
emit d.cts files in src/cjs
  • Loading branch information
junderw authored Dec 25, 2024
2 parents daa58b1 + f987e60 commit 4b06c43
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 35 deletions.
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,21 @@
"types": "src/cjs/index.d.ts",
"exports": {
".": {
"import": "./src/esm/index.js",
"require": "./src/cjs/index.cjs",
"types": "./src/cjs/index.d.ts"
"import": {
"types": "./src/esm/index.d.ts",
"default": "./src/esm/index.js"
},
"require": {
"types": "./src/cjs/index.d.cts",
"default": "./src/cjs/index.cjs"
}
}
},
"scripts": {
"build": "npm run clean && tsc -p ./tsconfig.json && tsc -p ./tsconfig.cjs.json",
"clean": "rimraf src",
"gitdiff": "npm run build && git diff --exit-code",
"postbuild": "find src/cjs -type f -name \"*.js\" -exec bash -c 'mv \"$0\" \"${0%.js}.cjs\"' {} \\;",
"postbuild": "find src/cjs -type f \\( -name \"*.js\" -o -name \"*.ts\" \\) -exec bash -c 'ext=\"${0##*.}\"; mv \"$0\" \"${0%.$ext}.c$ext\"' {} \\;",
"standard": "ts-standard --ignore src --ignore test",
"test": "npm run standard && npm run unit",
"unit": "tape test/index.js"
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions src/esm/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import basex from 'base-x';
declare const _default: basex.BaseConverter;
export default _default;
46 changes: 23 additions & 23 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"outDir": "./src",
"rootDir": "./ts_src",
"types": ["node"],
"allowJs": false,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"alwaysStrict": true,
"esModuleInterop": true,
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": ["ts_src/**/*.ts"],
"exclude": ["node_modules/**/*"]
}
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"outDir": "./src",
"rootDir": "./ts_src",
"types": ["node"],
"declaration": true,
"allowJs": false,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"alwaysStrict": true,
"esModuleInterop": true,
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": ["ts_src/**/*.ts"],
"exclude": ["node_modules/**/*"]
}
13 changes: 5 additions & 8 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": false,
"outDir": "src/cjs",
"module": "commonjs"
}
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "src/cjs",
"module": "commonjs"
}
}

0 comments on commit 4b06c43

Please sign in to comment.