cloudflare / cloudflare/workers-sdk
Cannot use `@callable` with `@cloudflare/vite-plugin`
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.5k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 186
Description
### What versions & operating system are you using?
System:
OS: macOS 15.5
CPU: (14) arm64 Apple M4 Max
Memory: 117.58 MB / 36.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.12.0 - /Users/esoub/.nvm/versions/node/v24.12.0/bin/node
npm: 11.6.2 - /Users/esoub/.nvm/versions/node/v24.12.0/bin/npm
pnpm: 10.28.2 - /Users/esoub/.nvm/versions/node/v24.12.0/bin/pnpm
bun: 1.3.7 - /Users/esoub/.bun/bin/bun
Deno: 2.6.8 - /opt/homebrew/bin/deno
npmPackages:
@cloudflare/vite-plugin: ^1.25.2 => 1.25.2
wrangler: ^4.67.0 => 4.67.0
### Please provide a link to a minimal reproduction
https://github.com/Barbapapazes/vite-cloudflare-decorators
### Describe the Bug
1. Create a simple Vite project with a file named index.ts with the following content
```ts
import { Agent, callable, routeAgentRequest } from 'agents'
import { env } from 'cloudflare:workers'
export default {
async fetch(request: Request, env: Env) {
return (
(await routeAgentRequest(request, env, {
prefix: 'api',
}))
?? new Response('Not found', { status: 404 })
)
},
} satisfies ExportedHandler
export class AIAgent extends Agent {
@callable() // This is the line that breaks the server (without, everything works fine)
async analyze(input: string) {
console.log('Analyzing...', input)
return `Analysis of "${input}": ...`
}
}
```
2. See the console, you should see the following error
```txt
error when starting dev server:
SyntaxError: Invalid or unexpected token
at Object.runInlinedModule (workers/runner-worker.js:1314:35)
at CustomModuleRunner.directRequest (workers/runner-worker.js:1166:80)
at CustomModuleRunner.cachedRequest (workers/runner-worker.js:1084:73)
ELIFECYCLE Command failed with exit code 1.
```
### Please provide any relevant error logs
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.