Skip to content

Commit 7a2fc90

Browse files
authored
chore: use vite+ (#643)
https://github.com/voidzero-dev/setup-vite-plus-action <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Upgraded development tooling to Vite+ (build, test and formatting via unified commands). * **Chores** * Consolidated and modernized CI workflows; updated Node.js test matrix and removed legacy Node 16 workflow. * Modernized package scripts to use Vite+ runners and adjusted project configuration. * **Tests** * Tests now use the Vite+ test harness (test imports updated). * **Documentation** * Added Vite+ usage docs and a new README badge. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent d748999 commit 7a2fc90

54 files changed

Lines changed: 875 additions & 1052 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/nodejs-16.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Node.js old versions CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
concurrency:
13+
group: nodejs-old-versions-test-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}-(${{ matrix.node }})
14+
cancel-in-progress: true
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
node: ['16', '18']
19+
20+
steps:
21+
- uses: actions/checkout@v6
22+
- name: Use Node.js
23+
uses: actions/setup-node@v6
24+
with:
25+
node-version: ${{ matrix.node }}
26+
- run: npm install
27+
- name: Patch vitest imports
28+
run: |
29+
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
30+
sed --version >/dev/null 2>&1 && sed -i "s@'vite-plus'@'vite'@g" vite.config.ts || sed -i '' "s@'vite-plus'@'vite'@g" vite.config.ts
31+
jq 'del(.overrides)' package.json > package.json.tmp && mv package.json.tmp package.json
32+
npm install -D vitest@3 vite@7
33+
- run: npx vitest && npm run build:ts && npm run build:version && npm pack && npx attw --pack
34+
env:
35+
NODE_OPTIONS: --require ./test/patch-for-node16-18.cjs
36+
- run: npm run test-node16

.github/workflows/nodejs.yml

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,38 @@ jobs:
1717
- name: Checkout repository
1818
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
1919

20-
- name: Install pnpm
21-
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
22-
2320
- name: Set up Node.js
2421
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
2522
with:
2623
node-version: '24'
27-
cache: 'pnpm'
2824

29-
- name: Install dependencies
30-
run: pnpm install --frozen-lockfile
25+
- name: Setup Vite+
26+
uses: voidzero-dev/setup-vite-plus-action@v1
27+
with:
28+
cache: true
29+
run-install: true
3130

3231
- name: Run lint
33-
run: pnpm run lint
32+
run: vite run lint
3433

3534
- name: Check dedupe
36-
run: pnpm dedupe --check
35+
run: vite dedupe --check
3736

3837
- name: Run typecheck
39-
run: pnpm run typecheck
38+
run: vite run typecheck
4039

4140
- name: Run format check
42-
run: pnpm run fmtcheck
41+
run: vite run fmtcheck
4342

44-
- name: Run build
45-
run: pnpm run build
43+
- name: Run build check
44+
run: vite run build
4645

4746
test:
4847
strategy:
4948
fail-fast: false
5049
matrix:
5150
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
52-
node: ['18', '20', '22', '24']
51+
node: ['20', '22', '24', '25']
5352

5453
name: Test (${{ matrix.os }}, ${{ matrix.node }})
5554
runs-on: ${{ matrix.os }}
@@ -65,24 +64,19 @@ jobs:
6564
- name: Checkout repository
6665
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
6766

68-
- name: Install pnpm
69-
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
70-
7167
- name: Set up Node.js
7268
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
7369
with:
7470
node-version: ${{ matrix.node }}
75-
cache: 'pnpm'
7671

77-
- name: Install dependencies
78-
run: pnpm install --frozen-lockfile
79-
80-
- name: Downgrade vitest for Node 18
81-
if: matrix.node == '18'
82-
run: pnpm add vitest@3 @vitest/coverage-v8@3 --save-dev --ignore-scripts
72+
- name: Setup Vite+
73+
uses: voidzero-dev/setup-vite-plus-action@v1
74+
with:
75+
cache: true
76+
run-install: true
8377

8478
- name: Run tests
85-
run: pnpm run ci
79+
run: vite run ci
8680

8781
- name: Code Coverage
8882
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5

.github/workflows/pkg.pr.new.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ on: [push, pull_request]
33

44
jobs:
55
build:
6+
concurrency:
7+
group: pkg-pr-new-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}
8+
cancel-in-progress: true
69
runs-on: ubuntu-latest
710

811
steps:
@@ -12,12 +15,15 @@ jobs:
1215
- run: corepack enable
1316
- uses: actions/setup-node@v6
1417
with:
15-
node-version: 20
18+
node-version: 22
1619

17-
- name: Install dependencies
18-
run: npm install
20+
- name: Setup Vite+
21+
uses: voidzero-dev/setup-vite-plus-action@v1
22+
with:
23+
cache: true
24+
run-install: true
1925

2026
- name: Build
21-
run: npm run prepublishOnly
27+
run: vite run build
2228

23-
- run: npx pkg-pr-new publish
29+
- run: vite dlx pkg-pr-new publish

.oxfmtrc.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

.oxlintrc.json

Lines changed: 0 additions & 128 deletions
This file was deleted.

CLAUDE.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,56 @@ Tests use Vitest with:
8282
- Request/response events published via `diagnostics_channel` (`urllib:request`, `urllib:response`)
8383
- Streaming requests disable retry/redirect functionality
8484
- User-Agent header: `node-urllib/{version} Node.js/{version} ({platform}; {arch})`
85+
86+
<!--VITE PLUS START-->
87+
# Using Vite+, the Unified Toolchain for the Web
88+
89+
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`.
90+
91+
## Vite+ Workflow
92+
93+
`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.
94+
95+
### Vite+ Commands
96+
97+
- dev - Run the development server
98+
- build - Build for production
99+
- lint - Lint code
100+
- test - Run tests
101+
- fmt - Format code
102+
- lib - Build library
103+
- new - Create a new monorepo package (in-project) or a new project (global)
104+
- run - Run tasks from `package.json` scripts
105+
106+
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.
107+
108+
### Package Manager Commands
109+
110+
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.
111+
112+
- install - Install all dependencies, or add packages if package names are provided
113+
- add - Add packages to dependencies
114+
- remove - Remove packages from dependencies
115+
- dlx - Execute a package binary without installing it as a dependency
116+
- info - View package information from the registry, including latest versions
117+
- link - Link packages for local development
118+
- outdated - Check for outdated packages
119+
- pm - Forward a command to the package manager
120+
- unlink - Unlink packages
121+
- update - Update packages to their latest versions
122+
- why - Show why a package is installed
123+
124+
## Common Pitfalls
125+
126+
- **Using the package manager directly:** Do not use pnpm, npm, or Yarn directly. Vite+ can handle all package manager operations.
127+
- **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.
128+
- **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`.
129+
- **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.
130+
- **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.
131+
- **Type-Aware Linting:** There is no need to install `oxlint-tsgolint`, `vite lint --type-aware` works out of the box.
132+
133+
## Review Checklist for Agents
134+
135+
- [ ] Run `vite install` after pulling remote changes and before getting started.
136+
- [ ] Run `vite lint`, `vite fmt`, and `vite test` to validate changes.
137+
<!--VITE PLUS END-->

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
[![Node.js Version](https://img.shields.io/node/v/urllib.svg?style=flat)](https://nodejs.org/en/download/)
99
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
1010
![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/node-modules/urllib)
11+
[![pkg.pr.new](https://pkg.pr.new/badge/node-modules/urllib)](https://pkg.pr.new/~/node-modules/urllib)
1112

1213
[npm-image]: https://img.shields.io/npm/v/urllib.svg?style=flat-square
1314
[npm-url]: https://npmjs.org/package/urllib

0 commit comments

Comments
 (0)