Skip to content

Commit a282b6e

Browse files
committed
✨ Fix types in published tasks package
1 parent 27b995d commit a282b6e

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

packages/tasks/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
},
1010
"main": "./dist/index.cjs",
1111
"module": "./dist/index.js",
12-
"types": "./dist/src/index.d.ts",
12+
"types": "./dist/index.d.ts",
1313
"exports": {
1414
".": {
15-
"types": "./dist/src/index.d.ts",
1615
"require": "./dist/index.cjs",
1716
"import": "./dist/index.js"
1817
}
@@ -24,13 +23,14 @@
2423
"format": "prettier --write .",
2524
"format:check": "prettier --check .",
2625
"prepublishOnly": "pnpm run inference-codegen && git diff --name-only --exit-code src && pnpm run build",
27-
"build": "tsup src/index.ts --format cjs,esm --clean && tsc --emitDeclarationOnly --declaration",
26+
"build": "tsup src/index.ts --format cjs,esm --clean && tsc --emitDeclarationOnly --declaration && pnpm run generate-cts",
2827
"watch:export": "tsup src/index.ts --format cjs,esm --watch",
2928
"watch:types": "tsc --emitDeclarationOnly --declaration --watch",
3029
"watch": "npm-run-all --parallel watch:export watch:types",
3130
"prepare": "pnpm run build",
3231
"check": "tsc",
3332
"test": "vitest run",
33+
"generate-cts": "tsx scripts/generate-cts.ts",
3434
"inference-codegen": "tsx scripts/inference-codegen.ts && prettier --write src/tasks/*/inference.ts",
3535
"inference-tgi-import": "tsx scripts/inference-tgi-import.ts && prettier --write src/tasks/text-generation/spec/*.json && prettier --write src/tasks/chat-completion/spec/*.json",
3636
"inference-tei-import": "tsx scripts/inference-tei-import.ts && prettier --write src/tasks/feature-extraction/spec/*.json"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
2+
import { join } from "node:path";
3+
4+
function recursiveCopy(path: string) {
5+
for (const item of readdirSync(path)) {
6+
if (item.endsWith(".d.ts")) {
7+
const content = readFileSync(join(path, item), "utf-8");
8+
writeFileSync(join(path, item.replace(".d.ts", ".d.cts")), content.replaceAll(".d.ts.map", ".d.cts.map"));
9+
} else if (item.endsWith(".d.ts.map")) {
10+
const content = readFileSync(join(path, item), "utf-8");
11+
writeFileSync(join(path, item.replace(".d.ts.map", ".d.cts.map")), content.replaceAll(".d.ts", ".d.cts"));
12+
} else if (statSync(join(path, item)).isDirectory()) {
13+
recursiveCopy(join(path, item));
14+
}
15+
}
16+
}
17+
18+
recursiveCopy("dist");

packages/tasks/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
"declaration": true,
1616
"declarationMap": true
1717
},
18-
"include": ["src", "scripts"],
18+
"include": ["src"],
1919
"exclude": ["dist"]
2020
}

packages/tasks/tsconfig.local.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["src", "scripts"]
4+
}

0 commit comments

Comments
 (0)