Skip to content

Commit

Permalink
build: build with bun
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
  • Loading branch information
explodingcamera committed Oct 4, 2023
1 parent 7b8a45b commit 21a1566
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
with:
bun-version: latest

- name: Build Deps
run: bun run build
- name: Install Dependencies & Build
run: bun install && bun run build

- name: Run Tests
run: bun run test
2 changes: 1 addition & 1 deletion __tests__/basic.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { expect, it } from "vitest";
import { expect, it } from "bun:test";

it("works", () => expect(true).toBeTruthy());
Binary file modified bun.lockb
Binary file not shown.
17 changes: 4 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,20 @@
},
"scripts": {
"watch": "npm run build:esbuild -- --watch",
"build": "npm run build:esbuild && npm run types",
"build:esbuild": "esbuild src/*.ts --minify --bundle --outdir=lib --platform=neutral --external:crypto --external:spark-md5 --target=node16 --format=esm",
"build": "npm run build:bun && npm run types",
"build:bun": "bun build ./src/index.ts --minify --outdir=lib --target=node --external:crypto --format=esm",
"dev": "bun example/test.ts",
"release": "release-it",
"test": "vitest",
"types": "tsc -p tsconfig.build.json",
"preversion": "npm run build"
},
"devDependencies": {
"@biomejs/biome": "^1.2.2",
"@biomejs/cli-linux-x64": "^1.2.2",
"@types/node": "^20.6.5",
"@types/spark-md5": "^3.0.2",
"esbuild": "^0.19.3",
"np": "^8.0.4",
"bun-types": "^1.0.4",
"release-it": "^16.2.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vitest": "^0.34.5"
"spark-md5": "^3.0.2"
},
"release-it": {
"git": {
Expand All @@ -51,9 +45,6 @@
"release": true
}
},
"dependencies": {
"spark-md5": "^3.0.2"
},
"engines": {
"node": ">=18"
},
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class SubsonicAPI {
async init() {
this.#crypto = globalThis.crypto
? globalThis.crypto
: await import("crypto").then((crypto) => crypto.webcrypto as Crypto);
: await import("node:crypto").then((crypto) => (crypto as any).webcrypto as Crypto);

if (globalThis.fetch) {
this.#fetch = globalThis.fetch.bind(globalThis);
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export function arrayBufferToBase64(bytes: Uint8Array) {
if (typeof window === "undefined") {
if (typeof globalThis.Buffer !== "undefined") {
return Buffer.from(bytes).toString("base64url");
}

Expand Down
23 changes: 18 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,26 @@
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["DOM", "ESNext"],
"lib": [
"DOM",
"ESNext"
],
"module": "ESNext",
"outDir": "./lib",
"allowJs": true,
"checkJs": false,
"declaration": true
"declaration": true,
"types": [
"bun-types"
]
},
"include": ["**/src/**/*", "**/__tests__/**/*", "example/**/*"],
"exclude": ["node_modules", "lib"]
}
"include": [
"**/src/**/*",
"**/__tests__/**/*",
"example/**/*"
],
"exclude": [
"node_modules",
"lib"
]
}

0 comments on commit 21a1566

Please sign in to comment.