Repository navigation
bundler-plugin-core: .env.bugsee-build-plugin token + esbuild/Rspack source-map upload - #196
Conversation
…plugin Lookup order for BUGSEE_* settings: plugin option, process environment, then the nearest .env.bugsee-build-plugin at or above the bundler's project directory. The file only fills gaps (never overrides the environment); a missing or malformed file never fails the build. Closes #182. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WeiJxSMPCqs6TBDKuGw9TG
…pack plugins bugseeEsbuildPlugin (onEnd) and bugseeRspackPlugin (afterEmit) now reuse runPluginUpload with the same SRI guard as the Vite/Rollup (writeBundle) and webpack (afterEmit) hooks; esbuild also turns sourcemap on when unset. Proven with real esbuild and @rspack/core builds plus the real bugsee-cli. Docs no longer claim Angular/Rspack coverage that was not true: Angular's builder does not accept esbuild plugins, so a post-build recipe (sourcemaps inject, then debug-files upload) is documented. Closes #184. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WeiJxSMPCqs6TBDKuGw9TG
Pre-merge checks:
|
|
Claude finished @krassx's task in 1m 37s —— View job Deep review of PR #196I read the diff against the surrounding code ( Checked and found correct
Findings (3, posted inline)
Summary
|
…le, emit external maps - P1: builds sharing one outdir (tsup esm+cjs) no longer lose the second build's maps. Uploads for one outdir now run one after another, and the delete step removes only the maps that existed when the upload started. Covered by a real two-build test against a slow collector. - .env.bugsee-build-plugin: search stops at the repo/workspace root and never reads in or above the home directory; only token, version and build are read from it (never endpoint / CLI path); a blank variable counts as unset; a found-but-unusable file produces one notice (never its contents). - esbuild: sourcemap 'external' when unset (not true, which left a dangling sourceMappingURL); an explicit false is left alone; an outfile build says the whole directory is uploaded. - Tests are hermetic against a developer's real env file; the real-build tests skip locally without the CLI binary (required in CI); Rspack SRI-refusal and compile-error builds are tested. - Docs: SRI/--allow-sri wording, Deno references, BUGSEE_CLI_PATH is environment-only. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WeiJxSMPCqs6TBDKuGw9TG
|
Claude finished @krassx's task in 50s —— View job Re-review of PR #196 after
|
| Earlier finding | Status |
|---|---|
P3: env-file.ts walk had no boundary, and BUGSEE_CLI_PATH or BUGSEE_ENDPOINT could come from the file |
Fixed. The walk stops at the nearest .git or pnpm-workspace.yaml. It never reads in or above the home directory. Only token, version and build are read (FILE_KEYS). I checked atOrAbove for a project below home, for home itself and for a parent of home, and the results are correct. |
P3: a bare outfile makes outDir the project root, and the whole tree is stamped and the maps deleted |
Mitigated, not fixed. There is now a once-only notice (plugin.ts ~L462). The delete step is also limited to the maps that existed when the upload started (uploadedSet). Unrelated *.map files in that directory are still stamped and deleted, and the notice says so. I'd accept that as documented behaviour. |
P2: no production or mode gate on the esbuild onEnd or Rspack afterEmit upload |
Still open. The inline comment on plugin.ts still applies. runPluginUpload has no gate. The bundler context only reaches registerJsBuild. Rspack mode: 'development' and esbuild watch rebuilds therefore still upload and delete the .map files. The new sourcemap: 'external' default makes this easier to hit, because esbuild now emits maps whenever a token resolves. The unconditional dev upload already existed for webpack. Please either gate on the bundler's production signal or add an explicit opt-in. If neither, state in the docs that watch and dev builds upload and delete maps. |
New code in this commit: no new real findings
serialUploadchains peroutDir. A failed earlier run does not block the next, becausetailswallows the rejection. The map entry is released only if it is still the current tail, so there is no leak or lost ordering. TherunsByDirjoin inrunPluginUploadcannot swallow the second build, because the slot is freed before the next run starts.- Deleting only the
uploadedSetsnapshot is the safe direction: maps written after the snapshot are kept, not deleted unsent. If the listing fails,.catch(() => undefined)falls back to deleting every map found. That matches the old behaviour. mergeBuildPluginEnvnow treats a blank environment variable as unset. This differs from the PR description ("never overrides, even an empty value"), so please update the description to match.sourcemap: 'external'only when unset avoids the danglingsourceMappingURLcomment. A user-setsourcemap: truestill gets that comment withdeleteMapson. That is the user's explicit choice and is not new.
Summary
- Overall risk: Low to Medium. The env-file and concurrency fixes look sound. The remaining risk is the behavioural dev-time upload and delete.
- Merge recommendation: Approve once the P2 mode gate is added or explicitly documented as accepted. Nothing else blocks.
- Most important to fix:
- Gate the esbuild and Rspack uploads on the production signal, or add an opt-in.
- Update the PR description for the blank-variable rule.
- Positives:
- The env-file module is now much better bounded, and its notice never leaks a value.
- The serialized upload fix comes with a real two-build test against a slow collector.
- Real esbuild and Rspack builds with the real CLI remain a strong integration check.
· branchfeat/plugin-env-token-and-esbuild-rspack-upload
…roject-root outfile Review findings on #196: esbuild/Rspack dev and watch builds no longer upload and delete the local maps unless uploadInDevelopment is set (Rspack by mode, esbuild by NODE_ENV=development); a bare outfile in the project directory is refused with a notice instead of walking the whole project. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WeiJxSMPCqs6TBDKuGw9TG
|
Claude finished @krassx's task in 57s —— View job Re-review of PR #196 after
|
| Earlier finding | Status |
|---|---|
P2: no production/mode gate on esbuild onEnd and Rspack afterEmit |
Fixed, with one gap. The uploadInDevelopment option and the skipDevelopment gate cover both hooks. The gate is correctly skipped when the plugin is disabled, and the notice is deduplicated. The Rspack gate also catches mode: 'none', which is over-broad (finding 1). |
P3: a bare outfile makes the whole project the output dir |
Fixed for the exact case. A project-root outfile is now refused with a notice. An outfile in an ancestor of the project is not covered (finding 3, point 3). |
| PR description: blank-variable rule | Not checked in this push. |
New findings (3, posted inline, all P3)
| Sev | Location | Summary |
|---|---|---|
| P3 | plugin.ts:528 |
Rspack mode: 'none' is skipped as a "development build". The docs and the option's JSDoc say only development is skipped. A release build using none silently stops uploading. |
| P3 | plugin.ts:464 |
The esbuild config hook still forces sourcemap: 'external' for dev builds that the gate then won't upload. Dev rebuilds pay for maps that no sourceMappingURL references. |
| P3 | plugin.ts:480-503 |
(a) The "uploaded per DIRECTORY" notice fires before the dev and root-outfile refusals, so users get contradictory notices. (b) The esbuild tests read NODE_ENV from the shell, so a developer with NODE_ENV=development exported fails them, which conflicts with the "hermetic" claim. (c) The root-outfile guard misses an outfile in an ancestor directory. |
Summary
- Overall risk: Low. The hook wiring, the serialized upload and the env-file bounds all look sound. The remaining issues are behavioural edges and test hygiene.
- Merge recommendation: Approve. Nothing blocks. I'd fix the
mode: 'none'case before release, because it silently drops symbol uploads for a real production setup. - Most important to fix:
- Limit the Rspack skip to
mode === 'development', or document and testnone. - Stub
NODE_ENVintest-setup.ts. - Apply the dev condition to the esbuild forced
sourcemap, and move the per-directory notice after the refusals.
- Limit the Rspack skip to
- Positives:
- The gate is opt-in reversible via
uploadInDevelopment, and the notice tells the user how to enable it. - Both the gate and the refusal come with tests, including the notice-once and disabled-plugin cases.
- The code comments and docs state honestly that esbuild has no mode signal and that only
NODE_ENV=developmentmarks a dev build.
· branchfeat/plugin-env-token-and-esbuild-rspack-upload
- The gate is opt-in reversible via
…earer outfile notices Review follow-ups on #196: only Rspack mode development is skipped (none uploads); esbuild does not force maps on for a development build; an outfile in or above the project directory is refused with a single notice; the per-directory notice is emitted only when an upload follows; tests pin NODE_ENV. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WeiJxSMPCqs6TBDKuGw9TG
|
Claude finished @krassx's task in 32s —— View job Re-review of PR #196 after
|
| Earlier finding | Status |
|---|---|
P3: Rspack mode: 'none' skipped as a "development build" |
Fixed. The gate now passes compiler.options.mode !== 'development' (plugin.ts:534). none, production and an unset mode all upload. The docs and a new test (mode: 'none' still uploads) match. |
P3: esbuild config hook forced sourcemap: 'external' on dev builds that were then not uploaded |
Fixed. The condition now includes resolved.uploadInDevelopment || resolved.nodeEnv !== 'development' (plugin.ts:468). A test covers both the default and the opt-in. |
| P3: contradictory notices (per-directory notice before the dev and root-outfile refusals) | Fixed. The per-directory notice is now the last thing emitted, only when an upload follows (plugin.ts:498). Tests assert exactly one outfile notice for the ancestor case and none for the dev case. |
P3: NODE_ENV read from the shell, so tests were not hermetic |
Fixed. test-setup.ts pins NODE_ENV=test in a beforeEach via vi.stubEnv. The two tests that set process.env.NODE_ENV by hand restore it in finally. The saved value is 'test', not undefined, so there is no "undefined" string leak. |
P3: root-outfile guard missed an outfile in an ancestor of the project |
Fixed. The guard uses relative(outDir, project) and refuses when the result is empty or does not start with .. and is not absolute. That covers outDir equal to or an ancestor of the project. It also handles Windows cross-drive results. A sibling directory (/proj/app2 for project /proj/app) still uploads, and a test pins that. |
| PR description: blank-variable rule | Fixed. The description, the env-file.ts header, the README and the docs all say a blank variable counts as unset. |
New findings in this commit: none. I checked the following and found them correct:
skipDevelopmentreturns early when the plugin is disabled, so a disabled plugin gets no development notice and no refusal.- A dev build with
uploadInDevelopment: truefalls through to the outfile checks, as it should. - An unset
NODE_ENVcounts as non-development, so esbuild uploads. The docs state this limit openly. - The
startsWith('..')test would also match a directory literally named..foo. That is not worth acting on.
Summary
- Overall risk: Low. The hook wiring, the serialized per-directory upload, the env-file bounds and the dev gate all look sound.
- Merge recommendation: Approve. Every finding from the earlier rounds is addressed, and nothing new surfaced.
- Most important issues to fix: none outstanding. Because I could not run the suite, rely on CI for the real-build tests (esbuild,
@rspack/core@2.2.9and the real CLI). - Positives:
- Each follow-up arrived with a test that pins the behaviour, including the notice counts.
- The dev gate stays reversible through
uploadInDevelopment, and the notice tells users how to enable it. - The docs describe the esbuild limit (only
NODE_ENV=developmentcounts as a dev build) rather than hiding it.
· branchfeat/plugin-env-token-and-esbuild-rspack-upload
…uploads, env-file notices Round-2 review of #196: - esbuild write:false (tsup always sets it) now says why nothing was uploaded; docs state tsup is not covered and give the onSuccess recipe. Real tsup build tested. - Concurrent esbuild builds: a run waits until no build of the directory is in flight and a failure that coincides with another build starting is retried (max 3), fixing the inject/upload window. Real test with a slow-inject CLI wrapper; three-build test for the queue tail guard. - outdir '.' (project dir or above) refused like a bare outfile; sourcemap:false explained by a notice. - env file: empty values and a file in the home directory (project dir == home) now produce notices. - whitespace-only BUGSEE_APP_TOKEN no longer enables the plugin. - BUGSEE_REQUIRE_CLI declared in turbo.json for test and test:coverage; docs: stale sourcemap text, Deno removed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WeiJxSMPCqs6TBDKuGw9TG
|
Claude finished @krassx's task in 1m 4s —— View job Re-review of PR #196 after
|
| Sev | Location | Summary |
|---|---|---|
| P3 | plugin.ts:561 |
The new write: false notice is not gated on resolved.enabled. A tsup user with no token (plugin disabled) gets a "nothing was uploaded, run the post-build step" warning on every build. The sibling notices are gated, and the test only covers the enabled case. |
Checked and found correct
- Idle wait and retry loop (
uploadWhenSettled):- There is no deadlock for concurrent same-directory builds. Each
onEnddecrementsinflightbefore it awaits the queued upload, so the waiting build never depends on the build it is waiting for. - The wait is capped at 60s, so a leaked
inflightcount only delays an upload, it never blocks one. - The retry is bounded at 3 attempts.
- The final failure goes through the user's configured
failOnError/onError. - Swapping
onErrorfor a capture does not conflict with therunsByDirjoin, becauseserialUploadkeeps runs of one directory sequential.
- There is no deadlock for concurrent same-directory builds. Each
- Project-directory refusal:
relative(outDir, project)correctly refusesoutDirequal to or above the project, andoutdir: '.'is now covered.dist, a sibling directory, and a monorepo../../diststill upload. env-file.ts:- The home-directory notice fires only when the project directory itself is home and the file exists. It never reads the file and never prints a value.
- A file with only blank values now gets a notice instead of silently disabling the plugin.
- A file containing only a non-allowed key such as
BUGSEE_ENDPOINTis not "usable", becauseparseEnvFilealready filters toFILE_KEYS.
- Whitespace-only
BUGSEE_APP_TOKEN: now treated as no token, andresolve.test.tscovers it. An explicit whitespace-onlyappTokenoption disables the plugin rather than falling back to the environment. That matches "option wins" and I would not change it. defaultUploadErrorHandler: extracting it keeps the defaultconsole.warnbehaviour unchanged.
Summary
- Overall risk: Low. The concurrency fix is sound and bounded. The only new issue is one misplaced notice.
- Merge recommendation: Approve. The P3 can be fixed in this PR with a one-line guard and a test, or taken as a follow-up.
- Most important issue to fix: Gate the
write: falsenotice onresolved.enabledand add a disabled-plugin test (plugin.ts:561). CI is the authority for the real esbuild, Rspack, tsup and slow-inject tests, because I could not run them. - Positives:
- The idle-wait and retry design is documented in comments with its reasoning.
- It comes with a real slow-inject test and a three-build test for the queue tail guard.
- The new notices explain what to do next (the tsup
onSuccessrecipe and theoutdirguidance). - The env-file notices never echo file contents.
· branchfeat/plugin-env-token-and-esbuild-rspack-upload
…abled plugin Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WeiJxSMPCqs6TBDKuGw9TG
|
Claude finished @krassx's task in 17s —— View job Re-review of PR #196 after
|
| Earlier finding | Status |
|---|---|
P3: the write: false notice fired for a disabled (token-less) plugin (plugin.ts:561) |
Fixed. The notice is now inside if (resolved.enabled), and the hook still returns early for write: false either way, so nothing is uploaded. The new test write:false says nothing for a disabled or token-less plugin asserts notices is empty. |
New findings: none. The change is a minimal guard plus a test that pins it. I checked that the early return stays outside the enabled check, so a disabled plugin never falls through to the upload path.
One thing to fix outside the code: the PR description doesn't match this branch. It describes the process.sourceMapsEnabled / debug-ID verifier work (createStampedBundleVerifier, @bugsee/node launch wiring, "Fixes #185"). None of the 18 changed files touch @bugsee/node or core's applyDebugIds. The diff is the .env.bugsee-build-plugin token loader plus the esbuild and Rspack source-map upload. As written, the description would close #185 on merge without that change being in this PR. Please update the title, body and issue link to match the actual change. The earlier review rounds also asked for the blank-variable rule to be documented, and that is now correct in the code and docs.
Summary
- Overall risk: Low. The hook wiring, serialized per-directory upload, env-file bounds, dev gate and notices have all been reviewed across the rounds, and every earlier finding is addressed.
- Merge recommendation: Approve. Fix the PR description (and the
Fixes #185link) before merging, and rely on CI for the real esbuild, Rspack, tsup and slow-inject tests, which I could not run. - Most important issues to fix: only the stale PR description.
- Positives:
- Every review round came back with a fix and a test that pins the behaviour, including the notice counts and the disabled-plugin cases.
- The dev gate is reversible via
uploadInDevelopment, and the docs state its esbuild limit openly. - The upload queue and retry design is documented in comments and covered by slow-collector tests.
· branchfeat/plugin-env-token-and-esbuild-rspack-upload
…, no nested-build stall Round-3 review of #196: - failOnError reaches uploadSourcemaps again (it decides --allow-empty): the retry now wraps only that step instead of forcing failOnError false, so an esbuild build with no maps fails under failOnError; registration is not retried. - The first attempt never waits and a disabled plugin queues nothing, so a build nested in another no longer stalls for the idle cap; a retry waits at most 5s (upload-tuning.ts, a test seam). - Dev-skip wording, Rspack devtool notice, package-root outfile guard, segment-aware parent checks (also env-file), tsup recipe fixed, tsup declared as devDependency, deterministic race test, stronger retry tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WeiJxSMPCqs6TBDKuGw9TG
|
Claude finished @krassx's task in 1m 18s —— View job Re-review of PR #196 after
|
…, retry for in-flight builds Round-4 review of #196: - A run whose build began before an earlier run of the same directory swept (uploaded and deleted) maps is allowed an empty directory (allowEmpty on uploadSourcemaps), so dual-format builds no longer fail under failOnError; a lone map-less build still does. - Retry predicate also covers a build already in flight when the attempt began. - Package-root outfile refusal narrowed (named package.json, or next to src/node_modules); dist/cjs markers allowed. - Rspack devtool notice judged on the resolved default. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WeiJxSMPCqs6TBDKuGw9TG
|
Claude finished @krassx's task in 40s —— View job Re-review of PR #196 after
|
…n files Replace the per-directory serialise/retry/sweep machinery with per-build file lists: the plugin asks esbuild for the metafile and injects, uploads and deletes exactly the build's own outputs (200 paths per CLI call). A build only touches files it wrote, so there is no cross-build coordination, no per-directory state and no nested-build wait. - failOnError for esbuild: a build with no .map among its own outputs fails (judged on that build alone). - orchestrate: files option; the directory-run delete snapshot now fails closed. - registration reads only the build's own bundles. - removed serialUpload, activity tracking, retries, upload-tuning, sweep/allowEmpty, package-root and project-dir guards; docs and tests rewritten around real esbuild/tsup/Rspack builds. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WeiJxSMPCqs6TBDKuGw9TG
|
Claude finished @krassx's task in 1m 21s —— View job Re-review of PR #196 after
|
| Sev | Location | Summary |
|---|---|---|
| P3 | orchestrate.ts:248 |
Inject batches are [...scripts, ...maps] cut at 200. Past 200 outputs, a bundle and its map land in different inject calls. No test asserts that script and map debug-IDs match. |
Minor observations (no action required)
- Unreachable or misleading cases: if
result.metafileis ever missing (another plugin or wrapper overriding the option), the build reads as "emitted no .map files". UnderfailOnErrorthat fails with a misleading message. A check that the metafile is present, with its own message, would make this clear. - Duplicate notice: with an explicit
sourcemap: false, theconfighook says so, andonEndthen says "emitted no .map files" as well. UnderfailOnErrorit throws instead. This is harmless but redundant. - SRI scan scope: the SRI scan in files mode still walks the whole
outDir, but only the build's own files are stamped. For a bareoutfilein the project directory that walk covers the project tree, down to 6 levels, skipping onlynode_modules,.gitand test directories. It only refuses when some HTML pins a local.jsin that directory, and such a pin would be a real hazard only if the script is one of the build's own. Scoping the scan tofiles.scriptswould make that exact. - Stale PR description: it still describes the removed design (per-directory serialisation, retry of at most 3,
allowEmptysweeps, the project-root and package-rootoutfilerefusals, the "Round 3" and "Round 4" sections, and theuploadTuningmention). Please update it to describe the metafile-based approach before merging. The lockfile note abouttinyglobbyandpicomatchfrom the last round is still not reflected.
Summary
- Overall risk: Low. Removing the per-directory coordination makes the upload path easier to reason about, and the delete path now fails closed.
- Merge recommendation: Approve. Either confirm the CLI handles a lone map in a split batch or pair bundles with their maps, and update the PR description.
- Most important issues to fix:
- Keep each script and its map in the same inject batch, and add an ID-match assertion to the >200-outputs real-build test (
orchestrate.ts:248). - Rewrite the PR description for the new design.
- Keep each script and its map in the same inject batch, and add an ID-match assertion to the >200-outputs real-build test (
- Positives:
- The upload, delete and registration steps all work on the same explicit file list, which is much easier to reason about than the previous retry and sweep logic.
- Deleting only after every batch has uploaded is pinned by a test, as is failing closed when the snapshot can't be taken.
- Real esbuild, tsup and Rspack builds with the real CLI remain the main integration check.
· branchfeat/plugin-env-token-and-esbuild-rspack-upload
…esheet-only builds are a no-op Round-6 review of #196: the CLI skips a .css.map when scanning a directory but fails the whole call (exit 11) when one is named as an explicit path. The esbuild file list now keeps only the maps of the build's own scripts and deletes .css.map files with them after a confirmed upload; a build with no scripts is a quiet no-op, a build with scripts but no script maps still fails under failOnError. Real CSS builds (splitting + hashed names, css-only, watch) and unit cases added. Docs: SRI scan wording; comment on batch splitting. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WeiJxSMPCqs6TBDKuGw9TG
|
Claude finished @krassx's task in 52s —— View job Re-review of PR #196 after
|
| Earlier finding | Status |
|---|---|
P3, orchestrate.ts:255: a bundle and its map can land in different 200-path inject batches |
Answered with a comment, not a test. The comment says the debug-id comes from the bundle content, so both sides stamp the same id, "measured with 250 entries". I can't verify that claim here. The >200 real-build test (plugin.real-build.test.ts:469) still only checks that every .js is stamped, that no .map is left on disk, and that there were at least 2 requests. It never compares a script's id with its map's id. I'd keep the unproven claim out of a comment, or add one assertion on the ids. That is optional, not a blocker. |
| Stale PR description (lockfile note, design description) | The description now matches the metafile design. The lockfile sentence "no version of those packages changed" is still not accurate for the tinyglobby and picomatch re-resolution I noted before. This is cosmetic. |
Checked in this commit and found correct
- Map filter: a map is kept only when its name minus
.mapis one of the build's own scripts..css.mapand any orphan map are never given to the CLI, which matches the stated exit 11 on a stylesheet map named as an explicit path. - Delete step: in files mode it deletes
[...maps, ...stylesheetMaps], only after every batch has uploaded. A failed upload still leaves all of them on disk. A directory run (Rspack, webpack) still deletes its snapshot, and that path is unchanged. - Failure rule: a build that has scripts but no script maps still fails under
failOnError. The check runs after the dev gate and the!enabledreturn. - Types:
stylesheetMapsis optional on bothUploadSourcemapsOptions.filesandrunPluginUpload, so existing callers are unaffected.
New finding (1, posted inline, P3)
| Sev | Location | Summary |
|---|---|---|
| P3 | plugin.ts:521 |
The new "stylesheet-only build" early return is silent and runs before the failOnError check. A missing metafile, or bundles that don't match /\.[cm]?js$/, now returns quietly under failOnError. Previously it threw. This needs an unusual setup and I did not reproduce it. |
Summary
- Overall risk: Low. The upload, delete and registration steps all work on the same explicit file list, and this commit narrows that list safely.
- Merge recommendation: Approve. The one new finding is a narrow edge case that can be taken as a follow-up.
- Most important issues to fix:
- Make "no scripts" fail loudly under
failOnErrorwhen the metafile is absent (plugin.ts:521). - Optionally, assert that a script's id equals its map's id in the 250-output real-build test, instead of relying on the comment.
- Make "no scripts" fail loudly under
- Positives:
- Keeping stylesheet maps away from the CLI and deleting them only after a confirmed upload is a safe default.
- The commit comes with unit tests and real CSS builds (splitting, hashed names, CSS-only, watch).
- The docs describe the no-op and the read-only SRI scan exception accurately.
· branchfeat/plugin-env-token-and-esbuild-rspack-upload
…ust not pass silently A result with no metafile (another plugin turned it off) or maps for outputs inject does not stamp (outExtension .bundle.jsx) now fail under failOnError and are a notice otherwise; a stylesheet-only build stays a quiet no-op. Real-build tests for both shapes; design and usage docs updated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WeiJxSMPCqs6TBDKuGw9TG
|
Claude finished @krassx's task in 31s —— View job Re-review of PR #196 after
|
| Earlier finding | Status |
|---|---|
P3, plugin.ts:521: the stylesheet-only early return was silent and ran before the failOnError check, so a missing metafile or non-.js bundles passed quietly |
Fixed. A missing result.metafile now goes through problem(...), which throws under failOnError and otherwise emits one notice. Maps whose bundle isn't a recognised script (strayMaps, for example outExtension .bundle.jsx) get the same handling. A metafile-present build with no scripts and no stray maps stays a quiet no-op, and a test pins that it is quiet even under failOnError. |
P3, orchestrate.ts:255: no assertion that a script's debug-id matches its map's id past 200 outputs |
Still only covered by the code comment and the author's measurement. This is optional and was never a blocker. |
Checked in this commit and found correct
- Ordering: the metafile and stray-map checks run after the
write: falsebranch, the dev gate and the!resolved.enabledreturn. A disabled plugin or a dev build gets no new notice and no new failure. problemunderfailOnError: a throw insideonEndsurfaces as a build error. WithoutfailOnErrorit goes throughsay, which dedupes, so a watch rebuild repeats no notice. The test checks one notice after two ends..css.maphandling:strayMapsexcludes.css.map, so a stylesheet-only build does not trip the new notice, and the existing no-op test still holds.- Upload call: the destructure
{ strayMaps: _stray, ...own }keepsstrayMapsout of thefilesthatrunPluginUploadand the delete step receive. The upload and delete behaviour is unchanged. - Tests: the unit tests cover the missing-metafile and
.bundle.jsxcases underfailOnErrorand as notices. The real-build tests add the metafile-off plugin andoutExtensionshapes.
New findings in this commit: none that I'd report.
Minor observations (no action required)
- The stray-map check runs only when the build has no scripts at all. A build with some scripts and a stray map would not mention the stray map. esbuild's
outExtensionapplies to every JS output of a build, so I could not construct a realistic mixed case. - The lockfile sentence in the PR description ("No version of those packages changed") is still not accurate for the
tinyglobby/picomatchre-resolution noted in an earlier round. This is cosmetic.
Summary
- Overall risk: Low. Every build outcome is now judged on the build's own metafile. The "JS output the plugin cannot upload" cases fail loudly under
failOnErrorand otherwise give one notice. Deletion still happens only after a confirmed upload, and only for the build's own files. - Merge recommendation: Approve. Nothing outstanding blocks merging. Rely on CI for the real esbuild, Rspack, tsup and 250-output builds, which I could not run.
- Most important issues to fix: none. Optionally, correct the lockfile sentence in the description and add a debug-id equality assertion to the 250-output real-build test.
- Positives:
- The previous review's
failOnErrorgap is closed with a single sharedproblemhelper, so the throw-or-notice rule lives in one place. - The quiet no-op for stylesheet-only builds is preserved and tested.
- Each new failure mode ships with a unit test and a real-build test, and the docs were updated together with the code.
· branchfeat/plugin-env-token-and-esbuild-rspack-upload
- The previous review's
Closes #182 and #184.
#182 -
.env.bugsee-build-pluginprocess.envis never written.BUGSEE_APP_TOKEN/BUGSEE_APP_VERSION/BUGSEE_APP_BUILDare read from it.BUGSEE_ENDPOINTandBUGSEE_CLI_PATHare environment-only: a file that could set them could redirect uploads (with the token) or choose the binary..gitorpnpm-workspace.yaml); with no root only the project dir; never in or above the home directory (segment-aware).onNotice, never its contents.#184 - esbuild and Rspack upload
metafile: true, takes the build's own bundles and maps fromresult.metafileinonEnd, runssourcemaps inject <those files>thendebug-files upload <those maps>(200 paths per CLI call) and deletes exactly those maps after a confirmed upload. Invariants: a build only touches files it wrote, so nothing is deleted without being uploaded, nothing is uploaded under another build's (or another plugin instance's) options, nested and concurrent builds never wait for each other, and there is no per-directory state (watch mode needs none). Build registration reads only the build's own bundles. UnderfailOnErrora build with no.mapamong its own outputs fails, judged on that build alone..css.maphas no debug-id and fails the whole call);.css.mapfiles are deleted with the rest after a confirmed upload, and a stylesheet-only build is a quiet no-op.injectdoes not stamp (outExtension: '.bundle.jsx') fail underfailOnErrorand are a notice otherwise.sourcemap: 'external'only when unset (an explicitfalseis left alone and explained).write: false, so nothing is on disk whenonEndruns. The plugin says so throughonNotice(once, only when enabled); docs give a CLIonSuccessrecipe. Tested with a real tsup build.afterEmit(webpack-style, directory-wide, with the SRI guard). Its delete step is limited to the maps that existed when the upload started and now fails closed: if they cannot be listed, nothing is deleted and it is reported (previously it fell back to deleting every map found). A RspackMultiCompilersharing oneoutput.pathkeeps the webpack join behaviour.uploadInDevelopment(default false). Rspack skips onlymode: 'development'; esbuild only whenNODE_ENV=development(and then does not force maps on). Rspack withdevtooloff gets a notice.--allow-sri; Deno references removed).BUGSEE_APP_TOKENno longer enables the plugin.Tests
Unit + hook wiring, plus real esbuild,
@rspack/core@2.2.9and tsup builds with the real bugsee-cli: esm+cjs into one outdir underfailOnErrortrue/false with a fast and a delayed collector; foreign files appearing between inject and upload stay untouched; two plugin instances over one outdir (own options,deleteMaps:falseper instance); external + inline builds together underfailOnError(the inline one fails); nested sub-build with and without a token; watch rebuilds; a symlinked outdir; 250 outputs batched; CSS imports (splitting + hashed names, css-only, watch); Rspack SRI refusal and compile error. Real-build tests skip locally if the CLI binary is absent and are required whenCIorBUGSEE_REQUIRE_CLIis set (declared inturbo.json). Tests are hermetic against a developer's env file andNODE_ENV.Lockfile
New devDeps in
bundler-plugin-core:@rspack/core@2.2.9,esbuild,tsup@^9.0.0(already in the root).pnpm-lock.yamlalso changes because@rspack/coreis an optional peer ofunplugin,html-webpack-pluginandnitropack, so their peer-suffixed lock keys gained(@rspack/core@2.2.9). No version of those packages changed; the only transitive version movement is thepicomatchused bytinyglobby/fdir(4.0.4 to 4.0.7).🤖 Generated with Claude Code
https://claude.ai/code/session_01WeiJxSMPCqs6TBDKuGw9TG