diff --git a/.changeset/six-peas-make.md b/.changeset/six-peas-make.md new file mode 100644 index 0000000000..77579e013d --- /dev/null +++ b/.changeset/six-peas-make.md @@ -0,0 +1,5 @@ +--- +"@workflow/core": patch +--- + +Use globalThis-backed Map for step function registry to prevent module duplication from splitting the registry in Turbopack dev mode diff --git a/packages/core/src/private.ts b/packages/core/src/private.ts index 0eabc7b70f..e8686c3f6c 100644 --- a/packages/core/src/private.ts +++ b/packages/core/src/private.ts @@ -15,7 +15,16 @@ export type StepFunction< stepId?: string; }; -const registeredSteps = new Map(); +const RegisteredStepsKey = Symbol.for('@workflow/core//registeredSteps'); + +const globalSymbols: typeof globalThis & { + [RegisteredStepsKey]?: Map; +} = globalThis; + +const registeredSteps = (globalSymbols[RegisteredStepsKey] ??= new Map< + string, + StepFunction +>()); function getStepIdAliasCandidates(stepId: string): string[] { const parts = stepId.split('//');