How can I scan the JavaScript packages that actually ship in a bundle?

November 16, 2026 4 answers
Asked by _s82~ticketcog.5

I'm generating SBOMs with Syft and sending them to Dependency-Track, but the lockfile scan includes build tools as well as packages that may end up in the browser bundle.

Some Laravel projects put frontend packages in devDependencies, so filtering those out doesn't seem reliable. How can I tell what ships, and should CI still scan the whole lockfile?

Answers

4w~socketladle_593

Use the bundler's own build output as evidence. Webpack can emit JSON compilation stats, and esbuild has a metafile that records inputs contributing to outputs. Capture that from the release build and map the module paths back to package names and versions in the lockfile.

For Vite builds, rollup-plugin-visualizer can produce raw data showing modules associated with chunks. Check what the report includes for your particular build rather than assuming every listed module survived intact. Tree shaking can remove parts of a module, and being in a chunk doesn't prove a vulnerable function is reachable.

w.397!zelmor:

Keeping the report alongside the release artifact also makes it easier to investigate a finding against the build that actually shipped.

Reply to this answer
7c!gaugepocket_582

Keep two views. Scan the full lockfile for build-time exposure, then use bundle evidence to prioritize what may affect the deployed app. A compromised build dependency can matter even if its code never ships to the browser.

I wouldn't fail every build just to drive the CVE count down. Triage the affected dependency, how it's used, and whether an upgrade is practical. The devDependencies label alone doesn't settle whether code ships.

Reply to this answer
q.368~drizzlefob

If you want an SBOM directly from the build, look at rollup-plugin-sbom for a Vite or Rollup setup, or cyclonedx/webpack-plugin for webpack. Compare the generated components with the lockfile and bundle output on a test project before relying on it as your deployed inventory.

8n!pixelwrench_637:

The bundler-generated SBOM and the lockfile SBOM answer different questions, so it can be useful to retain both.

Reply to this answer
Vellin-3q

Source maps can help identify bundled sources, but I wouldn't treat a smaller SBOM as proof that it's complete. Check the result against the bundler's module or input report, including split chunks. If you generate maps for analysis, decide separately whether they should be included in the deployed artifact.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions