Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 0 additions & 28 deletions .oxfmtrc.json

This file was deleted.

16 changes: 0 additions & 16 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 @@ -1013,3 +1013,56 @@ Include setup instructions and common configuration patterns.
- [Koa.js](https://koajs.com/) - Underlying web framework
- [Midway.js](https://midwayjs.org/) - Enterprise Node.js framework
- [Think.js](https://thinkjs.org/) - Alternative Node.js framework

<!--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-->
10 changes: 5 additions & 5 deletions examples/helloworld-tegg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
"scripts": {
"dev": "egg-bin dev",
"debug": "egg-bin debug",
"test": "vitest run",
"cov": "vitest run --coverage",
"test": "vite test run",
"cov": "vite test run --coverage",
"lint": "eslint . --ext .ts",
"ci": "pnpm run lint && pnpm run cov",
"prepublishOnly": "pnpm run build",
"start": "egg-scripts start --daemon",
"stop": "egg-scripts stop",
"typecheck": "tsgo --noEmit",
"build": "tsdown"
"build": "vite lib"
},
"dependencies": {
"@eggjs/scripts": "workspace:",
Expand All @@ -56,9 +56,9 @@
"@eggjs/bin": "workspace:*",
"@eggjs/mock": "workspace:*",
"@eggjs/tsconfig": "workspace:*",
"tsdown": "catalog:",
"typescript": "catalog:",
"vitest": "catalog:"
"vitest": "catalog:",
"vite-plus": "catalog:"
},
"engines": {
"node": ">=22.18.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld-tegg/test/ArgsController.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { app } from '@eggjs/mock/bootstrap';
import { expect, test } from 'vitest';
import { expect, test } from 'vite-plus/test';

test('should POST /api/args/request success', async () => {
app.mockCsrf();
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld-tegg/test/SimpleController.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { app } from '@eggjs/mock/bootstrap';
import { expect, test } from 'vitest';
import { expect, test } from 'vite-plus/test';

test('should GET /api/headers with headers', async () => {
await app.httpRequest().get('/api/headers').set('X-Custom', 'custom').expect(200).expect({
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld-tegg/test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { beforeAll, afterAll } from 'vitest';
import { beforeAll, afterAll } from 'vite-plus/test';

// https://vitest.dev/config/#setupfiles
// export beforeAll and afterAll to globalThis, let @eggjs/mock/bootstrap use it
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld-tegg/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from 'tsdown';
import { defineConfig } from 'vite-plus/lib';

export default defineConfig({
entry: ['app.ts', 'config/**/*.ts', 'app/**/*.ts'],
Expand Down
7 changes: 7 additions & 0 deletions examples/helloworld-tegg/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite-plus';

import tsdownConfig from './tsdown.config.js';

export default defineConfig({
lib: tsdownConfig,
});
2 changes: 1 addition & 1 deletion examples/helloworld-tegg/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineProject } from 'vitest/config';
import { defineProject } from 'vite-plus';

export default defineProject({
test: {
Expand Down
10 changes: 5 additions & 5 deletions examples/helloworld-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
"scripts": {
"dev": "egg-bin dev",
"debug": "egg-bin debug",
"test": "vitest run",
"cov": "vitest run --coverage",
"test": "vite test run",
"cov": "vite test run --coverage",
"lint": "eslint . --ext .ts",
"ci": "pnpm run lint && pnpm run cov",
"prepublishOnly": "pnpm run build",
"start": "egg-scripts start --daemon",
"stop": "egg-scripts stop",
"typecheck": "tsgo --noEmit",
"build": "tsdown"
"build": "vite lib"
},
"dependencies": {
"@eggjs/scripts": "workspace:",
Expand All @@ -44,9 +44,9 @@
"@eggjs/bin": "workspace:*",
"@eggjs/mock": "workspace:*",
"@eggjs/tsconfig": "workspace:*",
"tsdown": "catalog:",
"typescript": "catalog:",
"vitest": "catalog:"
"vitest": "catalog:",
"vite-plus": "catalog:"
},
"engines": {
"node": ">=22.18.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld-typescript/test/hello.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { app } from '@eggjs/mock/bootstrap';
import { test } from 'vitest';
import { test } from 'vite-plus/test';

test('should GET /', async () => {
await app.httpRequest().get('/').expect(200).expect('Hello EggJS 🥚🥚🥚🥚');
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld-typescript/test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { beforeAll, afterAll } from 'vitest';
import { beforeAll, afterAll } from 'vite-plus/test';

// https://vitest.dev/config/#setupfiles
// export beforeAll and afterAll to globalThis, let @eggjs/mock/bootstrap use it
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld-typescript/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from 'tsdown';
import { defineConfig } from 'vite-plus/lib';

export default defineConfig({
entry: ['app.ts', 'config/**/*.ts', 'app/**/*.ts'],
Expand Down
7 changes: 7 additions & 0 deletions examples/helloworld-typescript/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite-plus';

import tsdownConfig from './tsdown.config.js';

export default defineConfig({
lib: tsdownConfig,
});
2 changes: 1 addition & 1 deletion examples/helloworld-typescript/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineProject } from 'vitest/config';
import { defineProject } from 'vite-plus';

export default defineProject({
test: {
Expand Down
21 changes: 9 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
"scripts": {
"clean-dist": "pnpm -r --parallel exec rimraf dist",
"clean": "pnpm -r --parallel run clean && pnpm clean-dist",
"build": "tsdown",
"build": "vite lib",
"prelint": "pnpm clean-dist",
"lint": "oxlint --type-aware --type-check --quiet",
"fmt": "oxfmt",
"lint": "vite lint --type-aware --type-check --quiet",
"fmt": "vite fmt",
"typecheck": "pnpm clean && pnpm -r run typecheck",
"fmtcheck": "oxfmt --check .",
"fmtcheck": "vite fmt --check .",
"pretest": "pnpm run clean && pnpm -r run pretest",
"test": "vitest run --bail 1 --retry 2 --testTimeout 20000 --hookTimeout 20000",
"test": "vite test run --bail 1 --retry 2 --testTimeout 20000 --hookTimeout 20000",
"test:cov": "pnpm run test --coverage",
"preci": "pnpm -r --parallel run pretest",
"ci": "pnpm run test --coverage",
Expand Down Expand Up @@ -58,22 +58,19 @@
"js-yaml": "catalog:",
"lint-staged": "catalog:",
"mocha": "catalog:",
"oxfmt": "catalog:",
"oxlint": "catalog:",
"oxlint-tsgolint": "catalog:",
"publint": "catalog:",
"rimraf": "catalog:",
"semver": "catalog:",
"tsdown": "catalog:",
"tsx": "catalog:",
"typescript": "catalog:",
"urllib": "catalog:",
"vitest": "catalog:"
"vitest": "catalog:",
"vite-plus": "catalog:"
Comment on lines +67 to +68
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The new CLAUDE.md documentation explicitly states that vitest should not be installed directly as vite-plus wraps it:

Do not install Vitest, Oxlint, Oxfmt, or tsdown directly: Vite+ wraps these tools. They must not be installed directly.
...
You must not install vitest to import test utilities.

However, vitest is still listed as a dev dependency here and in other packages. If it's required for type definitions or other reasons not covered by vite-plus, the documentation should be updated to clarify this. If it's not needed, it should be removed to align with the new development guidelines and avoid confusion.

},
"lint-staged": {
"*": [
"oxfmt --no-error-on-unmatched-pattern",
"oxlint --type-aware --fix"
"vite fmt --no-error-on-unmatched-pattern",
"vite lint --type-aware --fix"
]
},
"engines": {
Expand Down
8 changes: 4 additions & 4 deletions packages/cluster/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
}
},
"scripts": {
"lint": "oxlint",
"lint": "vite lint",
"typecheck": "tsgo --noEmit",
"test": "vitest run"
"test": "vite test run"
},
"dependencies": {
"@eggjs/utils": "workspace:*",
Expand All @@ -65,10 +65,10 @@
"@eggjs/tsconfig": "workspace:*",
"address": "catalog:",
"coffee": "catalog:",
"tsdown": "catalog:",
"typescript": "catalog:",
"urllib": "catalog:",
"vitest": "catalog:"
"vitest": "catalog:",
"vite-plus": "catalog:"
},
"engines": {
"node": ">=22.18.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/cluster/test/agent_worker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { scheduler } from 'node:timers/promises';

import { mm, type MockClusterApplication } from '@eggjs/mock';
import coffee from 'coffee';
import { describe, it, afterEach, beforeAll, afterAll } from 'vitest';
import { describe, it, afterEach, beforeAll, afterAll } from 'vite-plus/test';

import { cluster, getFilepath } from './utils.ts';

Expand Down
2 changes: 1 addition & 1 deletion packages/cluster/test/app_worker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { mm, type MockApplication } from '@eggjs/mock';
import { request } from '@eggjs/supertest';
import { ip } from 'address';
import urllib from 'urllib';
import { describe, it, afterEach, beforeEach, beforeAll, afterAll } from 'vitest';
import { describe, it, afterEach, beforeEach, beforeAll, afterAll } from 'vite-plus/test';

import { cluster, getFilepath } from './utils.ts';

Expand Down
2 changes: 1 addition & 1 deletion packages/cluster/test/https.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from 'node:assert';

import { mm, type MockApplication } from '@eggjs/mock';
import { HttpClient } from 'urllib';
import { describe, it, afterEach } from 'vitest';
import { describe, it, afterEach } from 'vite-plus/test';

import { getFilepath, cluster } from './utils.ts';

Expand Down
2 changes: 1 addition & 1 deletion packages/cluster/test/master/after-start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { strict as assert } from 'node:assert';
import { scheduler } from 'node:timers/promises';

import { mm, type MockApplication } from '@eggjs/mock';
import { describe, it, afterEach, beforeAll, afterAll } from 'vitest';
import { describe, it, afterEach, beforeAll, afterAll } from 'vite-plus/test';

import { cluster } from '../utils.ts';

Expand Down
2 changes: 1 addition & 1 deletion packages/cluster/test/master/check-pid-file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from 'node:path';
import { scheduler } from 'node:timers/promises';

import { mm, type MockApplication } from '@eggjs/mock';
import { describe, it, afterEach, beforeEach } from 'vitest';
import { describe, it, afterEach, beforeEach } from 'vite-plus/test';

import { cluster, getFilepath } from '../utils.ts';

Expand Down
2 changes: 1 addition & 1 deletion packages/cluster/test/master/close-master.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { once } from 'node:events';
import { scheduler } from 'node:timers/promises';

import { mm, type MockApplication } from '@eggjs/mock';
import { describe, it, afterEach } from 'vitest';
import { describe, it, afterEach } from 'vite-plus/test';

import { cluster } from '../utils.ts';

Expand Down
2 changes: 1 addition & 1 deletion packages/cluster/test/master/messenger.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { scheduler } from 'node:timers/promises';

import { mm, type MockApplication } from '@eggjs/mock';
import { describe, it, afterEach } from 'vitest';
import { describe, it, afterEach } from 'vite-plus/test';

import { cluster } from '../utils.ts';

Expand Down
2 changes: 1 addition & 1 deletion packages/cluster/test/master/others.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { scheduler } from 'node:timers/promises';

import { mm, type MockApplication } from '@eggjs/mock';
import { request } from '@eggjs/supertest';
import { describe, it, afterEach, beforeAll, afterAll } from 'vitest';
import { describe, it, afterEach, beforeAll, afterAll } from 'vite-plus/test';

import { cluster, getFilepath } from '../utils.ts';

Expand Down
2 changes: 1 addition & 1 deletion packages/cluster/test/master/start-master.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { strict as assert } from 'node:assert';

import { mm, type MockApplication } from '@eggjs/mock';
import { describe, it, afterEach } from 'vitest';
import { describe, it, afterEach } from 'vite-plus/test';

import { cluster } from '../utils.ts';

Expand Down
2 changes: 1 addition & 1 deletion packages/cluster/test/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from 'node:path';

import { mm } from '@eggjs/mock';
import { importResolve } from '@eggjs/utils';
import { describe, it, afterEach, beforeAll, afterAll } from 'vitest';
import { describe, it, afterEach, beforeAll, afterAll } from 'vite-plus/test';

import { parseOptions } from '../src/utils/options.ts';
import { getFilepath, cluster } from './utils.ts';
Expand Down
Loading
Loading