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
12 changes: 8 additions & 4 deletions .github/workflows/nodejs-16.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ jobs:
with:
node-version: 16
- run: npm install
- name: Downgrade vitest for Node 16
run: npm install vitest@3 @vitest/coverage-v8@3 --save-dev --ignore-scripts
- run: npm run ci:node16
- run: npm run prepublishOnly
- name: Patch vitest imports
run: |
for f in test/*.test.ts; do [ -e "$f" ] || exit 0; sed --version >/dev/null 2>&1 && sed -i "s@'vite-plus/test'@'vitest'@g" "$f" || sed -i '' "s@'vite-plus/test'@'vitest'@g" "$f"; done
jq 'del(.overrides)' package.json > package.json.tmp && mv package.json.tmp package.json
npm install -D vitest@3 vite@7
rm -rf vite.config.ts
- run: NODE_OPTIONS="--require ./test/patch-for-node16-18.cjs" npx vitest --config ./vitest-for-node16.config.cjs && npm run build && npm pack && npx attw --pack
- run: npm run build
- run: node -v
- run: npm run test-node16
3 changes: 3 additions & 0 deletions .github/workflows/pkg.pr.new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on: [push, pull_request]

jobs:
build:
concurrency:
group: pkg-pr-new-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest

steps:
Expand Down
18 changes: 0 additions & 18 deletions .oxfmtrc.json

This file was deleted.

128 changes: 0 additions & 128 deletions .oxlintrc.json

This file was deleted.

53 changes: 53 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,56 @@ Tests use Vitest with:
- Request/response events published via `diagnostics_channel` (`urllib:request`, `urllib:response`)
- Streaming requests disable retry/redirect functionality
- User-Agent header: `node-urllib/{version} Node.js/{version} ({platform}; {arch})`

<!--VITE PLUS START-->
# Using Vite+, the Unified Toolchain for the Web

This project is using Vite+, a modern toolchain built on top of Vite, Rolldown, Vitest, tsdown, Oxlint, and Oxfmt. Vite+ wraps these tools and package manager commands in a single, global CLI called `vite`. Vite+ is distinct from Vite, but it invokes Vite through `vite dev` and `vite build`.

## Vite+ Workflow

`vite` is a global binary that handles the full development lifecycle. Run `vite help` to print a list of commands and `vite <command> --help` for information about a specific command.

### Vite+ Commands

- dev - Run the development server
- build - Build for production
- lint - Lint code
- test - Run tests
- fmt - Format code
- lib - Build library
- new - Create a new monorepo package (in-project) or a new project (global)
- run - Run tasks from `package.json` scripts

These commands map to their corresponding tools. For example, `vite dev --port 3000` runs Vite's dev server and works the same as Vite. `vite test` runs JavaScript tests through the bundled Vitest. The versions of individual tools can be checked using `vite <command> --version`. For example, `vite lint --version` prints the bundled Oxlint version, and `vite test --version` prints the bundled Vitest version. This is useful when researching documentation, features, and bugs.

### Package Manager Commands

Vite+ automatically detects and wraps the underlying package manager such as pnpm, npm, or Yarn through the `packageManager` field in `package.json` or package manager-specific lockfiles.

- install - Install all dependencies, or add packages if package names are provided
- add - Add packages to dependencies
- remove - Remove packages from dependencies
- dlx - Execute a package binary without installing it as a dependency
- info - View package information from the registry, including latest versions
- link - Link packages for local development
- outdated - Check for outdated packages
- pm - Forward a command to the package manager
- unlink - Unlink packages
- update - Update packages to their latest versions
- why - Show why a package is installed

## Common Pitfalls

- **Using the package manager directly:** Do not use pnpm, npm, or Yarn directly. Vite+ can handle all package manager operations.
- **Always use Vite commands to run tools:** Don't attempt to run `vite vitest` or `vite oxlint`. They do not exist. Use `vite test` and `vite lint` instead.
- **Running scripts:** Vite+ commands take precedence over `package.json` scripts. If there is a `test` script defined in `scripts` that conflicts with the built-in `vite test` command, run it using `vite run test`.
- **Do not install Vitest, Oxlint, Oxfmt, or tsdown directly:** Vite+ wraps these tools. They must not be installed directly. You cannot upgrade these tools by installing their latest versions. Always use Vite+ commands.
- **Import JavaScript modules from `vite-plus`:** Instead of importing from `vite` or `vitest`, all modules should be imported from the project's `vite-plus` dependency. For example, `import { defineConfig } from 'vite-plus';` or `import { expect, test, vi } from 'vite-plus/test';`. You must not install `vitest` to import test utilities.
- **Type-Aware Linting:** There is no need to install `oxlint-tsgolint`, `vite lint --type-aware` works out of the box.

## Review Checklist for Agents

- [ ] Run `vite install` after pulling remote changes and before getting started.
- [ ] Run `vite lint`, `vite fmt`, and `vite test` to validate changes.
<!--VITE PLUS END-->
53 changes: 28 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,30 @@
"tag": "latest"
},
"scripts": {
"lint": "oxlint src test --type-aware --type-check",
"fmt": "oxfmt",
"lint": "vite lint src test --type-aware --type-check",
"fmt": "vite fmt",
"typecheck": "tsc --noEmit && tsgo --noEmit",
"fmtcheck": "oxfmt --check .",
"fmtcheck": "vite fmt --check .",
"prebuild": "npm run clean",
"build": "tsc --version && tshy && tshy-after && npm run build:version",
"postbuild": "rm -rf *.tsbuildinfo",
"build": "tsc --version && tshy && tshy-after && vite run build:version && rm -rf *.tsbuildinfo",
"build:version": "node ./scripts/replace_urllib_version.js",
"build:cjs:test": "cd test/cjs && rm -rf node_modules && npm link ../.. && node index.js",
"build:esm:test": "cd test/esm && rm -rf node_modules && npm link ../.. && node index.js",
"build:mts:test": "cd test/mts && rm -rf node_modules && npm link ../.. && tsc",
"build:test": "npm run build && npm run build:cjs:test && npm run build:esm:test && npm run build:mts:test && npm run test-tsc",
"test-tsc": "npm run test-tsc:cjs:es2021 && npm run test-tsc:cjs && npm run test-tsc:esm",
"test-tsc:cjs": "cd test/fixtures/ts && rm -rf node_modules && npm link ../../.. && npm run build",
"test-tsc:cjs:es2021": "cd test/fixtures/ts-cjs-es2021 && rm -rf node_modules && npm link ../../.. && npm run build",
"test-tsc:esm": "cd test/fixtures/ts-esm && rm -rf node_modules && npm link ../../.. && npm run build",
"test": "npm run lint -- --fix && vitest run --reporter=dot",
"bench": "vitest bench",
"test-keepalive": "cross-env TEST_KEEPALIVE_COUNT=50 vitest run --reporter=dot --test-timeout 180000 keep-alive-header.test.ts",
"build:test": "vite run build && vite run build:cjs:test && vite run build:esm:test && vite run build:mts:test && vite run test-tsc",
"test-tsc": "vite run test-tsc:cjs:es2021 && vite run test-tsc:cjs && vite run test-tsc:esm",
"test-tsc:cjs": "cd test/fixtures/ts && rm -rf node_modules && npm link ../../.. && vite run build",
"test-tsc:cjs:es2021": "cd test/fixtures/ts-cjs-es2021 && rm -rf node_modules && npm link ../../.. && vite run build",
"test-tsc:esm": "cd test/fixtures/ts-esm && rm -rf node_modules && npm link ../../.. && vite run build",
"test": "vite run lint -- --fix && vite test run --reporter=dot",
"bench": "vite test bench",
"test-keepalive": "cross-env TEST_KEEPALIVE_COUNT=50 vite test run --reporter=dot --test-timeout 180000 keep-alive-header.test.ts",
"test-node16": "node examples/httpclient.cjs && node examples/search_github.cjs && node examples/timing.cjs",
"cov": "vitest run --reporter=dot --coverage",
"ci": "npm run cov && npm run prepublishOnly && npm pack && attw --pack",
"ci:node16": "cross-env NODE_OPTIONS=\"--require ./test/patch-for-node16-18.cjs\" vitest run --reporter=dot && npm run prepublishOnly && npm pack && attw --pack",
"cov": "vite test run --reporter=dot --coverage",
"ci": "vite run cov && vite run prepublishOnly && npm pack && attw --pack",
"ci:node16": "cross-env NODE_OPTIONS=\"--require ./test/patch-for-node16-18.cjs\" vite test run --reporter=dot && vite run prepublishOnly && npm pack && attw --pack",
"clean": "rm -rf dist && tsc -b --clean",
"prepublishOnly": "npm run build",
"prepublishOnly": "vite run build",
"prepare": "husky"
},
"dependencies": {
Expand All @@ -83,7 +82,6 @@
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.18.2",
"@codspeed/vitest-plugin": "^5.0.1",
"@eggjs/oxlint-config": "^1.0.0",
"@eggjs/tsconfig": "^2.0.0",
"@types/busboy": "^1.5.4",
Expand All @@ -101,22 +99,19 @@
"husky": "^9.1.7",
"iconv-lite": "^0.6.3",
"lint-staged": "^16.2.7",
"oxfmt": "^0.24.0",
"oxlint": "^1.35.0",
"oxlint-tsgolint": "^0.11.0",
"proxy": "^1.0.2",
"selfsigned": "^3.0.1",
"string.prototype.towellformed": "^1.0.2",
"tar-stream": "^2.2.0",
"tshy": "^3.1.0",
"tshy-after": "^1.4.1",
"typescript": "^5.9.3",
"vitest": "^4.0.17"
"vite-plus": "latest"
},
"lint-staged": {
"*": [
"npm run lint -- --fix",
"oxfmt"
"vite run lint --fix",
"vite run fmt ."
]
},
"tshy": {
Expand All @@ -128,5 +123,13 @@
"engines": {
"node": ">= 18.19.0"
},
"packageManager": "pnpm@10.28.0"
"packageManager": "pnpm@10.28.0",
"pnpm": {
"overrides": {
"vite": "npm:@voidzero-dev/vite-plus-core@latest"
}
},
"overrides": {
"vite": "npm:@voidzero-dev/vite-plus-core@latest"
}
}
Loading
Loading