From 4c485747a039f1eca90a25cd23d28b102f4c3ba7 Mon Sep 17 00:00:00 2001 From: Naveen Kumar Date: Thu, 20 Aug 2026 01:36:19 +0800 Subject: [PATCH] chore: drop bunfig keys Bun ignores and fix broken npm scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bun does not warn about unknown bunfig keys, so several plausible-looking options had read as working configuration for a long time. Each removal below was verified, not assumed: [build] Set minify/sourcemap, then ran `bun build` with no CLI flags: no .js.map was emitted and the output kept its original identifiers. Not a bunfig section at all. [test] timeout Set timeout=100 and ran a 300ms test: it passed. [test] bail Set bail=true with a failing first file: the second file still ran. [install] frozen The real key is `frozenLockfile`. [install] auto Real key, but it takes "auto"|"force"|"disable"| "fallback", not a boolean — and it governs runtime auto-install of missing packages, not peer deps as the comment claimed. [install] parallel No such option. [install.scopes] Both scopes pointed at the default registry. `registry` is kept even though it matches the default: stating it explicitly stops a user-level .npmrc or bunfig from silently redirecting installs for this project. The file header now records what was removed and why, so the same keys don't get re-added. Three npm scripts were broken and errored on every run: `bun --shell ''` misuses --shell, which takes "bun" or "system", not a command. Scripts already run under Bun's shell via [run] shell, so the wrapper was only ever wrong. `bun run clean` now actually deletes its targets. dev:extension needed more than the syntax fix. Without `--mode development`, Vite defaults to production, setupDevEnvironment() is never registered (it is gated on !isProduction) and output lands in dist/ — making the script identical to `bun run build` despite its name. With the flag it produces dev/, which is what .gitignore's `dev/*` expects. No regression risk: the script never ran at all before. Also dropped ./tests/example.test.ts from the four test scripts; that file does not exist and Bun was silently ignoring it. Verified: build succeeds, 495 unit pass, svelte-check 4053 files 0 errors, biome clean (2 pre-existing warnings), 54 e2e pass in real Chrome, and `bun run clean` / `dev:extension` confirmed working by direct execution. --- bunfig.toml | 69 ++++++++++++++++++---------------------------------- package.json | 14 +++++------ 2 files changed, 31 insertions(+), 52 deletions(-) diff --git a/bunfig.toml b/bunfig.toml index 94c38b8..3ec7658 100644 --- a/bunfig.toml +++ b/bunfig.toml @@ -1,33 +1,34 @@ # Bun Configuration File # https://bun.sh/docs/runtime/bunfig +# +# Only keys Bun actually parses live here. Several plausible-looking options +# were removed after testing showed Bun ignores them (Bun does not warn about +# unknown keys, so they had read as configuration for a long time): +# [build] — not a bunfig section at all; `bun build` ignored +# its minify/sourcemap/target/splitting values. +# [test] timeout, bail — not parsed; a 300ms test passed under timeout=100 +# and bail=true did not stop the run after a failure. +# [install] frozen — the real key is `frozenLockfile`. +# [install] auto — real, but takes "auto"|"force"|"disable"|"fallback", +# not a boolean, and governs runtime auto-install +# rather than peer dependencies. +# [install] parallel — no such option. +# [install.scopes] — both scopes pointed at the default registry. [install] -# Use exact versions for reproducible builds +# Pin exact versions for reproducible builds exact = true -# Parallel downloads for faster dependency installation -parallel = true - -# Default registry +# State the registry explicitly so a user-level .npmrc or bunfig cannot +# silently redirect installs for this project. registry = "https://registry.npmjs.org/" -# Auto-install peer dependencies -auto = true - -# Frozen lockfile in CI -frozen = false - -[install.scopes] -# Optimize specific scopes -"@types" = "https://registry.npmjs.org/" -"@sveltejs" = "https://registry.npmjs.org/" - [test] -# Enable coverage by default +# Coverage on by default coverage = true - -# Exclude files from coverage that are difficult to test (Chrome API dependent) coverageSkipTestFiles = true + +# Chrome-API-dependent modules that unit tests cannot meaningfully cover coveragePathIgnorePatterns = [ "src/services/chrome/**", "src/services/StorageService.ts", @@ -37,36 +38,14 @@ coveragePathIgnorePatterns = [ "tests/**" ] -# Preload test setup files - ensure chrome mocking is available +# Installs the global `chrome` mock before any test imports run preload = ["./tests/setup.ts"] -# Root directory for test discovery root = "." -# Set test timeout (in milliseconds) -timeout = 5000 - -# Bail on first test failure (useful for CI) -bail = false - -# Note: Unit tests are run using explicit patterns in package.json scripts -# E2E tests should be run separately with Playwright: npm run test:e2e -# This avoids conflicts between Bun test and Playwright test APIs +# Unit tests are selected by explicit globs in package.json; Playwright E2E runs +# separately via `bun run test:e2e` to keep the two test APIs from colliding. [run] -# Set default shell for cross-platform compatibility -# Options: "bun" or "system" +# Use Bun's own shell so scripts behave the same across platforms shell = "bun" - -[build] -# Default build target -target = "browser" - -# Enable minification by default -minify = true - -# Enable source maps in development -sourcemap = "external" - -# Code splitting -splitting = true \ No newline at end of file diff --git a/package.json b/package.json index 8f82f7c..933cd50 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "module", "scripts": { "dev": "vite", - "dev:extension": "bun --shell 'export NODE_ENV=development && vite build --watch'", + "dev:extension": "NODE_ENV=development vite build --mode development --watch", "build": "vite build", "build:bun": "bun build src/background/background.ts --outdir=dist/assets --target=browser --minify --splitting", "build:analyze": "bun build src/background/background.ts --outdir=dist/assets --target=browser --minify --splitting --analyze", @@ -17,18 +17,18 @@ "check:biome": "biome check ./src", "check:biome:fix": "biome check --write ./src", "lint-staged": "lint-staged", - "test": "bun test ./src/**/__tests__/*.test.ts ./tests/setup.ts ./tests/example.test.ts", - "test:unit": "bun test ./src/**/__tests__/*.test.ts ./tests/setup.ts ./tests/example.test.ts", - "test:watch": "bun test --watch ./src/**/__tests__/*.test.ts ./tests/setup.ts ./tests/example.test.ts", - "test:coverage": "bun test --coverage ./src/**/__tests__/*.test.ts ./tests/setup.ts ./tests/example.test.ts", + "test": "bun test ./src/**/__tests__/*.test.ts ./tests/setup.ts", + "test:unit": "bun test ./src/**/__tests__/*.test.ts ./tests/setup.ts", + "test:watch": "bun test --watch ./src/**/__tests__/*.test.ts ./tests/setup.ts", + "test:coverage": "bun test --coverage ./src/**/__tests__/*.test.ts ./tests/setup.ts", "test:e2e": "playwright test", "test:e2e:ui": "playwright test --ui", "test:e2e:smoke": "playwright test tests/e2e/extension-smoke.spec.ts", "test:e2e:ci": "playwright test extension-smoke comprehensive-flows proxy-management traffic-modes traffic-routing accessibility import-large-backup", "check:ci": "biome ci ./src", "package": "vite build && cd dist && zip -r ../pacify-extension.zip . && cd ..", - "clean": "bun --shell 'rm -rf dist dev node_modules/.vite'", - "clean:all": "bun --shell 'rm -rf dist dev node_modules/.vite node_modules'", + "clean": "rm -rf dist dev node_modules/.vite", + "clean:all": "rm -rf dist dev node_modules/.vite node_modules", "deps:update": "bun update --latest", "deps:check": "bun outdated", "prepare": "husky"