Repository navigation
Conversation
…two processes Add @modern-js/plugin-parallel-build. When enabled, the main process builds the client environment while a child process builds the server environment into a staging directory; the server bundles are moved into dist once both finish. The build stays single-process for dev, watch, analyze, Rsdoctor, SSG, RSC, extra environments and, in auto mode, low memory. The server compile wrote its generated tsconfig to one fixed path, so two compiles of the same app running at the same time could read each other's outDir and emit into the wrong directory. The file name now carries a hash of the output directory. Co-Authored-By: Riff
🦋 Changeset detectedLatest commit: 52e92f7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 116 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for modernjs-byted ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
Rsdoctor Bundle Diff Analysis📊 Quick Summary
Generated by Rsdoctor GitHub Action |
…mat docs The thread-split assertion assumed at least four cores and the temp dir assertion assumed POSIX separators; both now hold on the macOS and Windows runners. The new documentation files are formatted with the repository formatter. Co-Authored-By: Riff
…, follow SSG per-entry rule Running every integration fixture in two-process mode surfaced two problems. First, consumers of the server bundles depended on plugin order: with the plugin registered after plugin-ssg, SSG ran before the merge and failed with a missing dist/bundles/index.js. The merge now runs in a `pre` ordered Rsbuild after-build hook, ahead of the framework's own after-build bridge, so deploy and custom plugins see the complete dist whatever their position. Second, `output.ssgByEntries` was not recognised, so SSG apps configured per entry were split. SSG detection now follows the framework's rule (per-entry settings first, then `output.ssg`). SSG keeps falling back to one process: the server build process runs the whole CLI lifecycle, so it would prerender a second time without the client output. The staging directory is removed when the server build fails. Co-Authored-By: Riff
…ormance.parallelBuild Replace the separate plugin, which re-ran the whole CLI in a child process and moved the server bundles back, with a capability built into the build path. Planning (entries, routes, generated code) and the after-build steps still run once in the main process. With `performance.parallelBuild` the builder of the main process is created without the server environment, and a worker process, started when the build begins, creates a builder for that environment only from the planning results it receives. Both write to the final dist, so there is no staging directory or merge, and the output is identical to a single-process build. The worker initialises the CLI because functions in the build configuration cannot cross a process boundary; planning hooks and build/deploy hooks do not run there. The plain-data parts of the configuration shared by both builds are compared with the main process and the build fails if they differ. The option is off by default; without it the build takes the same path as before. RSC, watch, analyze and Rsdoctor keep the single process. Co-Authored-By: Riff
…lBuild moves to the worker Co-Authored-By: Riff
…ironment, not by SSR Co-Authored-By: Riff
Co-Authored-By: Riff
…split Add integration cases for a server compile that fails in the worker and for a configuration that evaluates differently in the two processes. Remove the Rayon thread split between the processes: at 10k modules per compiler it made no measurable difference against fixed pools of 24 or 64 threads, with or without a JavaScript loader. Document that the stats passed to onAfterBuild cover the client environment only. Co-Authored-By: Riff
…orker The BFF loader imports the API modules while the server environment is compiled. The worker did not register the swc hooks and tsconfig paths, so an API module importing through a path alias failed to load. Co-Authored-By: Riff
…parallelBuild Co-Authored-By: Riff
Co-Authored-By: Riff
…ce.parallelBuild Co-Authored-By: Riff
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
An application whose build has a
serverenvironment (SSR or SSG enabled) compiles itsclientandserverenvironments with two Rspack compilers in one Node.js process. They share one main thread and one V8 heap, so JavaScript loaders, plugin hooks and garbage collection of one compiler stall the other.This PR adds the experimental option
performance.parallelBuildto@modern-js/app-tools. When it is on, a production build keeps planning (entries, routes, generated code) and every after-build step (server/andapi/compilation, SSG, deploy) in the main process, where they run once. Only the Rspack compile of the server environment moves to a worker process: the main builder is created without that environment, and the worker creates a builder for it from the planning results sent by the main process. Both processes write to the final dist, so the output is identical to a single-process build. The worker initialises the CLI because functions in the build configuration cannot be sent to another process; planning hooks and build/deploy hooks do not run there. The plain-data parts of the configuration that both builds share are compared between the two processes and the build fails if they differ.The option is off by default and has no sub-options. Without it the build takes the same code path as before.
dev,--watch,--analyze, Rsdoctor and RSC applications keep the single process.An earlier revision of this PR implemented the idea as a separate plugin that re-ran the CLI in a child process; that package is removed.
It also fixes a concurrency bug in
@modern-js/server-utils: the server-directory compile wrote its generated tsconfig to one fixed path, so two compiles of the same app running at the same time could read each other'soutDir.构建中包含
server环境的应用(开启 SSR 或 SSG),其client与server两个环境由同一进程里的两个 Rspack 编译器编译,共用主线程和 V8 堆。本 PR 为@modern-js/app-tools新增实验性配置performance.parallelBuild:开启后规划与构建后的步骤仍只在主进程执行一次,只有 server 环境的 Rspack 编译交给 worker 进程,两个进程直接写入最终 dist,产物与单进程一致。默认关闭、无子选项,不开启时代码路径不变;dev、watch、analyze、Rsdoctor 与 RSC 保持单进程。同时修复@modern-js/server-utils临时 tsconfig 固定路径导致的并发问题。Related Links
modifyBuilderEnvironmentsordering introduced in feat(app-tools): add modifyBuilderEnvironments hook #8717 (environment filtering happens after that hook).Validation Evidence
tests/integration/ssr/tests/parallel-build.test.ts: builds an existing app that has a server environment (the SSR base app) with and without the option and asserts the emitted files are byte-identical, the worker was used, and the server directory was compiled once.pnpm --filter @modern-js/app-tools test: 29 passed.pnpm lint,pnpm check,pnpm check-changeset, type check of app-tools: pass.Retained Tests and Exceptions
ssrbase app (no new fixture). It protects the public contract of the option: identical output and single execution of after-build steps.Checklist
pnpm run changeif published package behavior changes.Co-Authored-By: Riff