Skip to content

feat(nextjs): add disableWatch option to skip extra env-file watching#883

Closed
mhornbacher wants to merge 1 commit into
dmno-dev:mainfrom
mhornbacher:nextjs-disable-watch
Closed

feat(nextjs): add disableWatch option to skip extra env-file watching#883
mhornbacher wants to merge 1 commit into
dmno-dev:mainfrom
mhornbacher:nextjs-disable-watch

Conversation

@mhornbacher

@mhornbacher mhornbacher commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds disableWatch to varlockNextConfigPlugin (sets process.env.__VARLOCK_NEXT_DISABLE_WATCH)
  • Next forwards that delta into @next/env updateInitialEnv, which tears down extra-file watchers
  • Watched paths are shared across duplicate CJS copies of next-env-compat via globalThis + process.env.__VARLOCK_NEXT_WATCHED_EXTRA_FILES (loadEnvConfig and updateInitialEnv can hit different copies)
  • Unit tests cover same-instance and cross-instance teardown

Test plan

  • Rebuild/relink @varlock/nextjs-integration
  • DEBUG_VARLOCK_NEXT_INTEGRATION=1 with disableWatch: true
  • Expect next-env-compat module init <id> (possibly two ids), then after plugin: updateInitialEnv with { instance, newEnv } and disableWatch: unwatchAllExtraFiles { instance, count, paths }
  • FIFO .env watch loop stops
  • bun run --filter @varlock/nextjs-integration test:ci

@pkg-pr-new

pkg-pr-new Bot commented Jul 13, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/varlock@883
npm i https://pkg.pr.new/@varlock/nextjs-integration@883

commit: 858e58c

Plugin sets __VARLOCK_NEXT_DISABLE_WATCH; Next forwards that delta into @next/env updateInitialEnv, which unwatches already-installed extra env file watchers. No globalThis bridge.

Co-authored-by: Cursor <cursoragent@cursor.com>
@theoephraim

Copy link
Copy Markdown
Member

I think I solved this with a different tactic - we can just detect the FIFO and not watch it at all.
This still leaves watching/reloads intact when you edit other files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants