| 19 | |
| 20 | |
| 21 | def collect(ui_dir, dep_tree, out, excluded): |
| 22 | for name, info in (dep_tree or {}).items(): |
| 23 | version = info.get("version") |
| 24 | if not version: |
| 25 | continue # unmet optional peer — not installed, nothing shipped |
| 26 | pkg_dir = os.path.join(ui_dir, "node_modules", *name.split("/")) |
| 27 | try: |
| 28 | with open(os.path.join(pkg_dir, "package.json"), encoding="utf-8") as fh: |
| 29 | meta = json.load(fh) |
| 30 | except (OSError, ValueError): |
| 31 | continue # not physically installed — nothing shipped |
| 32 | # Platform-restricted packages (os/cpu fields) are native build |
| 33 | # tooling (esbuild/rollup/lightningcss/oxide binaries). They cannot |
| 34 | # be part of a browser bundle — exclude them and do not recurse into |
| 35 | # their dependency subtrees (wasm runtime shims etc.). |
| 36 | if meta.get("os") or meta.get("cpu"): |
| 37 | excluded.add((name, version)) |
| 38 | continue |
| 39 | out.add((name, version)) |
| 40 | collect(ui_dir, info.get("dependencies"), out, excluded) |
| 41 | |
| 42 | |
| 43 | def license_text(pkg_dir): |