fix action package exports and build ESM library entrypoints.

emit real ESM runtime + declaration outputs for programmatic imports, align package exports/types with built files, and add a no-cjs policy note.

Made-with: Cursor
This commit is contained in:
Colin McDonnell
2026-04-12 19:49:21 +00:00
committed by pullfrog[bot]
parent 6541bdc4f4
commit 3c2f3722ff
4 changed files with 41 additions and 4 deletions
+19 -1
View File
@@ -1,10 +1,13 @@
// @ts-check
import { build } from "esbuild";
import { readFileSync, writeFileSync } from "fs";
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
const pkg = JSON.parse(readFileSync("package.json", "utf-8"));
rmSync("./dist", { recursive: true, force: true });
mkdirSync("./dist", { recursive: true });
// Plugin to strip shebangs from output files
/**
* @type {import("esbuild").Plugin}
@@ -73,6 +76,21 @@ await build({
},
});
// Build ESM library entrypoints for programmatic imports
await build({
...sharedConfig,
entryPoints: ["./index.ts"],
outfile: "./dist/index.js",
target: "node20",
});
await build({
...sharedConfig,
entryPoints: ["./internal/index.ts"],
outfile: "./dist/internal.js",
target: "node20",
});
// prepend shebang after strip (esbuild banner can't guarantee line 1 placement)
const cliPath = "./dist/cli.mjs";
const cliContent = readFileSync(cliPath, "utf8");