Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Run tests with Node.js ${{ matrix.node-version }}
run: npm run test-node
test-karma:
test-browser:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
Expand All @@ -58,8 +58,15 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- name: Run karma tests
run: npm run test-karma
- name: Cache Playwright browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('package.json') }}
- name: Install Playwright chromium
run: npx playwright install --with-deps chromium
- name: Run browser tests
run: npm run test-browser
coverage:
runs-on: ubuntu-latest
timeout-minutes: 10
Expand All @@ -75,6 +82,14 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install
# coverage runs the browser project too, so a browser is required
- name: Cache Playwright browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('package.json') }}
- name: Install Playwright chromium
run: npx playwright install --with-deps chromium
- name: Generate coverage report
run: npm run coverage-ci
- name: Upload coverage to Codecov
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@
- Test on Node.js >=22.
- Update `engines.node` to `>=22`.
- Update README requirements section.
- **BREAKING**: Add an `exports` field.
- Only `.`, `./agentCompatibility.js`, and `./package.json` are importable;
other deep imports into the package are no longer reachable.
- Switch testing from `mocha`/`chai`/`karma`/`c8` to `vitest`.
- `karma` is unmaintained; `vitest` covers Node.js tests, browser tests, and
coverage with a single tool and config.
- Browser tests now run in Chromium via `playwright` instead of `karma`.
- `npm test` now runs both the Node.js and browser suites; use
`npm run test-node` or `npm run test-browser` for one of them.
- `npm run test-karma` is replaced by `npm run test-browser`.
- `npm run coverage-report` is removed; use
`npm run coverage -- --coverage.reporter=html`.
- Coverage now includes the browser suite, and reported totals shift
slightly because `vitest` and `c8` count executable lines differently.

### Fixed
- Resolve `agentCompatibility` through an `exports` `browser` condition rather
than only the top-level `browser` field. Bundlers that do not apply the
`browser` field to package-internal relative imports (such as Vite) no longer
pull `undici` into browser builds.

### Removed
- **BREAKING**: Remove CJS support.
Expand Down
109 changes: 0 additions & 109 deletions karma.conf.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion lib/httpClient.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* Copyright (c) 2020-2026 Digital Bazaar, Inc.
*/
import {convertAgent} from './agentCompatibility.js';
import {convertAgent} from '@digitalbazaar/http-client/agentCompatibility.js';
import ky from 'ky';

export {ky};
Expand Down
49 changes: 20 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@
"license": "BSD-3-Clause",
"type": "module",
"main": "./lib/index.js",
"exports": {
".": "./lib/index.js",
"./agentCompatibility.js": {
"react-native": "./lib/agentCompatibility-browser.js",
"browser": "./lib/agentCompatibility-browser.js",
"default": "./lib/agentCompatibility.js"
},
"./package.json": "./package.json"
},
"browser": {
"./lib/agentCompatibility.js": "./lib/agentCompatibility-browser.js",
"./tests/utils.js": "./tests/utils-browser.js"
"./lib/agentCompatibility.js": "./lib/agentCompatibility-browser.js"
},
"react-native": {
"./lib/agentCompatibility.js": "./lib/agentCompatibility-browser.js"
},
"scripts": {
"test": "npm run test-node",
"test-node": "cross-env NODE_ENV=test mocha --preserve-symlinks -t 30000 -A -R ${REPORTER:-spec} --require tests/test-mocha.js tests/*.spec.js",
"test-karma": "karma start karma.conf.cjs",
"test-watch": "cross-env NODE_ENV=test mocha --watch --parallel --preserve-symlinks -t 30000 -A -R ${REPORTER:-spec} --require tests/test-mocha.js tests/*.spec.js",
"coverage": "cross-env NODE_ENV=test c8 npm run test-node",
"coverage-ci": "cross-env NODE_ENV=test c8 --reporter=lcovonly --reporter=text-summary --reporter=text npm run test-node",
"coverage-report": "c8 report",
"test": "vitest run",
"test-node": "vitest run --project node",
"test-browser": "vitest run --project browser",
"test-watch": "vitest",
"coverage": "vitest run --coverage",
"coverage-ci": "vitest run --coverage --coverage.reporter=lcovonly --coverage.reporter=text-summary --coverage.reporter=text",
"lint": "eslint"
},
"files": [
Expand All @@ -31,22 +38,13 @@
},
"devDependencies": {
"@digitalbazaar/eslint-config": "^9.0.0",
"c8": "^12.0.0",
"chai": "^4.5.0",
"@vitest/browser-playwright": "^4.1.10",
"@vitest/coverage-v8": "^4.1.10",
"cors": "^2.8.6",
"cross-env": "^10.1.0",
"detect-node": "^2.1.0",
"eslint": "^10.8.0",
"express": "^5.2.1",
"karma": "^6.4.4",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.2.0",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.4.0",
"karma-webpack": "^5.0.1",
"mocha": "^11.7.6",
"webpack": "^5.109.0"
"playwright": "^1.62.0",
"vitest": "^4.1.10"
},
"repository": {
"type": "git",
Expand All @@ -68,12 +66,5 @@
"homepage": "https://github.com/digitalbazaar/http-client",
"engines": {
"node": ">=22"
},
"c8": {
"reporter": [
"lcov",
"text-summary",
"text"
]
}
}
Loading
Loading