Skip to content

Bundle serde only files#876

Closed
TooTallNate wants to merge 7 commits into01-13-add_support_for_use_step_functions_in_class_instance_methodsfrom
01-27-bundle_serde_only_files
Closed

Bundle serde only files#876
TooTallNate wants to merge 7 commits into01-13-add_support_for_use_step_functions_in_class_instance_methodsfrom
01-27-bundle_serde_only_files

Conversation

@TooTallNate
Copy link
Copy Markdown
Member

@TooTallNate TooTallNate commented Jan 28, 2026

Bundle serde-only files in workflow builds to ensure proper serialization/deserialization.

What changed?

Modified the builder to include serde-only files in the bundle instead of externalizing them. This change affects three different build configurations:

  1. Added serdeOnlyFiles to entriesToBundle in the main workflow build
  2. Added serdeOnlyFiles as entriesToBundle in the SWC plugin for workflow mode
  3. Added serdeOnlyFiles as entriesToBundle in the SWC plugin for client mode

How to test?

  1. Build a workflow that uses serde classes from node_modules
  2. Verify that the built workflow correctly serializes and deserializes data
  3. Check that the bundle includes the necessary serde classes

Why make this change?

When serde files were externalized, node_modules serde classes weren't properly bundled, which could cause serialization/deserialization issues. This change ensures that all necessary serde classes are included in the bundle, maintaining proper data handling across workflow executions.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 28, 2026

🦋 Changeset detected

Latest commit: 549c928

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 18 packages
Name Type
@workflow/builders Patch
@workflow/astro Patch
@workflow/cli Patch
@workflow/nest Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite Patch
workflow Patch
@workflow/world-testing Patch
@workflow/example-nest Patch
@workflow/docs-typecheck Patch
@workflow/nuxt Patch
workflow-vite-example Patch
@workflow/ai Patch
@workflow/core Patch
@workflow/web-shared Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 28, 2026

🧪 E2E Test Results

All tests passed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 479 0 38 517
Total 479 0 38 517

Details by Category

✅ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 43 0 4
✅ example 43 0 4
✅ express 43 0 4
✅ fastify 43 0 4
✅ hono 43 0 4
✅ nextjs-turbopack 46 0 1
✅ nextjs-webpack 46 0 1
✅ nitro 43 0 4
✅ nuxt 43 0 4
✅ sveltekit 43 0 4
✅ vite 43 0 4

📋 View full workflow run


Some E2E test jobs failed:

  • Vercel Prod: success
  • Local Dev: failure
  • Local Prod: failure
  • Local Postgres: failure
  • Windows: failure

Check the workflow run for details.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jan 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview, Comment Jan 28, 2026 10:09am
example-nextjs-workflow-webpack Ready Ready Preview, Comment Jan 28, 2026 10:09am
example-workflow Ready Ready Preview, Comment Jan 28, 2026 10:09am
workbench-astro-workflow Ready Ready Preview, Comment Jan 28, 2026 10:09am
workbench-express-workflow Ready Ready Preview, Comment Jan 28, 2026 10:09am
workbench-fastify-workflow Ready Ready Preview, Comment Jan 28, 2026 10:09am
workbench-hono-workflow Ready Ready Preview, Comment Jan 28, 2026 10:09am
workbench-nitro-workflow Ready Ready Preview, Comment Jan 28, 2026 10:09am
workbench-nuxt-workflow Ready Ready Preview, Comment Jan 28, 2026 10:09am
workbench-sveltekit-workflow Ready Ready Preview, Comment Jan 28, 2026 10:09am
workbench-vite-workflow Ready Ready Preview, Comment Jan 28, 2026 10:09am
workflow-docs Ready Ready Preview, Comment Jan 28, 2026 10:09am
workflow-nest Ready Ready Preview, Comment Jan 28, 2026 10:09am

The SWC transform adds imports like 'workflow/internal/class-serialization'
to files for class registration. When these files are inside node_modules
packages that don't directly depend on 'workflow', the import fails to resolve.

This fix adds an onResolve hook that catches workflow/internal/* imports
and resolves them from the project's working directory where 'workflow'
is installed, rather than from the file's location in node_modules.
Use import specifiers instead of file paths for class IDs, ensuring
consistent serialization across different export conditions (import vs
workflow). Package imports like 'just-bash' now generate IDs in the
format 'class//just-bash//ClassName' regardless of which file the
condition resolves to.

- Add packagePath parameter to SWC plugin transform
- Track package imports in esbuild plugin to determine specifier
- Add 'workflow' condition to enhanced-resolve for optimal entry points
- Skip serde-only transforms for external packages in rollup
- Add just-bash to workbench for testing workflow export conditions
Add a new fixture test that demonstrates all ID types (workflow, step, class)
using package paths instead of file paths when package_path is provided.

- Add package-based-ids fixture with test input and expected outputs
- Update fixture.rs to pass package_path='my-package' for this specific test
- Update spec.md to document that all IDs (not just classes) use package names
Two issues fixed for the Vite dev server:

1. Steps not found: The step bundle had its own 'registeredSteps' Map, but
   stepEntrypoint was imported externally and used a different Map. Fixed by
   using a global registry via Symbol.for('workflow-step-registry') so both
   the bundled code and external stepEntrypoint share the same registry.

2. Class serialization missing classId: When a package like 'just-bash' has
   serde patterns, its import was kept external while the serde file was
   bundled separately, creating two different class instances. Fixed by:
   - Tracking which packages have serde patterns during discovery
   - Not externalizing imports from packages with serde patterns
   - This ensures the class used in user code is the same one that gets
     registered for serialization

The first step (createBash) now succeeds and properly serializes the Bash
instance. A remaining issue exists where the workflow bundle uses a lightweight
Bash class without the exec() method - this is expected behavior for production
but causes issues in dev mode. This will be addressed in a separate change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant