2025-11-26 16:02:13 -08:00
|
|
|
{
|
|
|
|
|
"name": "@workflow/rollup",
|
2026-09-09 12:12:11 -07:00
|
|
|
"version": "5.0.0-beta.49",
|
2026-03-29 16:05:39 -07:00
|
|
|
"description": "Rollup plugin for Workflow SDK",
|
2025-11-26 16:02:13 -08:00
|
|
|
"type": "module",
|
|
|
|
|
"main": "dist/index.js",
|
|
|
|
|
"files": [
|
|
|
|
|
"dist"
|
|
|
|
|
],
|
|
|
|
|
"publishConfig": {
|
|
|
|
|
"access": "public"
|
|
|
|
|
},
|
|
|
|
|
"license": "Apache-2.0",
|
|
|
|
|
"repository": {
|
|
|
|
|
"type": "git",
|
|
|
|
|
"url": "https://github.com/vercel/workflow.git",
|
|
|
|
|
"directory": "packages/rollup"
|
|
|
|
|
},
|
|
|
|
|
"exports": {
|
|
|
|
|
".": "./dist/index.js"
|
|
|
|
|
},
|
|
|
|
|
"scripts": {
|
|
|
|
|
"build": "tsc",
|
|
|
|
|
"dev": "tsc --watch",
|
2026-07-10 10:13:34 -07:00
|
|
|
"clean": "tsc --build --clean && rm -rf dist",
|
|
|
|
|
"test": "vitest run src",
|
|
|
|
|
"typecheck": "tsc --noEmit"
|
2025-11-26 16:02:13 -08:00
|
|
|
},
|
|
|
|
|
"dependencies": {
|
|
|
|
|
"@swc/core": "catalog:",
|
Add discovery for custom classes with workflow serialization (#859)
Added automatic discovery for custom classes with workflow serialization, allowing serialization classes to be defined in separate files without requiring explicit directives.
### What changed?
- Added detection for files containing custom class serialization patterns:
- Files importing from `@workflow/serde`
- Files using `Symbol.for('workflow-serialize')` or `Symbol.for('workflow-deserialize')`
- Created shared utilities in `transform-utils.ts` for consistent pattern detection across all build tools
- Updated Next.js, Nitro, Rollup, and Vite plugins to use the new detection patterns
- Added exclusion logic to prevent re-processing of generated workflow files
- Added tests to verify the pattern detection works correctly
- Updated documentation in the SWC plugin spec to explain the new discovery mechanism
### How to test?
1. Create a class with custom serialization in a separate file:
```js
// models/point.js
export class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
static [Symbol.for('workflow-serialize')](instance) {
return { x: instance.x, y: instance.y };
}
static [Symbol.for('workflow-deserialize')](data) {
return new Point(data.x, data.y);
}
}
```
1. Import and use this class in a workflow or step file:
```js
'use workflow';
import { Point } from '../models/point';
export function myWorkflow() {
const point = new Point(10, 20);
return point;
}
```
1. Verify the class is properly serialized when passed between client and server
### Why make this change?
Previously, files containing custom serialization classes needed to include a `'use step'` directive to be discovered and transformed, even if they weren't actual step functions. This was unintuitive and could lead to confusion.
This change allows for a more natural code organization pattern where model classes with serialization can be defined in their own files without requiring directives. The build system will automatically discover and transform these files to ensure the serialization works correctly when the classes are used in workflows or steps.
2026-02-02 23:19:00 -08:00
|
|
|
"@workflow/builders": "workspace:*",
|
2025-11-26 16:02:13 -08:00
|
|
|
"@workflow/swc-plugin": "workspace:*",
|
|
|
|
|
"exsolve": "1.0.7"
|
|
|
|
|
},
|
|
|
|
|
"devDependencies": {
|
|
|
|
|
"@types/node": "catalog:",
|
|
|
|
|
"@workflow/tsconfig": "workspace:*",
|
2026-07-10 10:13:34 -07:00
|
|
|
"rollup": "^4.62.2",
|
2026-07-13 11:33:55 -07:00
|
|
|
"typescript": "catalog:",
|
2026-07-10 10:13:34 -07:00
|
|
|
"vitest": "catalog:"
|
2025-11-26 16:02:13 -08:00
|
|
|
}
|
2026-03-23 17:39:39 -07:00
|
|
|
}
|