Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
0a74c1b
feat(bundler-plugin-core): verify the debug-ID stamp, and delete maps…
krassx Nov 23, 2026
7f13da8
feat(bundler-plugin-core): stamp debug-IDs inside the build for Vite,…
krassx Nov 23, 2026
de212ad
docs: in-build stamping, stamp verification and safe map deletion
krassx Nov 23, 2026
d251091
chore: changeset for in-build stamping
krassx Nov 23, 2026
d3f2ee7
feat(bundler-plugin-core): sourcemaps doctor — offline build-output d…
krassx Nov 23, 2026
f1acf01
docs(source-maps): doctor README, usage section and PROGRESS entry
krassx Nov 23, 2026
e8495dd
fix(bundler-plugin-core): review findings on in-build stamping
krassx Nov 23, 2026
d42fe8f
fix(bundler-plugin-core): round-2 review findings on stamp verification
krassx Nov 23, 2026
780fd61
fix(bundler-plugin-core): round-3 review findings
krassx Nov 23, 2026
707bcf7
fix(bundler-plugin-core): upload a pre-stamped build as an explicit f…
krassx Nov 23, 2026
2e4885f
fix(bundler-plugin-core): upload and delete every uploadable map, wha…
krassx Nov 23, 2026
e7a6f10
fix(bundler-plugin-core): delete stylesheet/declaration maps on the p…
krassx Nov 23, 2026
6d06b43
fix(bundler-plugin-core): stamp moved maps, walk any depth, determini…
krassx Nov 23, 2026
3bdb914
fix(bundler-plugin-core): foreign maps survive, unreachable maps are …
krassx Nov 23, 2026
4cb9575
fix(bundler-plugin-core): delete by identity (what this build emitted…
krassx Nov 23, 2026
21daacb
fix(bundler-plugin-core): webpack/Rspack asset names with a ?query no…
krassx Nov 23, 2026
10242b1
fix(bundler-plugin-core): cut asset names at '?' only; '#' is part of…
krassx Nov 23, 2026
4077365
chore(bundler-plugin-core): round-12 leftovers (limits doc, script-li…
krassx Nov 23, 2026
2592a39
Merge remote-tracking branch 'origin/feat/in-build-stamping' into fea…
krassx Nov 23, 2026
82f36d9
fix(bundler-plugin-core): doctor pairs maps with the stamp's own poin…
krassx Nov 23, 2026
d8570ff
fix(bundler-plugin-core): write webpack/Rspack stamped assets as STRI…
krassx Nov 23, 2026
63b5cd5
fix(bundler-plugin-core): doctor review round — strict-usable severit…
krassx Nov 23, 2026
3782b60
fix(bundler-plugin-core): Vite workers keep the debug-id in their map…
krassx Nov 23, 2026
837bd6c
fix(bundler-plugin-core): the worker catch-up never costs the build i…
krassx Nov 23, 2026
9f67602
fix(bundler-plugin-core): catch-up always verifies/restores, reports …
krassx Nov 23, 2026
8c798c5
test(bundler-plugin-core): pin the catch-up's per-pair read guard
krassx Nov 23, 2026
74ff8e3
Merge remote-tracking branch 'origin/feat/in-build-stamping' into fea…
krassx Nov 23, 2026
b39a181
test(bundler-plugin-core): doctor over real Vite worker builds after …
krassx Nov 23, 2026
3623167
fix(bundler-plugin-core): doctor round 2 — bounded manifest reads ins…
krassx Nov 23, 2026
58558b1
fix(bundler-plugin-core): doctor CLI refuses a value on boolean flags…
krassx Nov 23, 2026
d811c7b
fix(bundler-plugin-core): doctor never follows a symlinked directory …
krassx Nov 23, 2026
355d236
fix(bundler-plugin-core): address PR #221 review threads and code-sca…
krassx Nov 23, 2026
436ac98
test(bundler-plugin-core): type the catch-up edge-case run mock
krassx Nov 23, 2026
a67491a
style(bundler-plugin-core): format a test
krassx Nov 23, 2026
048700a
fix(bundler-plugin-core): on-disk re-check judges only what the stamp…
krassx Nov 23, 2026
e0d192d
fix(bundler-plugin-core): report an unrestorable rewrite, sibling out…
krassx Nov 23, 2026
c4bf2ff
fix(bundler-plugin-core): a generate()-only output cannot hide anothe…
krassx Nov 23, 2026
97da0be
fix(bundler-plugin-core): coordinate outputs by physical directory; s…
krassx Nov 23, 2026
117053e
fix(bundler-plugin-core): generate()-only outputs are no siblings; ca…
krassx Nov 23, 2026
ae593b1
Merge remote-tracking branch 'origin/feat/in-build-stamping' into fea…
krassx Nov 23, 2026
4dfd6df
test(bundler-plugin-core): doctor over multi-output and nested-direct…
krassx Nov 23, 2026
d6551ec
fix(bundler-plugin-core): doctor SRI check reads each pinned script o…
krassx Nov 23, 2026
0f9a3ef
feat(nextjs): withBugsee() source-map upload for webpack and Turbopac…
krassx Nov 23, 2026
0d360f9
fix(bundler-plugin-core): review sweep - own-map exception by own nam…
krassx Nov 23, 2026
5fbeb79
Merge origin/feat/in-build-stamping (#224) into the sweep
krassx Nov 23, 2026
3bbcbce
fix(nextjs,bundler-plugin-core): remove forced browser maps when the …
krassx Nov 23, 2026
e04f684
docs(nextjs): registration follows the source-map pipeline; document …
krassx Nov 23, 2026
f5455e3
fix(nextjs): sweep forced browser maps after every run, and when a se…
krassx Nov 23, 2026
dd5b68c
fix(bundler-plugin-core): address PR review (generate-only, standalon…
krassx Nov 24, 2026
4b39207
fix(bundler-plugin-core): webpack stamps in-build in every mode; only…
krassx Nov 24, 2026
db8d182
fix(bundler-plugin-core,nextjs): review round on in-build stamping (s…
krassx Nov 24, 2026
75e222d
fix(bundler-plugin-core): doctor round 4-5: linear bounded SRI page s…
krassx Nov 24, 2026
575c6db
Merge origin/feat/in-build-stamping into feat/sourcemaps-doctor
krassx Nov 24, 2026
b10b5d3
style(bundler-plugin-core): organize imports after merge
krassx Nov 24, 2026
dfdfe05
fix(bundler-plugin-core): the stamp's SRI guard has no page-size cap …
krassx Nov 24, 2026
9cea1b1
fix(nextjs): honour deleteMaps:false and sweep forced maps on the no-…
krassx Nov 24, 2026
71a2ea6
docs(source-maps): webpack forced-map sweep honours deleteMaps:false …
krassx Nov 24, 2026
38f8218
feat(bundler-plugin-core): doctor --exclude for files the build did n…
krassx Nov 24, 2026
73d67e9
Merge remote-tracking branch 'origin/feat/in-build-stamping' into fea…
krassx Nov 24, 2026
8fafe79
fix(bundler-plugin-core): doctor round 7: exclude applies to SRI pins…
krassx Nov 24, 2026
efb61bd
fix(bundler-plugin-core): doctor SRI page walk follows the doctor fen…
krassx Nov 24, 2026
0fdf8c8
fix(bundler-plugin-core): doctor pairs a sourceMappingURL with a ?que…
krassx Nov 24, 2026
b4095bc
fix(bundler-plugin-core): doctor reads sources from index (sectioned)…
krassx Nov 24, 2026
9adba5c
fix(bundler-plugin-core): doctor cuts a pointer's query only (not a ?…
krassx Nov 24, 2026
1f3c461
fix(bundler-plugin-core): doctor: scheme sourceRoot, nested index map…
krassx Nov 24, 2026
5d6a0dc
merge: main (squash-merged #221) into feat/sourcemaps-doctor
krassx Nov 24, 2026
ddd5a7b
test(bundler-plugin-core): comment-strip oracle without String.replac…
krassx Nov 24, 2026
c77ef5f
fix(bundler-plugin-core): doctor reports directories it could not lis…
krassx Nov 24, 2026
db46ec9
fix(bundler-plugin-core): --exclude can name an unreadable directory
krassx Nov 24, 2026
4a2b3d0
fix(bundler-plugin-core): --exclude hides an unreadable directory onl…
krassx Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sourcemaps-doctor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bugsee/bundler-plugin-core': minor
---

Adds `bugsee-sourcemaps-doctor`, an offline check of a build output directory (`npx --package=@bugsee/bundler-plugin-core bugsee-sourcemaps-doctor dist`; `--json`, `--strict`, `--deployed`, `--ignore <id>`, `--exclude <glob>`), and the matching `diagnoseBuildOutput(dir, options)` API with a versioned report (`schemaVersion: 1`). It tells you why a crash from the build would not symbolicate: unstamped bundles or a missing runtime registration, a map whose debugId differs from its bundle's, dangling, hidden or inline source maps, invalid maps and missing `sourcesContent`, duplicate IDs, Subresource Integrity hazards, leftover public maps, development bundles, and the build environment (token source, version, build, `NODE_ENV`; the token value is never printed). Exit 0 ok, 1 warnings with `--strict`, 2 errors. Also: `stamp-files` no longer spreads large file lists onto the call stack (a directory with more than ~125k scripts or maps overflowed it). The Subresource Integrity page scan in the build plugins is now linear (quadratic regexes on pages with thousands of unterminated tags or comments are replaced by an `indexOf` scanner, with a differential test pinning identical results) and pages larger than 8 MiB are skipped.
3 changes: 3 additions & 0 deletions docs/PROGRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1532,5 +1532,8 @@ Verified against current majors, all green with no adapter code changes: `@bugse
### Debug-ID stamping inside the build for Vite, Rollup and Rspack; verified stamps; safe map deletion (2026-11-23)
`@bugsee/bundler-plugin-core` now stamps INSIDE the build wherever the bundler has a pre-write hook, so Subresource Integrity hashes taken later describe the stamped bytes: webpack 5 and **Rspack** at `PROCESS_ASSETS_STAGE_DEV_TOOLING + 1` (shared `tapProcessAssetsStamp`), **Vite and Rollup** in `generateBundle` (`order: 'pre'`; `rollupAssetStore` over chunks + `.map` assets; the stamped id is also put on `chunk.map` because Vite regenerates the map of a lazy-loading chunk after user hooks). esbuild and the standalone CLI stay post-emit with the SRI refusal (its message now names the workaround). Every stamp is verified (`verify-stamp.ts`: parses, sourceMappingURL intact, map debugId matches, original bytes + appended stamp): in-build all-or-nothing, post-emit snapshot + restore of the failing pair (`stamp-files.ts`); an in-build stamp is re-checked on disk (`verifyStampedPairs`) and against the HTML (`findIntegrityMismatches`). `.map` deletion now requires a confirmed upload AND a debugId on the map (`partitionByKeyed`). Real-build proof: `plugin.in-build.real-build.test.ts` (Vite 7 + 8, Rollup, Rspack with its built-in SRI plugin) and a Chromium run in `instrumentation-tests/test/sri-vite-rollup.e2e.ts`. Measured ordering limits and what the guards do not see: `docs/design/source-maps.md` §7.1.

### `sourcemaps doctor`: offline build-output diagnostics (2026-11-23)
`@bugsee/bundler-plugin-core` ships `diagnoseBuildOutput(dir, options)` (`src/doctor.ts`) and the `bugsee-sourcemaps-doctor` bin (`src/doctor-cli.ts`, ESM-only tsup entry, wired through `publishConfig.bin`). 36 check IDs (`DOCTOR_CHECK_IDS`) over the output directory, bundles, maps, SRI (reusing `sri.ts`), leftover maps and the build environment (token, version, build, `NODE_ENV`; the token is never printed), each with a severity and a fix hint, and one versioned JSON report (`schemaVersion: 1`) that the Rust `bugsee-cli sourcemaps doctor` is specified to share. Exit codes 0 ok, 1 warnings only with `--strict`, 2 errors. Review round (PR #222): `--strict` passes straight after a plugin run (`map.public-leftover` is a note unless `--deployed`; `map.pointer-dangling` is a note when no map is left and every bundle is stamped; `--ignore <id>`), the doctor never throws (`doctor.internal-error`; no spread of large lists, safe `file://` decoding), reads only regular files inside the directory with the size checked first (`map.unreadable`, `map.pointer-outside-dir`), walks the whole output directory (only `node_modules`/`.git` skipped unless it is the project root), resolves bundler-scheme sources against the project root, reports the token's source (`env.token-source`; a missing token is a warning), and pairs maps with the stamp's own `localPointerTarget`. The same spread pattern was fixed in `stamp-files.ts`. Round 8: the SRI page walk follows the doctor's fence (full walk for an output directory, reported fence otherwise); docs always use `npx --package=@bugsee/bundler-plugin-core bugsee-sourcemaps-doctor`. Round 7: `--exclude` applies to SRI pins and map pointers, unmatched patterns are reported (`output.exclude-unmatched`), an all-unreadable output cannot pass, reads are bounded by bytes in flight, maps need `mappings`/`sections`, every distinct SRI pin is kept for the doctor, `passed` lists only checks that had input. Round 6: `--exclude <glob>` (+ `exclude` option) drops files the build did not emit (`output.excluded`); the walk fence needs a `package.json` as well as cwd and reports what it skipped (`output.walk-fenced`); the stamp's own SRI guard keeps no page cap (only the doctor's scan does). Round 4: the HTML scan in `sri.ts` is linear (an `indexOf` scanner replaced the quadratic comment and script-tag regexes; a differential fuzz test pins identical results) and bounded (pages over 8 MiB are skipped and reported as `sri.html-skipped`); reads go through `safe-read.ts` (open with `O_NOFOLLOW`/`O_NONBLOCK`, type and size judged on the descriptor); in-directory symlinks are followed by real path; FIFOs/sockets/devices named like scripts are reported; a map reached through two names is judged once; long lists and the per-map `map.sources-content` notes are capped/aggregated. Real-build proof in `doctor.real-build.test.ts`: Vite 8 and 7, Rollup and Rspack stamped by the real plugin and CLI (healthy), an unstamped build, an inline-map build, and SRI builds (unstamped hazard, stamped-first clean, stamped-after-hash `sri.mismatch` produced by `bugsee-cli sourcemaps inject --allow-sri`). Webpack itself is not a dependency of this package; Rspack stands in for the shared in-build stamp path. Mutator loop: 10 mutations on the decision logic, all killed. **Not done:** an optional post-build `doctor` call in the plugins (the findings need a policy for failing a build; left as a follow-up), the Rust command, and every check that needs the backend (design hand-off: map-present-for-debug-ID, deployed-URL, synthetic symbolicate round trip).

### Next.js build integration: `withBugsee` (`@bugsee/nextjs/config`), webpack AND Turbopack (2026-11-23)
`withBugsee(nextConfig, options)` makes `next build` stamp debug-IDs and upload source maps (gap #1 of the source-map gap analysis). Design + measured limits: `docs/design/source-maps.md` §7.3; user docs: `packages/nextjs/README.md`. **webpack** (`--webpack`, default <= 15): one per-compilation plugin (client, server, edge) stamping inside the compilation (`PROCESS_ASSETS_STAGE_DEV_TOOLING + 1`, SRI-safe) and uploading exactly the files that compilation emitted (`files` mode, nothing walks `.next`). The generic `@bugsee/webpack-plugin` was NOT reused for Next: measured against a real build it cannot stamp the server compilation (assets named `../app/page.js`, output path `.next/server/chunks`) and its directory-wide upload of `.next` collides across the three compilations. **Turbopack** (default 16; `--turbopack` 15.x): `compiler.runAfterProductionCompile` (15.4.0+) runs the real `inject` + upload over `.next/static` and `.next/server`, bundles paired with maps by the `sourceMappingURL` pointer (Turbopack does not name a map after its bundle; Next 15.5 shares one map between two runtime chunks, which are left unstamped with a notice). Measured limits: Turbopack writes the SRI hashes BEFORE the hook, so an `experimental.sri` Turbopack build is left unmodified with a notice (webpack handles SRI); Next 16 errors on a `webpack` function without a `turbopack` config, so none is added on Turbopack builds; `compiler.define` (not `defineServer`) bakes the app identity. Policy: browser maps deleted after a confirmed upload, server/edge maps kept (`deleteServerMaps`). Composes with a user's `webpack`, `compiler.runAfterProductionCompile`, `compiler.define`, `productionBrowserSourceMaps`, function/async configs; inert for dev/start/export. Core change: `@bugsee/bundler-plugin-core` now also exports `stampAssets`, `AssetStore`, `notify`, `resolveIdentity`, `loadBuildPluginEnv`, `mergeBuildPluginEnv`. Found by the independent reviews and fixed: stamped webpack assets are written as STRING sources (a Buffer is opaque to webpack's RealContentHashPlugin, which renames `[contenthash]` chunks after the stamp, so every lazy chunk 404'd; the e2e now opens each build in headless Chromium and asserts the lazy chunk runs), the baked define is the RAW value (Next JSON-encodes `compiler.define` itself; a JSON string arrived double-quoted), own-files-only deletion on Turbopack, contained post-build hook, version floors (hook 15.4.0, define 15.1.0), idempotent application. Real builds (`@bugsee/nextjs-e2e`, `test/source-maps.e2e.ts`, `next` 15.5.28 and 16.4.6 x webpack/Turbopack + SRI cases, real `bugsee-cli`, mock collector, `next start` smoke): see the PR for the run.
32 changes: 32 additions & 0 deletions docs/source-maps-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,35 @@ stub the SDK reads. This is exactly what the plugins automate; the CLI is the sa
- **Not covered: bytecode targets.** React-Native/Hermes compiles JS → bytecode, which drops the injected comment
and stub, so the running code reports no debug-ID. That needs a Hermes-specific compose flow and is handled by the
separate React-Native SDK, not this (web/node/bun) SDK.

## 4. Check a build: `bugsee-sourcemaps-doctor`

When a production crash does not de-minify, run the doctor against the build output you actually deployed (or are about to). It is offline: it reads the files and makes no network call. The token is only looked up (never printed) so the report can say where it comes from; a missing token is a warning, not an error.

```bash
npx --package=@bugsee/bundler-plugin-core bugsee-sourcemaps-doctor dist # readable report, fix hint per finding
npx --package=@bugsee/bundler-plugin-core bugsee-sourcemaps-doctor dist --json # for CI (schemaVersion 1)
npx --package=@bugsee/bundler-plugin-core bugsee-sourcemaps-doctor dist --strict # warnings fail the step too (exit 1)
npx --package=@bugsee/bundler-plugin-core bugsee-sourcemaps-doctor dist --deployed # the directory is served: leftover .map files warn
```

The binary ships in `@bugsee/bundler-plugin-core`, so always name the package as above (a bare `npx bugsee-sourcemaps-doctor` is only safe when it is already linked into `node_modules/.bin`, which pnpm and Yarn do for direct dependencies only; otherwise npx asks the public registry for an unrelated name).

`--strict` passes straight after a default plugin run (maps removed after upload, bundles stamped) when the directory holds only what the build emitted. Scripts copied in (Vite `publicDir`, a copy plugin) are never stamped by the plugin and are indistinguishable from a bundle that lost its stamp: exclude them by path, relative to the checked directory (Vite copies `public/` to the ROOT of the output, so `--exclude sw.js --exclude 'pdf.worker.min.mjs*'`; repeatable; listed as `output.excluded`, and a pattern that matches nothing is reported as `output.exclude-unmatched`). `--exclude` only removes files from the audit, not from what you deploy. A directory that is a project (has a `package.json`) and is the working directory is walked fenced (no `src`, `test`, dot-directories, depth > 6), and the skipped directories are listed as `output.walk-fenced`. Other options: `--ignore <id>` (repeatable; hard failures such as `output.no-js` cannot be ignored), `--project-root`, `--max-map-mb`, `--no-env`, `--`.

Exit codes: `0` ok, `1` warnings only (with `--strict`), `2` errors. The package is `@bugsee/bundler-plugin-core`; the same report is available in code as `diagnoseBuildOutput(dir, options)`.

Typical findings and what to do:

| ID | Meaning |
|---|---|
| `stamp.missing-debug-id` / `stamp.missing-registration` | A bundle is not stamped (or only has the comment, not the runtime registration). Add the plugin, or run `bugsee-cli sourcemaps inject <dir>` after the build. |
| `stamp.map-id-mismatch` / `stamp.map-no-debug-id` | The map's `debugId` is not the bundle's. A step ran after stamping; stamp last. |
| `map.pointer-dangling` | The bundle's `sourceMappingURL` points at a map that is not on disk. A note when no `.map` is left and every bundle is stamped (maps removed after upload); otherwise a warning. Use hidden maps to avoid the 404. |
| `map.inline` | The map is a `data:` URL inside the bundle: nothing to upload, and it ships to every visitor. |
| `map.sources-unresolvable` | No `sourcesContent` and the sources are not on disk: frames will have no source lines. |
| `map.public-leftover` | `.map` files are in the directory. A note by default; a warning with `--deployed` (you serve this directory). Keep `deleteMaps` on, or remove the maps / leave them out of the deploy (`--exclude` does not help: it only hides them from this audit). |
| `sri.unstamped-hazard` / `sri.mismatch` / `sri.manifest-hashes` | Subresource Integrity hashes pin these scripts; stamping after hashing makes the browser block them. |
| `env.token-missing` | No app token is visible to the build (a warning): the plugin is disabled and uploads nothing, which is fine if you upload with `bugsee-cli` by hand. `env.token-source` says where a found token comes from, never its value. |

The doctor reports which source supplied the token (`env.token-source`: option, environment variable or `.env.bugsee-build-plugin`), never the token. It reads only regular files inside the directory you give it and checks a map's size before reading it. Checks that need the backend (is the map for this ID uploaded? does the deployed URL serve a stamped bundle?) are not part of this command yet.
18 changes: 17 additions & 1 deletion packages/bundler-plugin-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,23 @@ npm install --save-dev @bugsee/vite-plugin
- Settings lookup order: plugin option, then the process environment, then the nearest `.env.bugsee-build-plugin` (only `BUGSEE_APP_TOKEN` / `BUGSEE_APP_VERSION` / `BUGSEE_APP_BUILD` are read from it; searched from the bundler's project directory up to the repo/workspace root, never in or above the home directory; fills gaps only, a blank variable counts as unset; a missing or malformed file never fails the build). Details: `docs/source-maps-usage.md`.
- Option resolution (`appToken`, `appVersion`, `appBuild`, `endpoint`, `deleteMaps`, `dryRun`, `disabled`, with environment fallbacks such as `BUGSEE_APP_TOKEN`; the version also falls back to the nearest `package.json` above the bundler's project directory (blank values count as unset; Rollup, which reports no project directory, walks up from the output directory and skips a name-less, version-less marker such as a `dist/cjs/package.json` holding only `{"type":"commonjs"}`), the build to a CI commit id, and a real value is baked into the app bundle as `__BUGSEE_APP_VERSION__` / `__BUGSEE_APP_BUILD__` for the runtime SDK: through `define` on Vite, esbuild, webpack 5 and Rspack, and by rewriting each rendered chunk (with a source map) on Rollup; webpack 4 cannot bake, so there only an explicit value is recorded; a constant you define yourself is what gets recorded when it is a plain string), build-commit detection and the CLI runner.

The programmatic API beyond the plugins is internal and may change between releases.
## `bugsee-sourcemaps-doctor`

An offline check of a build output directory: why would a crash from this build not symbolicate? No network call; a token is not required (a missing one is only a warning).

```bash
npx --package=@bugsee/bundler-plugin-core bugsee-sourcemaps-doctor dist # human report
npx --package=@bugsee/bundler-plugin-core bugsee-sourcemaps-doctor dist --json # machine-readable report (schemaVersion 1)
npx --package=@bugsee/bundler-plugin-core bugsee-sourcemaps-doctor dist --strict # exit 1 on warnings too
```

The binary ships in `@bugsee/bundler-plugin-core`, not in a package of its own name, so always name the package (a bare `npx bugsee-sourcemaps-doctor` asks the public registry for an unrelated, unclaimed name unless it happens to be linked into `node_modules/.bin`; pnpm and Yarn link only the bins of direct dependencies). With the package as a direct dependency, `pnpm exec bugsee-sourcemaps-doctor dist` works too.

Exit codes: 0 ok, 1 warnings only (with `--strict`), 2 errors. Options: `--project-root <dir>` (where `.env.bugsee-build-plugin` and `package.json` are looked up; default the working directory), `--max-map-mb <n>`, `--no-env` (skip the token / version / build / `NODE_ENV` checks), `--deployed` (the directory is, or is about to be, served: leftover `.map` files become a warning instead of a note), `--exclude <glob>` (files the build did not emit, e.g. `sw.js` or `pdf.worker.min.mjs*` for scripts copied from Vite's `publicDir` (it lands at the ROOT of the output) or by a copy plugin, relative to the checked directory, a leading `./` is fine; a pattern that matches nothing is reported as `output.exclude-unmatched`: the plugin never stamps those and a doctor cannot tell them from a bundle that lost its stamp; repeatable; `*` stays in a directory, `**` crosses them; matches are listed as `output.excluded`), `--ignore <id>` (drop a check ID; repeatable; `output.dir-missing`, `output.no-js` and `doctor.internal-error` cannot be ignored), `--` (end of options); `--key=value` works for options that take a value, and `--strict=false`-style values on flags are refused. Before the upload (hidden maps still on disk, the plugin will delete them) and after it (maps removed), `--strict` passes on a healthy build; add `--deployed` only when checking the directory you serve. Straight after a default plugin run `--strict` passes for a build whose output directory holds only what the build emitted (add `--exclude` for copied-in scripts): leftover maps are a note unless `--deployed`, and a pointer to maps removed on purpose from a fully stamped build is a note.

It checks, each with a stable ID, a severity and a fix hint: the output directory and its JavaScript; the debug-ID comment and `_bugseeDebugIds` registration on every bundle; a matching map with the same ID; `sourceMappingURL` pointers (dangling, hidden, inline); map validity (v3, `sources`, `sourcesContent` embedded or resolvable on disk, size); mixed stamped/unstamped bundles; duplicate IDs across different contents; Subresource Integrity hazards and mismatches (pages and `*manifest*.json` inside the directory only; a page larger than 8 MiB is reported, not scanned); leftover `.map` files that a deploy would serve; development-mode bundles; and the build environment (token present, version and build resolvable, `NODE_ENV`). The token value is never printed; the report says where it came from (option, environment variable, or `.env.bugsee-build-plugin`), and a missing token is a warning, because uploading by hand is legitimate. When the checked directory is itself a project directory (has a `package.json`) and is, or contains, the working directory, the walk skips `src`/`test`/dot-directories and stops below depth 6 so it stays out of a source tree; the skipped directories are listed as `output.walk-fenced`, never silent. The doctor never throws (an internal failure is a `doctor.internal-error` finding), never reads outside the checked directory, never opens a FIFO, socket or device (they are reported), reads a symlink only when its real path stays inside the checked directory (a pnpm-style `assets/app.js -> ../.store/app.js` is fine; one that leads out, dangles or loops is reported), judges type and size on the open file descriptor, and checks a map's size before reading it. Programmatic use: `diagnoseBuildOutput(dir, options)` returns the same report. The backend-assisted checks (is this ID's map uploaded?) are not part of this command; see `docs/source-maps-usage.md` §4.

The rest of the programmatic API beyond the plugins and the doctor is internal and may change between releases.

## Links

Expand Down
Loading