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
+2
View File
@@ -1,6 +1,8 @@
name: Test get-installation-token name: Test get-installation-token
on: on:
push:
branches: [main]
workflow_dispatch: workflow_dispatch:
permissions: permissions:
+19 -1
View File
@@ -1,10 +1,13 @@
// @ts-check // @ts-check
import { build } from "esbuild"; 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")); 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 // Plugin to strip shebangs from output files
/** /**
* @type {import("esbuild").Plugin} * @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) // prepend shebang after strip (esbuild banner can't guarantee line 1 placement)
const cliPath = "./dist/cli.mjs"; const cliPath = "./dist/cli.mjs";
const cliContent = readFileSync(cliPath, "utf8"); const cliContent = readFileSync(cliPath, "utf8");
+10 -3
View File
@@ -13,7 +13,7 @@
"scripts": { "scripts": {
"test": "vitest", "test": "vitest",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"build": "node esbuild.config.js", "build": "node esbuild.config.js && tsc -p tsconfig.exports.json",
"check:entrypoints": "node scripts/check-entrypoint-imports.ts", "check:entrypoints": "node scripts/check-entrypoint-imports.ts",
"play": "node play.ts", "play": "node play.ts",
"runtest": "node test/run.ts", "runtest": "node test/run.ts",
@@ -74,14 +74,21 @@
"url": "https://github.com/pullfrog/pullfrog/issues" "url": "https://github.com/pullfrog/pullfrog/issues"
}, },
"homepage": "https://github.com/pullfrog/pullfrog#readme", "homepage": "https://github.com/pullfrog/pullfrog#readme",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": { "exports": {
".": { ".": {
"@pullfrog/source": "./index.ts", "@pullfrog/source": "./index.ts",
"default": "./index.ts" "types": "./dist/index.d.ts",
"import": "./dist/index.js",
"default": "./dist/index.js"
}, },
"./internal": { "./internal": {
"@pullfrog/source": "./internal/index.ts", "@pullfrog/source": "./internal/index.ts",
"default": "./internal/index.ts" "types": "./dist/internal/index.d.ts",
"import": "./dist/internal.js",
"default": "./dist/internal.js"
}, },
"./package.json": "./package.json" "./package.json": "./package.json"
}, },
+10
View File
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
"emitDeclarationOnly": true,
"declarationMap": false,
"outDir": "./dist"
},
"include": ["index.ts", "internal/index.ts"]
}