-
Notifications
You must be signed in to change notification settings - Fork 139
Closed
Description
Description
When defining a workflow that imports from a SvelteKit app's server modules, the workflow plugin fails to resolve SvelteKit's virtual modules like $env/static/private.
Reproduction
- Create a SvelteKit app with the workflow plugin configured in
vite.config.ts:
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';
import { workflowPlugin } from 'workflow/sveltekit';
export default defineConfig({
plugins: [
sveltekit(),
workflowPlugin(),
],
});- Create a workflow file in
workflows/sample-workflow.tsthat imports from a server module:
export async function handleUserSignup(email: string) {
'use workflow';
const user = await getUserByEmail(email);
return { userId: user?.id, status: 'onboarded' };
}
async function getUserByEmail(email: string) {
'use step';
const { prisma } = await import('$lib/server/db');
return await prisma.user.findUnique({ where: { email } });
}- The
$lib/server/dbmodule imports from SvelteKit's virtual module:
import { MONGODB_URI } from "$env/static/private";
// ... prisma client setup- Run typecheck or build
Error
✘ [ERROR] Could not resolve "$env/static/private"
src/lib/server/db.ts:1:28:
1 │ import { MONGODB_URI } from "$env/static/private";
╵ ~~~~~~~~~~~~~~~~~~~~~
You can mark the path "$env/static/private" as external to exclude it from the bundle, which
will remove this error and leave the unresolved path in the bundle.
failed to load config from /path/to/project/apps/app/vite.config.ts
Preprocessing failed
Error: Build failed with 1 error:
src/lib/server/db.ts:1:28: ERROR: Could not resolve "$env/static/private"
Expected Behavior
The workflow plugin should either:
- Properly resolve SvelteKit's virtual modules (
$env/static/private,$env/dynamic/private,$lib/*, etc.) - Or mark these paths as external during the workflow discovery/bundling phase
Environment
- Bun
- esbuild 0.25.12
- svelte: 5.45.5
- @sveltejs/kit: 2.49.1
- workflow: 4.0.1-beta.28
Metadata
Metadata
Assignees
Labels
No labels