Skip to content
Merged
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
19 changes: 14 additions & 5 deletions packages/plugin-rsc/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@ Before creating or changing a conventional RSC example, use [`examples/starter-e

## Quick Reference for AI Agents

### Essential Commands
### Fresh Worktree Setup

```bash
# inside packages/plugin-rsc directory
pnpm build # build package
# from the repository root
pnpm install
pnpm build
```

Run the full workspace build before RSC E2E tests because examples use other workspace packages, such as `@vitejs/plugin-react`.

### Package Commands

```bash
# inside packages/plugin-rsc
pnpm tsc # typecheck
pnpm test # Run unit tests
pnpm test-e2e # Run e2e tests
pnpm test --run # run unit tests
pnpm test-e2e # run E2E tests
```
8 changes: 6 additions & 2 deletions packages/plugin-rsc/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ Use colocated unit tests for self-contained transforms and utilities.
## Development Workflow

```bash
# Build packages
pnpm dev # pnpm -C packages/plugin-rsc dev
# Install and build from the repository root
pnpm install
pnpm build

# Watch the RSC package during development
pnpm -C packages/plugin-rsc dev

# Type check
pnpm -C packages/plugin-rsc tsc
Expand Down
41 changes: 34 additions & 7 deletions packages/plugin-rsc/e2e/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function runCli(options: { command: string; label?: string } & SpawnOptions) {
console.log(styleText('magenta', label), data.toString())
})
const done = new Promise<void>((resolve) => {
child.on('exit', (code) => {
child.on('close', (code) => {
if (code !== 0 && code !== 143 && process.platform !== 'win32') {
console.log(styleText('magenta', `${label}`), `exit code ${code}`)
}
Expand All @@ -32,15 +32,42 @@ function runCli(options: { command: string; label?: string } & SpawnOptions) {
})

async function findPort(): Promise<number> {
let stdout = ''
return new Promise((resolve) => {
child.stdout!.on('data', (data) => {
stdout += stripVTControlCharacters(String(data))
const match = stdout.match(/http:\/\/localhost:(\d+)/)
let portOutput = ''
return new Promise((resolve, reject) => {
function cleanup() {
child.stdout!.off('data', onData)
child.off('close', onClose)
child.off('error', onError)
}

function onData(data: Buffer) {
portOutput += stripVTControlCharacters(String(data))
const match = portOutput.match(/http:\/\/localhost:(\d+)/)
if (match) {
cleanup()
resolve(Number(match[1]))
}
})
}

function onClose(code: number | null, signal: NodeJS.Signals | null) {
cleanup()
const details = stderr.trim() || stdout.trim()
reject(
new Error(
`${label} exited with ${code ?? signal ?? 'unknown status'} before publishing a port` +
(details ? `\n${details}` : ''),
),
)
}

function onError(error: Error) {
cleanup()
reject(error)
}

child.stdout!.on('data', onData)
child.on('close', onClose)
child.on('error', onError)
})
}

Expand Down
Loading