Let /cso prepare npm apps whose lockfile has bundled dependencies (#4777) (#4787)

`/cso --comprehensive` can now prepare npm apps whose
`package-lock.json` lists bundled dependencies, such as Next.js apps on
Tailwind CSS 4, instead of stopping with `UNPINNED_ARCHIVE`.

This keeps /cso's full audit usable on common JavaScript projects
without loosening its rule that every download is pinned to a hash.

Nothing to do.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-24 16:28:43 +00:00
1 parent d74ee528b6
commit f34b7aac22
3 files changed
+66

No files matched your search

+16
View File
@@ -310,6 +310,22 @@ function inspectNode(root: string, plan: PreparationPlan) {
if (!NAME.test(name) || typeof raw.version !== 'string' || !VERSION.test(raw.version))
fail('INVALID_METADATA', 'Locked npm package needs an exact name and version.', lockPath);
for (const field of DEPENDENCY_FIELDS) dependencySpecs(raw[field], lockPath);
if (raw.inBundle === true && raw.resolved === undefined) {
// A bundled package ships inside its bundler's tarball, so that archive must be pinned instead.
let owner = path;
do {
const cut = owner.lastIndexOf('/node_modules/');
if (cut < 0) fail('UNPINNED_ARCHIVE', 'Bundled npm package has no pinned parent archive.', lockPath);
owner = owner.slice(0, cut);
} while (record(lock.packages[owner]) && lock.packages[owner].inBundle === true);
const bundler = lock.packages[owner];
if (!record(bundler) || bundler.link === true || !owner.split('/').includes('node_modules'))
fail('UNPINNED_ARCHIVE', 'Bundled npm package has no pinned parent archive.', lockPath);
publicUrl(bundler.resolved, ['registry.npmjs.org'], lockPath);
integrity(bundler.integrity, lockPath);
delete clean.packages[path].scripts;
continue;
}
plan.inputs.push({
kind: 'public',
name,