Repository navigation
fix(plugins): resolve relative options against the bundler project root - #962
Merged
Merged
Conversation
Builds started from a parent directory (turbo, nx, `next build apps/web`) resolved devupFile, distDir, cssDir, the tsconfig and the webpack extraction ids against process.cwd(), so they read the wrong devup.json, wrote df into the wrong directory and changed class names. - plugin-utils: add resolveProjectPath and resolveDevupFile. A relative path resolves against the project root, and is returned unchanged when the root is the cwd. The default devup.json falls back to the cwd one, with a one-time warning, when only the cwd holds one. - webpack: normalize the path options, productionPrewarmFiles and the tsconfig against compiler.options.context at apply time, pass the root to the loader, and key loader ids, dependencies, the canonical map, numbering and reservation on it. - Rsbuild: resolve the options and tsconfig against api.context.rootPath, and build the atom-hoist graph and reservation from it. - Vite: resolve devupFile, distDir, cssDir and the tsconfig against config.root in configResolved. - Next (webpack): place cssDir and the prewarm graph under the project directory Next passes to webpack. Turbopack keeps the cwd. - Bun: use the root of Bun.build when it sets one. Refs #686 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each setup updates one project object in place, so the watcher needs no extra closure. Refs #686 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
Conflicts: - rsbuild-plugin/src/plugin.ts: imports keep both resolveDevupFile / resolveProjectPath (this branch) and setupWarning (#945). - webpack-plugin/src/__tests__/plugin.test.ts: kept both the "project root" describe and main's deleted-source tests (#951). Main's new paths now follow the project root, not the cwd: - webpack: removeFiles (#951) names deleted files relative to this.root, and the import graph warning (#945) checks this.root/src for a missing directory. Added a test for removeFiles with a context other than cwd. - Rsbuild: the import graph warning checks projectRoot/src. - Bun: the file numbering warning checks <root>/src. Vite's removeSource and Rsbuild's removeFiles use absolute ids already. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the conflict with #924 in the Bun plugin: writeDataFiles takes the located project, so devup.json, df and the CSS directory still resolve against the project root, and takes main's `reloading` flag after it. The first load rejects a theme error; the Tailwind CSS watcher reloads the same project with `reloading` set, so it reports the error and clears the theme. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the conflict with #960 in webpack: main builds the source loader rule once and reuses it for the MDX post loader. That rule now passes the project `root` to the loader, so MDX modules get root-relative extraction ids and dependencies as well. 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
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>
4 of 6 tasks
owjs3901
added a commit
that referenced
this pull request
Nov 17, 2026
Resolve against #962: the synchronous loadSourceFile now takes the BunProject, so the CommonJS runtime path extracts with the project's cssDir, importAliases and compiledPackages (the stylesheet import it drops is the one made from that cssDir) instead of module-level paths. Keep both the CommonJS and the project-root test suites. 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>
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-18: When a build was run from a parent directory, as turbo/nx do, the plugins resolved relative options against
process.cwd(). As a result they read the wrongdevup.json, wrotedfto a different location, and the webpack file ids (class names) changed. Following the maintainer's decision, this PR uses the bundler/project root as the base.cwd usages re-checked on
origin/mainand what was fixedresolveProjectPath(root, path)andresolveDevupFile(root, devupFile). When the root equals cwd they return the path exactly as given, so the common case (cwd = root) behaves byte-for-byte the same.devupFile/distDir/cssDirdefaults,productionPrewarmFiles, tsconfigjsxImportSource) toapplytime, based oncompiler.options.context. Arootoption is passed to the loader so extraction ids, dependency paths and the module resolver are root-based. The plugin's canonical map, atom-hoist, numbering, prewarm, andtoId/cwd/tsconfigPathinreservation.tsuse the same root.api.context.rootPath. The atom-hoist graph (const root = process.cwd()) andcwd/tsconfigPathinreservation.tsare also root-based now.devupFile/distDir/cssDirand tsconfig are now also resolved againstconfig.rootinconfigResolved. The reservation reads the latest paths through getters.cssDirdefault and the production prewarm graph are computed against the project directory Next passes in (_options.dir). This directory is the same as the webpackcontext. Turbopack cannot know the project directory at the config stage, so it keeps using cwd as before (documented in the README).rootfromBun.buildif present, otherwise cwd.Compatibility fallback
devupFile, and the project root has nodevup.jsonbut cwd does, the file in cwd is still used.devupFiledevupFile, it is resolved only against the root, with no fallback.Docs and changepack
devup/devup-json.changepack_log_plugin_project_root.json, which bumps plugin-utils and all 5 plugins as Patch. It states that webpack/Next webpack builds run from a parent directory may see class names change once.Overlap with other PRs
plugin.ts,setCwdModuleResolverinloader.ts,reservation.ts, and the atom-hoist graph in Rsbuildplugin.ts.process.cwd()→ root.roots) that fix(plugins): compile modern modules, resolve bundler conditions and hoist over every source root #934 intentionally added.sourceGraph/conventionalSourceRoots(process.cwd(), …),toId, andbuildStaticImportGraph(cwd, …).Test plan
plugin-utils/project-root.test.ts:devupFilesheetFile, loaderroot,productionPrewarmFiles, extraction ids, dependencies, resolverconfig.root≠ cwd (includingresolveId), root = cwd, user relative paths, fallback and warningcssDirand the route graph based on_options.dirBun.buildroot, no root, fallback and warningbun test --coverage(webpack/rsbuild/bun/next/plugin-utils): 4997 passed, all changed files at 100%plugin.ts/reservation.tsat 100%serve-coherence-prereq-native, 1 inreservation-native-boundary) fail, but they fail the same way when built fromorigin/mainsources, so it is a local environment issue.bunx tsc --noEmit -ppasses for all 6 packages, prettier check passes요약
PLG-18: turbo/nx처럼 상위 디렉터리에서 빌드를 실행하면, 플러그인이 상대 옵션을
process.cwd()기준으로 해석했습니다. 그 결과 엉뚱한devup.json을 읽고,df를 다른 위치에 쓰고, webpack 파일 id(클래스 이름)가 바뀌었습니다. 이 PR은 메인테이너 결정대로 번들러/프로젝트 루트를 기준으로 삼습니다.origin/main에서 다시 확인한 cwd 사용처와 수정 내용resolveProjectPath(root, path)와resolveDevupFile(root, devupFile)를 추가했습니다. 루트가 cwd와 같으면 경로를 받은 그대로 돌려주므로, 흔한 경우(cwd = root)의 동작은 바이트 단위로 같습니다.devupFile/distDir/cssDir기본값,productionPrewarmFiles, tsconfigjsxImportSource)를apply시점의compiler.options.context기준으로 옮겼습니다. 로더에root옵션을 넘겨 추출 id, 의존성 경로, module resolver를 루트 기준으로 만듭니다. 플러그인의 canonical map, atom-hoist, numbering, prewarm 그리고reservation.ts의toId/cwd/tsconfigPath도 같은 루트를 씁니다.api.context.rootPath기준으로 해석합니다. atom-hoist 그래프(const root = process.cwd())와reservation.ts의cwd/tsconfigPath도 루트 기준으로 바꿨습니다.devupFile/distDir/cssDir와 tsconfig도configResolved에서config.root기준으로 해석합니다. reservation은 getter로 최신 경로를 읽습니다.cssDir기본값과 production prewarm 그래프를 Next가 넘겨주는 프로젝트 디렉터리(_options.dir) 기준으로 계산합니다. 이 디렉터리는 webpackcontext와 같습니다. Turbopack은 config 단계에서 프로젝트 디렉터리를 알 수 없어서 기존처럼 cwd를 씁니다(README에 적어 두었습니다).Bun.build에root가 있으면 그 경로를, 없으면 cwd를 씁니다.호환 fallback
devupFile을 사용자가 지정하지 않았고, 프로젝트 루트에는devup.json이 없지만 cwd에는 있으면 cwd의 파일을 계속 씁니다.devupFile을 지정하라는 해결 방법devupFile을 지정한 경우에는 fallback 없이 루트 기준으로만 해석합니다.문서와 changepack
devup/devup-json에 "Project root" 설명을 추가했습니다.changepack_log_plugin_project_root.json하나이고, plugin-utils와 5개 플러그인을 모두 Patch로 올립니다. 상위 디렉터리에서 실행한 webpack/Next webpack 빌드는 클래스 이름이 한 번 바뀔 수 있다는 점을 명시했습니다.다른 PR과 겹치는 부분
plugin.ts의 prewarm/canonical-map 블록과loader.ts의setCwdModuleResolver,reservation.ts, Rsbuildplugin.ts의 atom-hoist 그래프입니다.process.cwd()→ 루트로 바꾸는 한 줄 수준으로만 고쳤습니다.roots)은 건드리지 않았습니다.sourceGraph/conventionalSourceRoots(process.cwd(), …),toId,buildStaticImportGraph(cwd, …)에서 cwd 자리에 루트를 넣으면 됩니다.테스트 계획
plugin-utils/project-root.test.ts에서 확인한 경우:devupFile에는 fallback 없음sheetFile, 로더root,productionPrewarmFiles, 추출 id, 의존성, resolverconfig.root≠ cwd(resolveId포함), root = cwd, 사용자 상대 경로, fallback과 경고_options.dir기준 prod/devcssDir와 라우트 그래프Bun.buildroot, root 없음, fallback과 경고bun test --coverage(webpack/rsbuild/bun/next/plugin-utils): 4997개 통과, 변경한 파일은 모두 100%plugin.ts/reservation.ts는 100%serve-coherence-prereq-native2개,reservation-native-boundary1개)는 실패하는데,origin/main소스로 빌드해도 똑같이 실패하므로 로컬 환경 문제입니다.bunx tsc --noEmit -p통과, prettier 검사 통과Refs #686
🤖 Generated with Claude Code