Repository navigation
perf(bun-plugin): write the runtime sheet only when a module changes it - #942
Merged
Merged
Conversation
Under the Bun runtime every compiled module serialized the whole sheet and wrote it synchronously, even when it added no style. The extraction output already carries the serialized base sheet exactly when the module changed it (singleCss), so write that and skip the rest. Writes stay synchronous: the runtime reads the sheet right after the import. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
This was referenced Nov 15, 2026
owjs3901
added a commit
that referenced
this pull request
Nov 15, 2026
Conflicts: - webpack, Rsbuild and Vite plugin.ts imports: kept main's setupWarning (#945) next to this branch's SOURCE_FILE_REGEX. - Rsbuild transform: kept this branch's `environment` parameter, with main's hoisted excludeRegex (#914) in place of the per-call createNodeModulesExcludeRegex(include). - Vite transform: kept this branch's SOURCE_FILE_REGEX check, with main's hoisted excludeRegex. - Bun loadSourceFile: kept main's runtime sheet write, which writes only the sheet a module changed (#942), and this branch's withDependencyImports return. Dropped from this branch in favor of main: the per-call exclude regex in the Rsbuild and Vite transforms (#914) and the unconditional runtime sheet write in Bun (#942). Also updated the "Compiled Files" section that #949 added to the Bun README: `.mts`/`.cts` are compiled, and `Bun.build` compiles the project's own `.js`/`.cjs` outside node_modules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
12 of 14 tasks
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
PLG-24 재검증 결과입니다.
Bun.build경로: main에서 이미 고쳐져 있습니다. CSS는onLoad의defer()뒤에 한 번 만들어 돌려주고 디스크에 쓰지 않습니다.compiler.getCss(null, false)로 시트 전체를 직렬화한 뒤writeFileSync로 썼습니다. 스타일을 하나도 더하지 않는 모듈도 마찬가지라 N개 모듈에서 직렬화와 동기 I/O가 O(N)번씩 일어났습니다.변경
singleCss가 항상true라, 추출 결과의Output.css는 이 모듈이 시트를 바꿨을 때만 직렬화된 base 시트를 담습니다(libs/binding/src/output.rs:collected나default_collected가 없으면None). 이 값은getCss(null, false)와 같은create_css(None, false)입니다.code.css가 있을 때만 그 문자열을 씁니다. 시트를 바꾸지 않는 모듈은 직렬화도 쓰기도 하지 않습니다.겹치는 PR
packages/bun-plugin/src/plugin.ts의loadSourceFile주변을 바꿉니다. 이 PR은writeFileSync블록만 바꾸므로 충돌이 나도 해결이 간단합니다.Test plan
bun test packages/bun-plugin/src/__tests__/plugin.test.ts(25 pass)getCss(null, false)와 같음, 같은 파일 재로드와 이미 있는 스타일만 쓰는 다른 파일은 쓰지 않음bun test packages/bun-plugin: 실패 4개는 이 변경 전 main에서도 로컬에서 똑같이 실패합니다(실제 빌드 root 비교 테스트, 로컬 native/WASM 빌드 문제)bunx tsc --noEmit -p packages/bun-plugin, prettierRefs #686
🤖 Generated with Claude Code