From 2bf97bc91497dff7e3fc76ad9d4702d6263640ee Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Mon, 22 Jul 2024 23:10:12 +0200 Subject: [PATCH] feat(build): :building_construction: Build plain JS for NPM --- .github/workflows/publish.yml | 5 ++--- build.ts | 9 ++++++++- client/package.json | 10 ++++++---- federation/package.json | 15 +++++++++------ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1d0354a..0e9c852 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -53,9 +53,8 @@ jobs: node-version: "22" registry-url: "https://registry.npmjs.org" - # Code is not minified and bundled anymore - #- name: Build - # run: bun run build + - name: Build + run: bun run build - name: Change version in package.json to ${{ github.event.inputs.version }}, defaulting to the truncated commit hash run: 'sed -i ''s/"version": ".*"/"version": "${{ github.event.inputs.version }}"/'' package.json ${{ github.event.inputs.package }}/package.json ${{ github.event.inputs.package }}/jsr.jsonc' diff --git a/build.ts b/build.ts index 2cce120..430d34b 100644 --- a/build.ts +++ b/build.ts @@ -1,11 +1,18 @@ import dts from "bun-plugin-dts"; import ora from "ora"; +const entrypoints = { + federation: ["index.ts", "schemas.ts", "requester.ts"], + client: ["index.ts", "types.ts"], +}; + for (const pkg of ["federation", "client"]) { const subSpinner = ora(`Building ${pkg} module`).start(); await Bun.build({ - entrypoints: [`${pkg}/index.ts`], + entrypoints: entrypoints[pkg as "federation" | "client"].map( + (entrypoint) => `${pkg}/${entrypoint}`, + ), outdir: `${pkg}/dist`, format: "esm", minify: true, diff --git a/client/package.json b/client/package.json index 6112b31..a9dc296 100644 --- a/client/package.json +++ b/client/package.json @@ -39,12 +39,14 @@ }, "exports": { ".": { - "import": "./index.ts", - "default": "./index.ts" + "import": "./dist/index.js", + "default": "./dist/index.js", + "types": "./dist/index.d.ts" }, "./types": { - "import": "./types.ts", - "default": "./types.ts" + "import": "./dist/types.js", + "default": "./dist/types.js", + "types": "./dist/types.d.ts" } }, "funding": { diff --git a/federation/package.json b/federation/package.json index f391064..5faa3e3 100644 --- a/federation/package.json +++ b/federation/package.json @@ -39,16 +39,19 @@ }, "exports": { ".": { - "import": "./index.ts", - "default": "./index.ts" + "import": "./dist/index.js", + "default": "./dist/index.js", + "types": "./dist/index.d.ts" }, "./requester": { - "import": "./requester.ts", - "default": "./requester.ts" + "import": "./dist/requester.js", + "default": "./dist/requester.js", + "types": "./dist/requester.d.ts" }, "./types": { - "import": "./schemas.ts", - "default": "./schemas.ts" + "import": "./dist/schema.js", + "default": "./dist/schema.js", + "types": "./dist/schema.d.ts" } }, "funding": {