Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clean-brooms-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@workflow/nitro": patch
---

Pass configured Nitro workflow scan directories through to Workflow builders.
8 changes: 6 additions & 2 deletions packages/nitro/src/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ function getNitroProjectRoot(nitro: Nitro): string {
return nitro.options.workspaceDir ?? nitro.options.rootDir;
}

function getNitroWorkflowDirs(nitro: Nitro): string[] {
return nitro.options.workflow?.dirs ?? ['.'];
}

export class VercelBuilder extends VercelBuildOutputAPIBuilder {
constructor(nitro: Nitro) {
super({
...createBaseBuilderConfig({
workingDir: nitro.options.rootDir,
projectRoot: getNitroProjectRoot(nitro),
dirs: ['.'], // Different apps that use nitro have different directories
dirs: getNitroWorkflowDirs(nitro),
runtime: nitro.options.workflow?.runtime,
sourcemap: nitro.options.workflow?.sourcemap,
externalPackages: getNitroStringExternals(nitro),
Expand Down Expand Up @@ -67,7 +71,7 @@ export class LocalBuilder extends BaseBuilder {
workingDir: nitro.options.rootDir,
projectRoot: getNitroProjectRoot(nitro),
watch: nitro.options.dev,
dirs: ['.'], // Different apps that use nitro have different directories
dirs: getNitroWorkflowDirs(nitro),
sourcemap: nitro.options.workflow?.sourcemap,
externalPackages: getNitroStringExternals(nitro),
}),
Expand Down
14 changes: 13 additions & 1 deletion packages/nitro/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type StubOptions = {
dev?: boolean;
preset?: string;
workspaceDir?: string;
workflow?: { runtime?: string };
workflow?: { dirs?: string[]; runtime?: string };
externals?: {
external?: Array<string | RegExp | ((id: string) => boolean)>;
};
Expand Down Expand Up @@ -332,6 +332,18 @@ describe('@workflow/nitro externals forwarding', () => {
expect(builder.config.projectRoot).toBe('/tmp');
});

it('forwards workflow.dirs to the workflow builder', () => {
const nitro = createNitroStub({
routing: true,
workflow: { dirs: ['server/workflows', 'layers/custom/workflows'] },
});
const builder = new Builder(nitro) as any;
expect(builder.config.dirs).toEqual([
'server/workflows',
'layers/custom/workflows',
]);
});

it('forwards string entries from nitro.options.externals.external', () => {
const nitro = createNitroStub({
routing: true,
Expand Down
Loading