Skip to content
Merged
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/wide-onions-slide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@workflow/next": patch
---

Make lazy discovery in Next.js opt-in
12 changes: 11 additions & 1 deletion packages/next/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { NextConfig } from 'next';
import semver from 'semver';
import {
DEFERRED_BUILDER_MIN_VERSION,
getNextBuilder,
shouldUseDeferredBuilder,
WORKFLOW_DEFERRED_ENTRIES,
Expand All @@ -17,6 +18,7 @@ export function withWorkflow(
workflows,
}: {
workflows?: {
lazyDiscovery?: boolean;
local?: {
port?: number;
dataDir?: string;
Expand Down Expand Up @@ -66,7 +68,15 @@ export function withWorkflow(
const existingRules = nextConfig.turbopack.rules as any;
const nextVersion = require('next/package.json').version;
const supportsTurboCondition = semver.gte(nextVersion, 'v16.0.0');
const useDeferredBuilder = shouldUseDeferredBuilder(nextVersion);
const useDeferredBuilder =
workflows?.lazyDiscovery && shouldUseDeferredBuilder(nextVersion);

Comment thread
vercel[bot] marked this conversation as resolved.
if (workflows?.lazyDiscovery && !useDeferredBuilder) {
console.warn(
`Enabled lazyDiscovery but Next.js version is not compatible, needs ${DEFERRED_BUILDER_MIN_VERSION} have ${nextVersion}`
);
}

// Deferred builder discovers files via loader socket notifications, so
// turbopack content conditions are only needed with the eager builder.
const shouldApplyTurboCondition =
Expand Down
Loading