Skip to content

fix(plugins): watch the configs devup.json extends in webpack and Rsbuild - #928

Merged
owjs3901 merged 5 commits into
mainfrom
fix/webpack-rsbuild-config-inputs
Nov 17, 2026
Merged

owjs3901 merged 5 commits into
mainfrom
fix/webpack-rsbuild-config-inputs

Conversation

@owjs3901

@owjs3901 owjs3901 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the part of #686's PLG-08 that remained in webpack and Rsbuild, the way Vite does it: they did not watch the config files that devup.json extends.

Problem

  • Vite collects and watches every file read while following extends, via loadDevupConfig(devupFile, inputs).
  • webpack watched only the single devup.json that existed at apply time (existsDevup was captured once in apply).
  • Rsbuild didn't even re-read devup.json itself in dev; it watched only Tailwind CSS files.
  • So editing a base theme, or adding or deleting devup.json, left the old CSS, theme.d.ts, and default theme in place.

Change

  • webpack (including the Next.js webpack path)
    • writeDataFiles passes an inputs set to loadDevupConfigSync and stores devup.json and the whole extends chain in configFiles, including files that don't exist.
    • The watch watchRun stamps the mtimes of configFiles and the Tailwind files. Missing files count as 0. If they change, the theme is re-read.
    • afterCompile is always registered. Existing configs go into fileDependencies, and configs that don't exist yet go into missingDependencies, so their creation is detected too.
  • Rsbuild
    • writeDataFiles returns { tailwindFiles, configFiles }.
    • The watchRun stamp includes the config files.
    • The JS transform registers existing configs with addDependency and missing configs with addMissingDependency. So when a config is edited, added, or deleted, modules are rebuilt and the theme is re-read.
  • Added addMissingDependency to the transform context in the test mock. It is a required field in the Rsbuild types.

PLG-13 is not in this PR

Vite's PLG-13 fix moves the atom-hoist / canonical map pre-pass into the reservation's beforeReserve and computes it over the reservation inventory's import graph (reservationGraph(inventory)). That graph covers src, app, the entry closure, and include. Applying the same structure to webpack and Rsbuild brings along the following.

  • The pre-pass timing moves from apply/setup to run/watchRun.
  • About 110 points in both plugins' tests that verify atom-hoist (where createSharedSlotReservation is mocked, so beforeReserve is not called) would need rewriting.
  • Next's productionPrewarmFiles throw semantics would also need to be realigned.

So it is left as separate work.

New errors

None.

Note

This touches the same writeDataFiles as #924 (fail the build on theme errors), so whichever merges later needs to resolve the conflict. On the webpack side, configFiles is recorded in finally, so it also works with #924's rethrow.

Test plan

  • bun test packages/webpack-plugin: 3565 pass, plugin.ts 100%
    • New tests: an extended base config ends up in configFiles and fileDependencies, it reloads when the base is edited or deleted, and it is not re-read when unchanged
    • Existing should apply matrix: updated expectations so it stats and adds to missingDependencies even when devup.json doesn't exist
  • bun test packages/rsbuild-plugin: 599 pass, plugin.ts 100%
    • New tests: it reloads when the base is edited or deleted, and the transform adds existing configs via addDependency and deleted configs via addMissingDependency
  • tsc --noEmit (webpack, rsbuild), bunx prettier --single-quote --no-semi --check pass
  • CI

요약

#686의 PLG-08 중 webpack·Rsbuild에 남아 있던 부분을 Vite처럼 고칩니다. devup.json이 extends하는 config 파일들을 감시하지 않던 문제입니다.

문제

  • Vite는 loadDevupConfig(devupFile, inputs)로 extends를 따라 읽은 파일을 모두 모아 감시합니다.
  • webpack은 apply 시점에 존재하던 devup.json 하나만 감시했습니다 (existsDevup를 apply에서 한 번만 캡처).
  • Rsbuild는 dev에서 devup.json 자체도 다시 읽지 않았고, Tailwind CSS 파일만 감시했습니다.
  • 그래서 base theme을 편집하거나 devup.json을 추가·삭제해도 예전 CSS, theme.d.ts, default theme이 그대로 남았습니다.

변경

  • webpack (Next.js webpack 경로 포함)
    • writeDataFiles가 inputs set을 loadDevupConfigSync에 넘기고, configFiles에 devup.json과 extends 체인 전체를 저장합니다. 존재하지 않는 파일도 포함합니다.
    • watch의 watchRun이 configFiles와 Tailwind 파일의 mtime을 stamp합니다. 없는 파일은 0으로 칩니다. 바뀌면 테마를 다시 읽습니다.
    • afterCompile은 항상 등록됩니다. 존재하는 config는 fileDependencies에, 아직 없는 config는 missingDependencies에 넣어 생성도 감지합니다.
  • Rsbuild
    • writeDataFiles가 { tailwindFiles, configFiles }를 반환합니다.
    • watchRun stamp에 config 파일이 포함됩니다.
    • JS transform이 존재하는 config는 addDependency로, 없는 config는 addMissingDependency로 등록합니다. 그래서 config가 편집·추가·삭제되면 모듈이 다시 빌드되고 테마도 다시 읽힙니다.
  • 테스트 mock의 transform context에 addMissingDependency를 추가했습니다. Rsbuild 타입에서 필수 필드입니다.

PLG-13은 이 PR에 넣지 않았습니다

Vite의 PLG-13 수정은 atom-hoist / canonical map pre-pass를 reservation의 beforeReserve로 옮기고, reservation inventory의 import graph(reservationGraph(inventory)) 위에서 계산하는 방식입니다. 이 graph는 src, app, entry closure, include를 모두 포함합니다. webpack·Rsbuild에 같은 구조를 적용하려면 다음이 따라옵니다.

  • pre-pass 시점이 apply/setup에서 run/watchRun으로 바뀝니다.
  • 두 플러그인 테스트에서 atom-hoist를 검증하는 약 110개 지점(createSharedSlotReservation이 mock되어 beforeReserve가 호출되지 않음)을 다시 써야 합니다.
  • Next의 productionPrewarmFiles throw 의미론도 다시 맞춰야 합니다.

그래서 별도 작업으로 남깁니다.

새 오류

없음.

참고

#924(테마 오류 시 빌드 실패)와 같은 writeDataFiles를 건드리므로, 둘 중 나중에 머지되는 쪽에서 충돌을 풀어야 합니다. webpack 쪽은 finally에서 configFiles를 기록하므로 #924의 rethrow와도 함께 동작합니다.

테스트 계획

  • bun test packages/webpack-plugin: 3565 pass, plugin.ts 100%
    • 새 테스트: extends한 base config가 configFiles·fileDependencies에 들어가는지, base 편집과 삭제 때 다시 로드되는지, 바뀌지 않으면 다시 읽지 않는지
    • 기존 should apply matrix: devup.json이 없을 때도 stat하고 missingDependencies에 넣도록 기대값 수정
  • bun test packages/rsbuild-plugin: 599 pass, plugin.ts 100%
    • 새 테스트: base 편집과 삭제 때 다시 로드되는지, transform이 존재하는 config는 addDependency, 삭제된 config는 addMissingDependency로 넣는지
  • tsc --noEmit (webpack, rsbuild), bunx prettier --single-quote --no-semi --check 통과
  • CI

Refs #686

🤖 Generated with Claude Code

…uild

Vite collects every file loadDevupConfig reads through extends and watches
them. webpack watched only a devup.json that existed when apply ran, and
Rsbuild did not reload devup.json in dev at all, so editing a base theme,
or adding or deleting devup.json, left the old CSS, types and default theme
in place (PLG-08).

Both now pass an inputs set to loadDevupConfig and keep the files it
names. webpack stamps them in watchRun and adds them to each compilation's
file dependencies, or its missing dependencies while one does not exist;
Rsbuild stamps them in watchRun and adds them to each transformed module's
dependencies, or missing dependencies. A changed, added or deleted config
reloads the theme.

Refs #686

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
packages/rsbuild-plugin/src/plugin.ts 100.00% <100.00%> (ø)
packages/webpack-plugin/src/plugin.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

owjs3901 and others added 2 commits November 16, 2026 08:06
Conflicts in rsbuild-plugin/src/plugin.ts:
- writeDataFiles: kept main's sequential mkdir and stylesheet write
  (the cold-start ENOENT fix) and returned this branch's
  { tailwindFiles, configFiles }.
- JS transform: kept main's hoisted excludeRegex (#914) and added this
  branch's addMissingDependency and config-file dependencies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the conflicts with #924. Rsbuild's writeDataFiles takes the
`watching` flag again and returns one flat `{ tailwindFiles, configFiles,
themeError }`, so the watcher keeps both the extends chain and the theme
error. webpack keeps `configFiles` and `themeError` side by side: the catch
records the error (or rethrows in a one-shot build) and the `finally` still
records the config chain. Both sides' tests are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901 and others added 2 commits November 17, 2026 12:00
Resolve the conflict with #960 in Rsbuild: main moved the source transform
into one handler shared with the MDX post transform. That handler now also
registers devup.json and the configs it extends, existing ones with
addDependency and missing ones with addMissingDependency, so MDX modules
reload the theme too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pick up the #983 snapshot fix so CI runs against current main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@owjs3901
owjs3901 merged commit f492dd3 into main Nov 17, 2026
27 checks passed
@owjs3901
owjs3901 deleted the fix/webpack-rsbuild-config-inputs branch November 17, 2026 07:12
owjs3901 added a commit that referenced this pull request Nov 17, 2026
Keep #947's ThemeProvider limitation next to this branch's Bun line, which
now also names the packages in include. Rsbuild transforms take both #928's
addMissingDependency and this branch's environment, so the merged tests pass
both, including #957's hook tests that predate addMissingDependency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901 added a commit that referenced this pull request Nov 17, 2026
Bring in #963 (per-session engine state) and #928. The only conflict was
the module list in libs/extractor/src/lib.rs, where main re-exports
ExtractorCaches next to this branch's vanilla_extract_calc module; both
are kept. The calc compiler adds no process-wide state, so nothing joins
the session swap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901 added a commit that referenced this pull request Nov 17, 2026
#963 keeps the CSS state of an engine session in CssState; carry the license
banner there too (stored inverted so a fresh session keeps it on), so the
test guard and session swaps restore it. #990 counts 46 validated argument
positions; setLicenseBanner.enabled makes 47. Set the banner next to #962's
project-root setup in Rsbuild and Bun, keep both README sections, and pass
#928's inputs Set in #962's webpack project-root assertion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901 added a commit that referenced this pull request Nov 17, 2026
…t test

#962 asserts loadDevupConfigSync is called with only the resolved devup.json,
but since #928 the plugin also passes the set it collects extended configs
into. Both merged, so the assertion fails on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901 added a commit that referenced this pull request Nov 17, 2026
#962 resolves the project from the bundler root: the Rsbuild and webpack
source graphs, canonical maps and resolver ids now use that root instead of
the cwd (the graph tests follow), while this branch keeps its source filters
and per-environment bundler conditions. The webpack loader caches one
resolver per root and condition set; Bun passes its project and conditions
to initialize. Also pass #928's inputs Set in #962's webpack project-root
assertion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901 added a commit that referenced this pull request Nov 17, 2026
Bring in #963 (per-session engine state), #928, #953, #990, #938, #939,
#962 and #968. No conflicts; this branch adds no process-wide state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant