Skip to content

fix(plugin-utils): report a broken devup.json instead of an empty theme - #916

Merged
owjs3901 merged 1 commit into
mainfrom
fix/devup-config-errors
Nov 15, 2026
Merged

owjs3901 merged 1 commit into
mainfrom
fix/devup-config-errors

Conversation

@owjs3901

Copy link
Copy Markdown
Contributor

Summary

#686의 PLG-19, PLG-09, PLG-10을 고칩니다.

  • PLG-19: loadDevupConfig/loadDevupConfigSync가 JSON이 아닌 devup.json을 {}로 읽어 테마 전체가 조용히 사라졌습니다. 서로를 extends하는 파일은 stack overflow가 날 때까지 재귀했습니다. 이제 둘 다 파일 경로와 고치는 방법을 담은 오류입니다.
    • JSON 객체가 아닌 설정(null, 배열, 문자열)도 오류입니다.
    • 아직 없는 extends 대상은 지금처럼 빈 설정입니다. Vite dev 서버가 이 파일을 감시하다가 생기면 읽기 때문입니다(config-input-provenance.test.ts).
    • 여러 파일이 같은 파일을 extends하는 경우(diamond)는 cycle이 아닙니다.
    • Vite, webpack, Rsbuild는 원래 설정 오류를 로그로 남기고 테마를 비웠습니다. 이 동작은 그대로입니다. Bun은 오류를 버렸는데, 이제 같이 로그로 남깁니다. Next.js Turbopack 설정은 원래 오류를 잡지 않으므로 이 오류로 실패합니다.
  • PLG-09: Vite, webpack, Rsbuild, Next.js가 theme.d.ts를 인터페이스 코드가 있을 때만 썼습니다. 그래서 토큰을 모두 지우면 예전 선언이 남았습니다. 이제 비어 있어도 항상 덮어씁니다(Bun은 이미 그랬습니다).
  • PLG-10: Rsbuild가 mkdir(cssDir)와 cssDir/devup-ui.css 쓰기를 같은 Promise.all에서 시작해, df/가 없는 첫 실행에서 ENOENT가 날 수 있었습니다. Vite처럼 디렉터리를 먼저 만든 뒤 씁니다.

#755와 겹치는 부분

#755(fix/plugin-core, 병합되지 않음)의 load-config.ts도 파싱 오류와 cycle을 오류로 바꿉니다. 이 PR은 main에서 새로 만들었고, #755 브랜치는 건드리지 않았습니다.

새로 생기는 오류

  • <file> is not valid JSON: <cause>. Fix its syntax; Devup UI does not load the theme until it parses.
  • <file> must hold a JSON object such as { "theme": {} }, not <null | an array | a string ...>.
  • devup.json `extends` form a cycle: a.json -> b.json -> a.json. Remove the `extends` entry that points back to an earlier file.

Vite, webpack, Rsbuild, Bun에서는 로그로 남고 테마가 비워집니다. Next.js Turbopack에서는 설정 단계가 실패합니다.

남는 한계

  • 플러그인들은 설정 오류가 나도 빌드를 실패시키지 않고 빈 테마로 계속합니다. #908의 테마 토큰 충돌 오류도 이 catch에 같이 잡힙니다. 프로덕션 빌드를 실패시킬지는 따로 정해야 합니다.

Test plan

  • load-config.test.ts: 잘못된 JSON(sync/async), 객체가 아닌 설정 3종, cycle(두 파일, 자기 자신), diamond. load-config.ts 커버리지 100%
  • Rsbuild: 토큰이 없을 때 빈 theme.d.ts를 쓰고, mkdir가 끝난 뒤에 devup-ui.css를 씀
  • Bun: 설정 읽기 실패를 console.error로 남김
  • webpack·Vite 기존 테스트를 항상 쓰는 theme.d.ts에 맞게 수정. rsbuild·bun·webpack·next plugin.test.ts와 vite plugin.test.ts 로컬 통과
  • CI 전체와 커버리지

Refs #686

🤖 Generated with Claude Code

`loadDevupConfig` turned a file that is not valid JSON into `{}`, so a typo
silently dropped the whole theme, and it followed `extends` cycles until the
stack overflowed. Both are now errors that name the file and how to fix it,
as is a config that is not a JSON object. An `extends` target that does not
exist yet stays an empty config: the dev servers watch it and load it once it
appears.

Vite, webpack and Rsbuild already log a config error and clear the theme; Bun
swallowed it and now logs it too.

`theme.d.ts` is written even when the theme has no tokens, so tokens removed
from devup.json leave no stale declarations behind (Vite, webpack, Rsbuild and
Next.js; Bun already did). Rsbuild creates the CSS directory before writing
into it, like Vite, so a cold start cannot lose the race with ENOENT.

Refs #686 (PLG-19, PLG-09, PLG-10)

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/bun-plugin/src/plugin.ts 100.00% <100.00%> (ø)
packages/next-plugin/src/plugin.ts 100.00% <100.00%> (ø)
packages/plugin-utils/src/load-config.ts 100.00% <100.00%> (ø)
packages/rsbuild-plugin/src/plugin.ts 100.00% <100.00%> (ø)
packages/vite-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
owjs3901 merged commit 6e45620 into main Nov 15, 2026
27 checks passed
@owjs3901
owjs3901 deleted the fix/devup-config-errors branch November 15, 2026 22:42
owjs3901 added a commit that referenced this pull request Nov 15, 2026
Conflicts:
- bun-plugin/src/plugin.ts: main (#916) kept the empty-theme fallback
  with a console.error; kept this branch's writeDataFiles, which rethrows
  on the first load and only clears the theme on a Tailwind CSS reload.
- bun-plugin/src/__tests__/plugin.test.ts: replaced main's "registers an
  empty theme" expectation with this branch's rejection tests.
- rsbuild-plugin/src/plugin.ts: kept registering the theme after reading
  the Tailwind CSS files and returning { tailwindFiles, themeError }.
- webpack-plugin/src/plugin.ts: kept clearing themeError after a
  successful load; main's #945 warnings and #951 file removal merged
  cleanly around it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901 added a commit that referenced this pull request Nov 15, 2026
Conflicts:
- rsbuild-plugin/src/plugin.ts: #916 already made writeDataFiles create
  cssDir before writing devup-ui.css (PLG-10), the same fix as this
  branch. Kept main's version; the branch no longer changes plugin.ts.
- Dropped .changepacks/changepack_log_rsbuild_cold_css_dir.json: the
  fix it announces shipped in #916, whose changepack covers it, so this
  branch now only adds hooks.test.ts.

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