diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d53c0d..89a1e69 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,9 @@ jobs: with: node-version: ${{ matrix.node }} cache: npm + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + with: + bun-version: 1.3.11 - name: Install dependencies run: npm ci @@ -39,5 +42,8 @@ jobs: - name: Build run: npm run build + - name: Build self-contained bundle + run: npm run bundle + - name: Test run: npm test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7d28c62..ef0a8ed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,13 +21,15 @@ jobs: with: node-version: 24 cache: 'npm' + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + with: + bun-version: 1.3.11 - name: Install Dependencies run: npm ci - - name: Build project - run: npm run build - + # No explicit build steps: `npm publish` runs prepublishOnly, + # which builds the project and the self-contained bundle. - name: Determine npm tag id: npm-tag env: diff --git a/package.json b/package.json index fc5210f..667be7c 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,15 @@ "bin": { "workos-migrate": "dist/index.js" }, + "exports": { + ".": "./dist/index.js", + "./bundle": { + "types": "./dist/cli/index.d.ts", + "default": "./dist/bundle.js" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" + }, "files": [ "dist/**/*", "README.md", @@ -15,6 +24,7 @@ ], "scripts": { "build": "tsc", + "bundle": "bun build src/cli/index.ts --outfile dist/bundle.js --target=bun --format=esm --banner='// Bun-only bundle: built with --target=bun for the WorkOS CLI; not supported on Node.js.' && bun build src/workers/worker.ts --outfile dist/worker.js --target=bun --format=esm --banner='// Bun-only bundle: built with --target=bun for the WorkOS CLI; not supported on Node.js.'", "start": "node dist/index.js", "dev": "tsx src/index.ts", "lint": "eslint \"src/**/*.ts\"", @@ -23,7 +33,7 @@ "format:check": "prettier --check \"src/**/*.ts\" \"*.md\" \"*.json\"", "typecheck": "tsc --noEmit", "test": "node --experimental-vm-modules node_modules/.bin/jest", - "prepublishOnly": "npm run build" + "prepublishOnly": "npm run build && npm run bundle" }, "keywords": [ "workos",