Repository navigation
Enable lazy dynamic imports by default in development - #101873
Conversation
|
Vercel Agent finished reviewing your changes. Vercel Agent's latest review does not approve this pull request under the repository's review policy. ExplanationPlease have @mischnic or @sokra review: the merge-base config-and-flags rubric strongly escalates the default changes at packages/next/src/server/config-shared.ts:2570-2571. The updated policy recognizes jimmyhmiller as a team member, but the default-change escalation still requires human review; I checked all four changed files, schema wiring, development guards, explicit-false handling, and activation paths without confirming a blocking defect. Native builds and browser tests remain unverified locally because dependencies and build outputs are unavailable. Review steps (43.8s)Preparing the workspace 16.2s |
Tests PassedCommit: 0e45853 |
9d966af to
40a9d98
Compare
|
can you pull the bugfixes into a separate PR? |
40a9d98 to
acf4cea
Compare
acf4cea to
2f54d81
Compare
### What? Extract the bugfixes from #101873 so they can merge before lazy dynamic imports are enabled by default. Both defaults remain unchanged. ### Why? Lazy imports can cause false reloads, return the wrong module namespace, or fail during loader evaluation when explicitly enabled. ### How? - Avoid false full-page reloads when lazy compilation advances the HMR version without a file edit. Each connection checks the version only on its first versioned `turbopack-subscribe`, which still catches updates missed through stale HTML or a dropped connection (a reconnect is a new connection and is checked again). Later mismatches on the same connection are ignored, since compiling a lazy chunk list advances the version without the client missing an update. - Return an ESM namespace when a manifest loader target is already available instead of returning raw CommonJS exports. - Include lazily compiled import targets in `this.importModule()` graphs, because loader evaluation runs in a separate process that cannot activate lazy imports. The graph is built with a new `ModuleGraphOptions::assume_activated` that follows the targets of lazy-import proxies, and those proxies generate their loading code in such graphs. Modules stay shared with the app instead of being processed a second time in a copy of the asset context. Explicitly enable both lazy-import flags in the existing loader fixture so its nested dynamic-import assertions cover this independently of the defaults, and check that a module imported by both the app and the loader is processed only as often as one that only the app imports. - Fix the runtime navigation HMR test to require the timing-dependent Fast Refresh log only for webpack. ### Verification - An earlier version of the combined implementation, with the previous forked-context importModule fix, passed CI in run 43967218926, attempt 2. - The standalone bugfix branch passes the importModule suite in Turbopack development, webpack development, and Turbopack production modes with the explicit flags. - Mutation checks: with no eager handling, the importModule suite fails because loader evaluation returns unsupported values. With the earlier forked asset context, the new processing-count assertion fails (2 runs against 1 for the control module). - `pnpm test-dev-turbo` on the importModule suite and the `lazy-dynamic-imports`, `lazy-dynamic-nested-imports` and `lazy-dynamic-chunk-list-collision` suites; `pnpm test-start-turbo` and `pnpm test-dev-webpack` on the importModule suite. - Manually: activating a lazy import in the browser doesn't re-run the loader, editing a lazy target re-runs only the importModule loader, and a restart with the persistent dev cache re-runs no loaders (checked on an earlier build of this fix, before the final refactors). <!-- NEXT_JS_LLM -->
Enable lazy compilation for client and SSR dynamic imports by default. Update chunk-list expectations for the additional HMR client manifest and the SSR next/dynamic manifest loader.
2f54d81 to
0ba0aab
Compare
|
Important Needs a person: this repository’s review rules call for a person’s review. Why?
The author is a team member, the change has 10 implementation lines, and I found no correctness findings. The f1 stale-docs finding from the earlier review is fixed. But the change flips the defaults of two config options in `config-shared.ts` and in the Rust config. REVIEW.md lists config defaults as a public behavior surface, and the config-and-flags rubric calls any default change in `config-shared.ts` a strong escalation. The author doesn't own config-and-flags, so that signal isn't downgraded to a comment. The `next_config.rs` change also hits turbopack-next-integration's medium signal.
Owners to review: mischnic, sokra. Facts from the base’s Summary
Flips the defaults of Questions for the author (2)
Checked (4)
Review steps
Read the full report ↗ (Download report.json • report.md) |
There was a problem hiding this comment.
Vercel Agent Verified Review reviewed 0ba0aab and isn’t approving it: this repository’s review rules call for a person’s review. 1 open finding is listed in its review summary and inline. View the full report
Both options now default to true in development, so the API reference shows how to disable them and records the default change in the version history.
…" (#102379) ## Summary Reverts #101873, which was merged before it was ready. `experimental.turbopackLazyDynamicImports` and `experimental.turbopackLazyDynamicImportsSSR` go back to being off by default in development, and the related docs and test expectations are restored. The bugfixes from #101937 are kept. This only reverts the default change. ## Verification - Clean `git revert` of 59490df - Not run: local tests (relying on CI) <!-- NEXT_JS_LLM -->
Summary
Enable
experimental.turbopackLazyDynamicImportsandexperimental.turbopackLazyDynamicImportsSSRby default in development so dynamic import targets are compiled only when used.Stacked on #101937, which contains the prerequisite bugfixes and should merge first. This layer changes only the defaults and their test expectations: the HMR client adds its own manifest chunk list, and the SSR
next/dynamicentry uses a manifest loader.Explicit
falsestill disables either flag. Production behavior is unchanged.Verification