feat(build): 🏗️ Build plain JS for NPM

This commit is contained in:
Jesse Wierzbinski 2024-07-22 23:10:12 +02:00
parent 8a4b246f01
commit 2bf97bc914
No known key found for this signature in database
4 changed files with 25 additions and 14 deletions

View file

@ -53,9 +53,8 @@ jobs:
node-version: "22" node-version: "22"
registry-url: "https://registry.npmjs.org" registry-url: "https://registry.npmjs.org"
# Code is not minified and bundled anymore - name: Build
#- name: Build run: bun run build
# run: bun run build
- name: Change version in package.json to ${{ github.event.inputs.version }}, defaulting to the truncated commit hash - 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' run: 'sed -i ''s/"version": ".*"/"version": "${{ github.event.inputs.version }}"/'' package.json ${{ github.event.inputs.package }}/package.json ${{ github.event.inputs.package }}/jsr.jsonc'

View file

@ -1,11 +1,18 @@
import dts from "bun-plugin-dts"; import dts from "bun-plugin-dts";
import ora from "ora"; import ora from "ora";
const entrypoints = {
federation: ["index.ts", "schemas.ts", "requester.ts"],
client: ["index.ts", "types.ts"],
};
for (const pkg of ["federation", "client"]) { for (const pkg of ["federation", "client"]) {
const subSpinner = ora(`Building ${pkg} module`).start(); const subSpinner = ora(`Building ${pkg} module`).start();
await Bun.build({ await Bun.build({
entrypoints: [`${pkg}/index.ts`], entrypoints: entrypoints[pkg as "federation" | "client"].map(
(entrypoint) => `${pkg}/${entrypoint}`,
),
outdir: `${pkg}/dist`, outdir: `${pkg}/dist`,
format: "esm", format: "esm",
minify: true, minify: true,

View file

@ -39,12 +39,14 @@
}, },
"exports": { "exports": {
".": { ".": {
"import": "./index.ts", "import": "./dist/index.js",
"default": "./index.ts" "default": "./dist/index.js",
"types": "./dist/index.d.ts"
}, },
"./types": { "./types": {
"import": "./types.ts", "import": "./dist/types.js",
"default": "./types.ts" "default": "./dist/types.js",
"types": "./dist/types.d.ts"
} }
}, },
"funding": { "funding": {

View file

@ -39,16 +39,19 @@
}, },
"exports": { "exports": {
".": { ".": {
"import": "./index.ts", "import": "./dist/index.js",
"default": "./index.ts" "default": "./dist/index.js",
"types": "./dist/index.d.ts"
}, },
"./requester": { "./requester": {
"import": "./requester.ts", "import": "./dist/requester.js",
"default": "./requester.ts" "default": "./dist/requester.js",
"types": "./dist/requester.d.ts"
}, },
"./types": { "./types": {
"import": "./schemas.ts", "import": "./dist/schema.js",
"default": "./schemas.ts" "default": "./dist/schema.js",
"types": "./dist/schema.d.ts"
} }
}, },
"funding": { "funding": {