commit 82a70fe140d78f5feedd0d3029924bb615837af8
parent 18f29e814d29a9ef8d815346813c6215b390944f
Author: triesap <tyson@radroots.org>
Date: Sat, 9 Aug 2025 18:12:52 +0000
workspace: update `ts` bindings build process with targets for esm and cjs outputs
Diffstat:
7 files changed, 44 insertions(+), 32 deletions(-)
diff --git a/bindings/ts/package.json b/bindings/ts/package.json
@@ -3,17 +3,15 @@
"version": "1.0.0",
"private": true,
"license": "AGPLv3",
- "main": "dist/cjs/index.js",
- "module": "dist/esm/index.js",
- "types": "dist/cjs/index.d.ts",
+ "type": "module",
+ "main": "./dist/cjs/index.js",
+ "module": "./dist/esm/index.js",
+ "types": "./dist/types/index.d.ts",
"exports": {
- "require": {
- "types": "./dist/cjs/index.d.ts",
- "default": "./dist/cjs/index.js"
- },
- "import": {
- "types": "./dist/cjs/index.d.ts",
- "default": "./dist/esm/index.js"
+ ".": {
+ "types": "./dist/types/index.d.ts",
+ "import": "./dist/esm/index.js",
+ "require": "./dist/cjs/index.js"
}
},
"files": [
@@ -21,19 +19,20 @@
],
"sideEffects": false,
"scripts": {
- "build:esm": "tsc -p tsconfig.json",
+ "build:esm": "tsc -p tsconfig.esm.json",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build": "npm run clean && npm run build:esm && npm run build:cjs",
"prebuild": "npm run clean",
"clean": "rimraf dist",
"dev": "npm run watch",
"watch": "tsc -w",
- "gen:index": "echo \"// Generated @radroots/radroots-common-bindings\" > src/index.ts && for f in src/*.ts; do fn=$(basename \"$f\" .ts); [ \"$fn\" != \"index\" ] && echo \"export * from './$fn';\" >> src/index.ts; done",
+ "gen:index": "echo \"// Generated @radroots/radroots-common-bindings\" > src/index.ts && for f in src/*.ts; do fn=$(basename \"$f\" .ts); [ \"$fn\" != \"index\" ] && echo \"export * from './$fn.js';\" >> src/index.ts; done",
"gen:schema": "ts-to-zod src/types.ts src/schema.ts",
"gen:types": "typeshare --lang typescript --output-file=src/types.ts ../../src",
"gen": "npm run gen:types && npm run gen:schema && npm run gen:index"
},
"devDependencies": {
+ "@radroots/tsconfig": "*",
"rimraf": "^6.0.1",
"ts-to-zod": "^3.15.0"
},
diff --git a/bindings/ts/src/index.ts b/bindings/ts/src/index.ts
@@ -1,3 +1,3 @@
// Generated @radroots/radroots-common-bindings
-export * from './schema';
-export * from './types';
+export * from './schema.js';
+export * from './types.js';
diff --git a/bindings/ts/tsconfig.cjs.json b/bindings/ts/tsconfig.cjs.json
@@ -0,0 +1,15 @@
+{
+ "extends": "@radroots/tsconfig/tsconfig.esm.json",
+ "compilerOptions": {
+ "module": "CommonJS",
+ "moduleResolution": "Node",
+ "rootDir": "./src",
+ "outDir": "dist/cjs",
+ "declaration": false,
+ "declarationMap": false,
+ "emitDeclarationOnly": false,
+ "tsBuildInfoFile": "node_modules/.cache/tsc.utils-nostr.cjs.tsbuildinfo"
+ },
+ "include": ["src"],
+ "exclude": ["node_modules", "dist"]
+}
diff --git a/bindings/ts/tsconfig.esm.json b/bindings/ts/tsconfig.esm.json
@@ -0,0 +1,13 @@
+{
+ "extends": "@radroots/tsconfig/tsconfig.esm.json",
+ "compilerOptions": {
+ "moduleResolution": "nodenext",
+ "rootDir": "./src",
+ "outDir": "dist/esm",
+ "declaration": true,
+ "declarationMap": true,
+ "declarationDir": "dist/types"
+ },
+ "include": ["src"],
+ "exclude": ["node_modules", "dist"]
+}
diff --git a/bindings/ts/tsconfig.json b/bindings/ts/tsconfig.json
@@ -0,0 +1,3 @@
+{
+ "extends": "./tsconfig.esm.json"
+}
diff --git a/bindings/tsconfig.cjs.json b/bindings/tsconfig.cjs.json
@@ -1,9 +0,0 @@
-{
- "extends": "@radroots/internal-tsconfig/tsconfig.cjs.json",
- "compilerOptions": {
- "rootDir": "./src",
- "outDir": "dist/cjs"
- },
- "include": ["src"],
- "exclude": ["node_modules", "dist"]
-}
diff --git a/bindings/tsconfig.json b/bindings/tsconfig.json
@@ -1,9 +0,0 @@
-{
- "extends": "@radroots/internal-tsconfig/tsconfig.esm.json",
- "compilerOptions": {
- "rootDir": "./src",
- "outDir": "dist/esm"
- },
- "include": ["src"],
- "exclude": ["node_modules", "dist"]
-}