Skip to content

bundler-plugin-core: .env.bugsee-build-plugin token + esbuild/Rspack source-map upload - #196

Merged
krassx merged 12 commits into
mainfrom
feat/plugin-env-token-and-esbuild-rspack-upload
Nov 12, 2026
Merged

krassx merged 12 commits into
mainfrom
feat/plugin-env-token-and-esbuild-rspack-upload

Conversation

@krassx

@krassx krassx commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #182 and #184.

#182 - .env.bugsee-build-plugin

  • Lookup order: plugin option, process env, then the file. The file only fills gaps (a blank variable counts as unset); process.env is never written.
  • Only BUGSEE_APP_TOKEN / BUGSEE_APP_VERSION / BUGSEE_APP_BUILD are read from it. BUGSEE_ENDPOINT and BUGSEE_CLI_PATH are environment-only: a file that could set them could redirect uploads (with the token) or choose the binary.
  • Search: from the bundler's project dir up to the repo/workspace root (.git or pnpm-workspace.yaml); with no root only the project dir; never in or above the home directory (segment-aware).
  • Missing/unreadable/malformed: never fails the build. A found-but-unusable file (unreadable, UTF-16/binary, no usable or only empty values, or in the home directory when that is the project dir) gives one onNotice, never its contents.

#184 - esbuild and Rspack upload

  • esbuild works on per-build file lists. The plugin sets metafile: true, takes the build's own bundles and maps from result.metafile in onEnd, runs sourcemaps inject <those files> then debug-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. Under failOnError a build with no .map among its own outputs fails, judged on that build alone.
    • This replaces an earlier per-directory serialise/retry design, in which each review round found a new race; the whole class is gone (about 220 lines of plugin.ts and the tuning module removed).
  • Only the maps of the build's own scripts are named to the CLI (an explicitly named .css.map has no debug-id and fails the whole call); .css.map files are deleted with the rest after a confirmed upload, and a stylesheet-only build is a quiet no-op.
  • JavaScript output the plugin cannot upload never passes silently: a result with no metafile (another plugin turned it off) or maps for outputs inject does not stamp (outExtension: '.bundle.jsx') fail under failOnError and are a notice otherwise.
  • esbuild sets sourcemap: 'external' only when unset (an explicit false is left alone and explained).
  • tsup is not covered: tsup always runs esbuild with write: false, so nothing is on disk when onEnd runs. The plugin says so through onNotice (once, only when enabled); docs give a CLI onSuccess recipe. Tested with a real tsup build.
  • Rspack 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 Rspack MultiCompiler sharing one output.path keeps the webpack join behaviour.
  • Dev gate: uploadInDevelopment (default false). Rspack skips only mode: 'development'; esbuild only when NODE_ENV=development (and then does not force maps on). Rspack with devtool off gets a notice.
  • Docs corrected (Angular's builder does not accept esbuild plugins; CLI recipe; CLI 0.7.13 refuses SRI unless --allow-sri; Deno references removed).
  • Pre-existing, fixed because trivial: a whitespace-only BUGSEE_APP_TOKEN no longer enables the plugin.

Tests

Unit + hook wiring, plus real esbuild, @rspack/core@2.2.9 and tsup builds with the real bugsee-cli: esm+cjs into one outdir under failOnError true/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:false per instance); external + inline builds together under failOnError (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 when CI or BUGSEE_REQUIRE_CLI is set (declared in turbo.json). Tests are hermetic against a developer's env file and NODE_ENV.

Lockfile

New devDeps in bundler-plugin-core: @rspack/core@2.2.9, esbuild, tsup@^9.0.0 (already in the root). pnpm-lock.yaml also changes because @rspack/core is an optional peer of unplugin, html-webpack-plugin and nitropack, so their peer-suffixed lock keys gained (@rspack/core@2.2.9). No version of those packages changed; the only transitive version movement is the picomatch used by tinyglobby/fdir (4.0.4 to 4.0.7).

🤖 Generated with Claude Code

https://claude.ai/code/session_01WeiJxSMPCqs6TBDKuGw9TG

krassx and others added 2 commits November 11, 2026 18:27
…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
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Pre-merge checks: Inconclusive 2

Failed Failed checks: 2 inconclusive

Check name Status Explanation Resolution
Title check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
Description check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@claude

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 1m 37s —— View job


Deep review of PR #196

I read the diff against the surrounding code (resolve.ts, orchestrate.ts, run-cli.ts, register-build.ts) and unplugin 2.3.10's esbuild and webpack hook wiring. I did not run the test suite, tsc or the real-build tests: dependencies aren't installed in this checkout, so the claims below come from reading the code.

Checked and found correct

  • unplugin 2.3.10 really invokes esbuild.config and then esbuild.setup(rawBuild). It registers its own onEnd only when buildEnd or writeBundle exists, and this factory defines neither. So there is no double upload for esbuild or Rspack.
  • In the esbuild config hook, identityFromRoot runs before resolved.enabled is read, so the token from the env file is already applied when sourcemap: true is forced.
  • .env.bugsee-build-plugin handling:
    • Precedence is right, and process.env is never written to.
    • An empty environment value is not overridden.
    • Missing, unreadable or directory-shaped files are skipped.
    • A UTF-8 BOM is handled, because trim() strips ``.
  • The Rspack afterEmit hook mirrors webpack's. With no preStamped, the SRI guard in the post-emit path still applies.

Findings (3, posted inline)

Sev Location Summary
P2 plugin.ts:413 The esbuild onEnd upload (and Rspack afterEmit) has no production or mode gate. Every watch or dev rebuild spawns bugsee-cli, uploads, and deletes the local .map files, and the wizard-written env file makes a token far more likely to be present on dev machines.
P3 plugin.ts:206 A bare outfile resolves outDir to the project root. The CLI inject step and the *.map deletion (depth ≤ 6, skipping node_modules and dot-directories) then touch unrelated maps.
P3 env-file.ts:53 The upward walk has no boundary, so a file in a shared ancestor such as /tmp can supply BUGSEE_APP_TOKEN and BUGSEE_ENDPOINT. Also, BUGSEE_CLI_PATH from the file is silently ignored because resolveBugseeCli reads process.env.

Summary

  1. Overall risk: Low to Medium. There are no correctness bugs in the hook wiring or the env merge. The risks are behavioural: the unconditional dev-time upload and delete, and the unbounded env-file lookup.
  2. Merge recommendation: Approve once the P2 is addressed, either with a mode gate or a documented opt-in. The two P3s can land as follow-ups or as doc notes.
  3. Most important to fix:
    • Gate or document the esbuild and Rspack dev and watch uploads.
    • Handle outfile at the project root so unrelated maps aren't deleted.
    • Decide whether to bound the env-file walk, for example at the .git or package.json root.
  4. Positives:
    • The env-file module is small and defensive, with never-fails-the-build semantics and thorough unit tests.
    • Real esbuild and Rspack builds against the real CLI and a local collector is a strong integration test.
    • The docs correction that Angular's builder doesn't accept esbuild plugins, with the CLI recipe instead, is valuable.
    • The hooks reuse runPluginUpload, so the in-flight deduplication and SRI guard carry over.

…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

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 50s —— View job


Re-review of PR #196 after 25ee1ffa

I read the new commit (serialize esbuild uploads, scope the env file, emit external maps) against my earlier findings and the surrounding code (resolve.ts runPluginUpload, orchestrate.ts, register-build.ts). I did not run tests, tsc or the real-build tests, because dependencies aren't installed in this checkout. Everything below comes from reading the code.

Status of earlier findings

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

  • serialUpload chains per outDir. A failed earlier run does not block the next, because tail swallows the rejection. The map entry is released only if it is still the current tail, so there is no leak or lost ordering. The runsByDir join in runPluginUpload cannot swallow the second build, because the slot is freed before the next run starts.
  • Deleting only the uploadedSet snapshot 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.
  • mergeBuildPluginEnv now 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 dangling sourceMappingURL comment. A user-set sourcemap: true still gets that comment with deleteMaps on. That is the user's explicit choice and is not new.

Summary

  1. Overall risk: Low to Medium. The env-file and concurrency fixes look sound. The remaining risk is the behavioural dev-time upload and delete.
  2. Merge recommendation: Approve once the P2 mode gate is added or explicitly documented as accepted. Nothing else blocks.
  3. 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.
  4. 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.
      · branch feat/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

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 57s —— View job


Re-review of PR #196 after 4722ee0c

I read the new commit (skip esbuild/Rspack dev builds; refuse a project-root outfile) against my earlier findings and the surrounding code in plugin.ts, resolve.ts and the tests. I did not run tests, tsc or the real-build tests, because dependencies aren't installed in this checkout. Everything below comes from reading the code.

Status of earlier findings

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

  1. 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.
  2. 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.
  3. Most important to fix:
    • Limit the Rspack skip to mode === 'development', or document and test none.
    • Stub NODE_ENV in test-setup.ts.
    • Apply the dev condition to the esbuild forced sourcemap, and move the per-directory notice after the refusals.
  4. 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=development marks a dev build.
      · branch feat/plugin-env-token-and-esbuild-rspack-upload

…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

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 32s —— View job


Re-review of PR #196 after e0977ab6

I read the new commit (narrow the Rspack dev gate, no dev maps, clearer outfile notices) against my earlier findings, plugin.ts, resolve.ts, test-setup.ts, the tests and the docs. I did not run tests, tsc or the real-build tests, because dependencies aren't installed in this checkout. Everything below comes from reading the code.

Status of earlier findings

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:

  • skipDevelopment returns early when the plugin is disabled, so a disabled plugin gets no development notice and no refusal.
  • A dev build with uploadInDevelopment: true falls through to the outfile checks, as it should.
  • An unset NODE_ENV counts 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

  1. Overall risk: Low. The hook wiring, the serialized per-directory upload, the env-file bounds and the dev gate all look sound.
  2. Merge recommendation: Approve. Every finding from the earlier rounds is addressed, and nothing new surfaced.
  3. 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.9 and the real CLI).
  4. 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=development counts as a dev build) rather than hiding it.
      · branch feat/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

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 1m 4s —— View job


Re-review of PR #196 after be5d9817

I read the new commit (tsup notice, retry-safe concurrent esbuild uploads, env-file notices) against the surrounding code in plugin.ts, resolve.ts (runPluginUpload and its runsByDir join), env-file.ts, orchestrate.ts and the esbuild tests. I did not run tests, tsc or the real-build tests, because dependencies aren't installed in this checkout. Everything below comes from reading the code.

Earlier findings: all were already addressed in the previous round. Nothing earlier is reopened by this commit.

New finding (1, posted inline, P3)

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 onEnd decrements inflight before 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 inflight count 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 onError for a capture does not conflict with the runsByDir join, because serialUpload keeps runs of one directory sequential.
  • Project-directory refusal: relative(outDir, project) correctly refuses outDir equal to or above the project, and outdir: '.' is now covered. dist, a sibling directory, and a monorepo ../../dist still 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_ENDPOINT is not "usable", because parseEnvFile already filters to FILE_KEYS.
  • Whitespace-only BUGSEE_APP_TOKEN: now treated as no token, and resolve.test.ts covers it. An explicit whitespace-only appToken option 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 default console.warn behaviour unchanged.

Summary

  1. Overall risk: Low. The concurrency fix is sound and bounded. The only new issue is one misplaced notice.
  2. 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.
  3. Most important issue to fix: Gate the write: false notice on resolved.enabled and 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.
  4. 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 onSuccess recipe and the outdir guidance).
    • The env-file notices never echo file contents.
      · branch feat/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

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 17s —— View job


Re-review of PR #196 after 83fde343

I read the new commit (do not say the write:false notice for a disabled plugin) against my previous finding in plugin.ts and the esbuild tests. I did not run tests, tsc or the real-build tests, because dependencies aren't installed in this checkout. Everything below comes from reading the code.

Status of earlier findings

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

  1. 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.
  2. Merge recommendation: Approve. Fix the PR description (and the Fixes #185 link) before merging, and rely on CI for the real esbuild, Rspack, tsup and slow-inject tests, which I could not run.
  3. Most important issues to fix: only the stale PR description.
  4. 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.
      · branch feat/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

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 1m 18s —— View job


Re-review of PR #196 after ad7685fe (round 3 fixes)

I read the new commit against plugin.ts, resolve.ts (runPluginUpload), orchestrate.ts (uploadSourcemaps), upload-tuning.ts, env-file.ts and the lockfile diff. I did not run the test suite, tsc or the real-build tests, because dependencies aren't installed in this checkout. Everything below comes from reading the code. CI is the authority for the real esbuild, Rspack and tsup tests.

Earlier findings: all were already addressed in earlier rounds. Nothing is reopened by this commit.

Checked in this commit and found correct

  • failOnError on the esbuild upload step
    • settledUpload is passed to runPluginUpload as the uploadSourcemaps dependency, so failOnError reaches uploadSourcemaps unchanged.
    • That keeps --allow-empty off under failOnError, so an esbuild build with no maps fails.
    • Under failOnError, uploadSourcemaps throws instead of calling onError. The thrown branch retries, then rethrows on the last attempt. That is correct.
    • Without failOnError it captures through onError, retries when another build started or is in flight, and otherwise reports through the user's onError or the default handler.
  • Registration is not retried. The retry wraps only the upload step, so a registerJsBuild failure still goes through its own handling, as the commit message says.
  • No nested-build stall. The first attempt never waits. Only a retry calls waitForIdle, bounded by idleWaitMs (5 s). onEnd decrements inflight before queuing, so queued builds don't wait on each other. A disabled plugin returns before serialUpload, so it queues nothing.
  • Outfile guard.
    • isSameOrAbove is segment-aware (..cache is no longer read as a parent). It also handles a Windows cross-drive result via isAbsolute.
    • The package-root check is limited to outfile-only builds, so outdir: 'dist' is unaffected.
    • atOrAbove in env-file.ts got the same fix.
  • Dev-skip and Rspack devtool notices
    • The dev-skip notice now says "nothing was uploaded". That is accurate for builds that wrote no maps.
    • The Rspack devtool notice is gated on resolved.enabled.
    • At plugin-apply time compiler.options.devtool is the raw user value, before Rspack applies its defaults. For an unset production devtool the notice is correct, because that default is false.
  • Test seam. uploadTuning is not exported from the package entry, and the tests that shrink it restore the values.

New findings: none that I'd report as real bugs.

Minor observations (no action needed)

  • A genuinely failing upload (bad token, network) that coincides with another build in flight is now retried up to 3 times. Each retry re-runs inject and upload, and waits up to 5 s. This is bounded and the final error is still reported, but it is extra work and delay. It reports captured[0], the first error, not the last.
  • With Rspack mode: 'development' and no devtool, the "devtool is off" notice appears at setup, followed by the dev-skip notice at afterEmit. This is mildly redundant, not wrong.
  • The PR description's lockfile claim is slightly off. It says no versions of existing packages changed. The pnpm-lock.yaml diff also moves tinyglobby@0.2.17 from picomatch@4.0.4 / fdir(picomatch@4.0.4) to 4.0.7. picomatch@4.0.7 and fdir@6.5.0(picomatch@4.0.7) already exist in the lock, so this is resolution drift from re-locking, not a broken lock. Consider reverting that hunk or noting it in the description.
  • tsup is now a devDependency of bundler-plugin-core, pinned to ^9.0.0 like the root. The lock entry matches.

Summary

  1. Overall risk: Low. The hook wiring, per-directory serialization and retry, env-file bounds, dev gate and notices have all been reviewed across the rounds. This commit fixes the one regression the retry wrapper introduced (failOnError no longer reaching the upload step).
  2. Merge recommendation: Approve. Nothing blocks. Rely on CI for the real esbuild, Rspack, tsup and slow-inject race tests.
  3. Most important issues to fix: none outstanding. Optionally, correct the lockfile sentence in the PR description.
  4. Positives:
    • Wrapping only the upload step keeps the failOnError, --allow-empty and registration semantics in one place.
    • uploadTuning makes the retry timing testable without sleeping.
    • The comments explain why the first attempt must not wait, which a future reader would otherwise "fix".
      · branch feat/plugin-env-token-and-esbuild-rspack-upload

…, 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

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 40s —— View job


Re-review of PR #196 after cf1764bc (round 4 fixes)

I read the new commit against plugin.ts (settledUpload, isPackageRoot, the esbuild setup hook, the Rspack devtool notice), orchestrate.ts (allowEmpty, the uploadedSet snapshot and the return shape), the docs and the test names. I did not run the test suite, tsc or the real-build tests: dependencies aren't installed in this checkout. Everything below comes from reading the code, so CI is the authority for the real esbuild, Rspack and tsup tests.

Earlier findings: all were addressed in earlier rounds, and nothing is reopened by this commit.

Checked in this commit and found correct

  • Dual-format builds under failOnError
    • sweepsAtStart is taken in onStart, so it is per build and refreshed on every watch rebuild.
    • sweeps is bumped only when a run deleted maps.
    • A run is allowed an empty directory only when activity.sweeps > sweepsAtStart. That means an earlier run uploaded and deleted maps after this build began. A lone map-less build has no sweep, so it still fails under failOnError.
    • serialUpload keeps runs of one directory sequential, so the second run always sees the first run's sweeps++.
    • allowEmpty is recomputed on every retry attempt, and options.allowEmpty is the fallback.
    • Combined with emptyFlag, --allow-empty is omitted only for failOnError && !allowEmpty. A default build behaves as before.
  • Retry predicate: busyBefore covers a build that was already running when the attempt began. The loop is still bounded by uploadTuning.attempts, and the first attempt still never waits.
  • isPackageRoot
    • It returns false for a missing or unparsable package.json, so a dist/cjs/package.json marker is not treated as a package root.
    • It is applied only to outfile-only builds, so outdir: 'dist' is unaffected, and a test pins that.
  • Rspack devtool notice: it is suppressed only for a development build that will be skipped anyway, so there is no duplicate with the dev-skip notice. With uploadInDevelopment: true the notice still shows, which is right because the default eval emits no maps.

Minor observations (not findings, no action required)

  • A package.json with a name marks a package root, so outfile: 'dist/index.js' is refused when dist/package.json is a copied, named manifest. That layout is common in libraries that publish from dist. It produces only a notice and nothing is uploaded, and the notice points to outdir, so I would take it as documented behaviour.
  • The allowEmpty leniency is global per output directory. A genuinely misconfigured map-less build that overlaps a build which swept the same directory is not flagged under failOnError. That is the accepted trade-off of the round 4 design, and the docs describe it.
  • If an esbuild context is disposed mid-build, onEnd may not fire and inflight can stay above zero. A later genuine upload failure in that directory would then retry up to 3 times with waits of up to 5 s each. This is bounded and only adds delay.

Summary

  1. Overall risk: Low. The hook wiring, per-directory serialization, the retry and allowEmpty handling, the env-file bounds, the dev gate and the notices have all been reviewed across the rounds. This commit fixes the dual-format failOnError regression without weakening the lone-build check.
  2. Merge recommendation: Approve. I found no new real issues.
  3. Most important issues to fix: none outstanding. Rely on CI for the real-build tests, including the new concurrent failOnError and in-flight-race cases.
  4. Positives:
    • The sweeps counter models "an earlier run already took my maps" directly, instead of loosening failOnError globally.
    • The package-root check is narrowed to avoid false refusals, with tests for the marker and invalid-manifest cases.
    • The docs state the failOnError semantics and the uploadInDevelopment limits openly.
      · branch feat/plugin-env-token-and-esbuild-rspack-upload

…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

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 1m 21s —— View job


Re-review of PR #196 after 05d9fd6d (esbuild uploads work on the build's own files)

I read the new commit against plugin.ts, orchestrate.ts, resolve.ts, debug-ids.ts and sri.ts, and the batching tests. I did not run the test suite, tsc or the real-build tests, and I could not exercise bugsee-cli: dependencies aren't installed in this checkout. Everything below comes from reading the code, so CI is the authority for the real esbuild, Rspack and tsup tests.

What changed: the plugin now sets metafile: true and uploads exactly the files the metafile lists, in batches of 200 paths. That replaces serialUpload, the activity tracking, the retry, allowEmpty and the package-root and project-dir guards. This design is simpler and removes the whole class of cross-build races from earlier rounds.

Status of earlier findings and observations

  • The retry, in-flight, allowEmpty, isPackageRoot and dual-format observations from the last two rounds no longer apply, because that code is gone.
  • The failOnError rule now lives in plugin.ts (a build with no .map among its own outputs throws) and is judged on that build alone. I checked that this runs after the dev gate and the !resolved.enabled return.
  • The directory-run delete snapshot now fails closed: if listing fails, nothing is deleted and the failure is reported, through onError or thrown under failOnError. That is the safer direction.
  • In files mode, defaultDeleteMapFiles(outDir, files.maps) unlinks the exact metafile paths with no depth limit. A map deeper than 6 levels is therefore still deleted, which the old directory walk would have missed.
  • runPluginUpload returns before runsByDir is set when files is given. A files run neither joins nor is joined, as intended.
  • Registration reads only the build's own scripts via collectDebugIdsOf.

New finding (1, posted inline, P3, needs a check against the real CLI)

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.metafile is ever missing (another plugin or wrapper overriding the option), the build reads as "emitted no .map files". Under failOnError that 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, the config hook says so, and onEnd then says "emitted no .map files" as well. Under failOnError it 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 bare outfile in the project directory that walk covers the project tree, down to 6 levels, skipping only node_modules, .git and test directories. It only refuses when some HTML pins a local .js in 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 to files.scripts would make that exact.
  • Stale PR description: it still describes the removed design (per-directory serialisation, retry of at most 3, allowEmpty sweeps, the project-root and package-root outfile refusals, the "Round 3" and "Round 4" sections, and the uploadTuning mention). Please update it to describe the metafile-based approach before merging. The lockfile note about tinyglobby and picomatch from the last round is still not reflected.

Summary

  1. Overall risk: Low. Removing the per-directory coordination makes the upload path easier to reason about, and the delete path now fails closed.
  2. 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.
  3. 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.
  4. 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.
      · branch feat/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

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 52s —— View job


Re-review of PR #196 after 57dae62b (stylesheet maps are never named to the CLI)

I read the new commit against plugin.ts (esbuildOwnFiles and the esbuild onEnd), orchestrate.ts (the inject batches and the delete step), resolve.ts and the new tests and docs. I did not run the test suite, tsc or the real-build tests, because dependencies aren't installed in this checkout. Everything below comes from reading the code. CI is the authority for the real esbuild, Rspack and tsup builds.

Status of earlier findings

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 .map is one of the build's own scripts. .css.map and 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 !enabled return.
  • Types: stylesheetMaps is optional on both UploadSourcemapsOptions.files and runPluginUpload, 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

  1. Overall risk: Low. The upload, delete and registration steps all work on the same explicit file list, and this commit narrows that list safely.
  2. Merge recommendation: Approve. The one new finding is a narrow edge case that can be taken as a follow-up.
  3. Most important issues to fix:
    • Make "no scripts" fail loudly under failOnError when 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.
  4. 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.
      · branch feat/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

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 31s —— View job


Re-review of PR #196 after 1e86f5be (esbuild JS output that cannot be uploaded must not pass silently)

I read the new commit against plugin.ts (esbuildOwnFiles and the esbuild onEnd) and the unit and real-build tests it adds or changes. I did not run the test suite, tsc or the real-build tests: dependencies aren't installed in this checkout. This comes from reading the code, so CI is the authority for the real esbuild, Rspack and tsup builds.

Status of earlier findings

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: false branch, the dev gate and the !resolved.enabled return. A disabled plugin or a dev build gets no new notice and no new failure.
  • problem under failOnError: a throw inside onEnd surfaces as a build error. Without failOnError it goes through say, which dedupes, so a watch rebuild repeats no notice. The test checks one notice after two ends.
  • .css.map handling: strayMaps excludes .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 } keeps strayMaps out of the files that runPluginUpload and the delete step receive. The upload and delete behaviour is unchanged.
  • Tests: the unit tests cover the missing-metafile and .bundle.jsx cases under failOnError and as notices. The real-build tests add the metafile-off plugin and outExtension shapes.

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 outExtension applies 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 / picomatch re-resolution noted in an earlier round. This is cosmetic.

Summary

  1. 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 failOnError and otherwise give one notice. Deletion still happens only after a confirmed upload, and only for the build's own files.
  2. 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.
  3. 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.
  4. Positives:
    • The previous review's failOnError gap is closed with a single shared problem helper, 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.
      · branch feat/plugin-env-token-and-esbuild-rspack-upload

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.

bundler-plugin-core: read the token from .env.bugsee-build-plugin

1 participant