Skip to content

Commit aafcfd6

Browse files
Isak Gustavsenclaude
authored andcommitted
fix(void): infer bindings from workflows/ modules
Resource imports used only inside workflows/, including _-prefixed step helpers and nested folders, now count toward binding inference, as they already do for durable-objects/. Apps with a sourceDir scan workflows/ too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent bce853d commit aafcfd6

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎docs/reference/resource-inference.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Regardless of mode, these are always checked:
7171
- **SSR entry** such as `src/main.ssr.ts`, for SSR apps that access bindings during rendering
7272
- **Application source** in `src/` or your configured `sourceDir`, including resource and auth imports
7373
- **`durable-objects/`**, which is scanned for typed Durable Object state modules in native Void apps
74-
- **`workflows/`**, which is scanned for Workflow modules in native Void apps
74+
- **`workflows/`**, which is scanned for Workflow modules and the resources they use in native Void apps
7575

7676
## Custom Scan Directories
7777

‎packages/void/src/plugin-inference.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const DEFAULT_SCAN_DIRS = [
5858
'crons',
5959
'email',
6060
'durable-objects',
61+
'workflows',
6162
'src',
6263
] as const;
6364

@@ -152,7 +153,8 @@ export function inferProjectBindings(
152153
): InferredBindings {
153154
const paths = options?.paths ?? readProjectPaths(root);
154155
const dirs =
155-
scanDirs ?? (paths.sourceDir ? [paths.sourceDir, 'durable-objects'] : DEFAULT_SCAN_DIRS);
156+
scanDirs ??
157+
(paths.sourceDir ? [paths.sourceDir, 'durable-objects', 'workflows'] : DEFAULT_SCAN_DIRS);
156158
const allBindings: Array<InferredBindings> = [];
157159
const scannedFiles = new Set<string>();
158160
const routesPrefix = `${toSlash(paths.routesDir).replace(/\/$/, '')}/`;

‎packages/void/test/unit/plugin-inference.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,24 @@ describe('inferProjectBindings', () => {
378378
});
379379
});
380380

381+
it('infers resources used only by Workflow modules and their helpers', () => {
382+
const root = createTempRoot();
383+
mkdirSync(join(root, 'workflows', 'order'), { recursive: true });
384+
writeFileSync(
385+
join(root, 'workflows', '_storage.ts'),
386+
`import { createStorage } from 'void/storage';
387+
export const files = (env) => createStorage(env.STORAGE);`,
388+
);
389+
writeFileSync(
390+
join(root, 'workflows', 'order', 'summary.ts'),
391+
`import { createAi } from 'void/ai';
392+
export const ai = (env) => createAi(env);`,
393+
);
394+
expect(inferProjectBindings(root)).toMatchObject({ needsAI: true, needsR2: true });
395+
writeFileSync(join(root, 'void.json'), JSON.stringify({ sourceDir: 'src' }));
396+
expect(inferProjectBindings(root)).toMatchObject({ needsAI: true, needsR2: true });
397+
});
398+
381399
it('detects live from a stream module outside the default directories only when scanned', () => {
382400
const root = createTempRoot();
383401
mkdirSync(join(root, 'routes'), { recursive: true });

0 commit comments

Comments
 (0)