Repository navigation
feat(builder): list the packages of the federation bundles in 3rdpartylicenses.txt - #193
jonmarozick wants to merge 2 commits into
Conversation
…ylicenses.txt With extractLicenses, Angular writes 3rdpartylicenses.txt from the metafiles of its own bundles. The shared and exposed bundles are built in the adapter's own esbuild contexts, so none of their packages were listed; only notices kept as legal comments survived. The adapter now keeps the latest metafile of each bundle (the node-modules bundler gains metafile: true; shared bundles keep core's file-name matching). After each successful Angular output, the builder appends an entry for every package Angular's file lacks, using a port of Angular's license extractor so rules and format match. Builds that extract licenses bundle the shared externals without the cache, because a cache hit runs no esbuild. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Hey thanks for this! I've found a few points though:
Before merging, we'll also need a green CI checkmark |
Fixes #192.
What changes
src/tools/esbuild/license-extractor.ts: a port of Angular'sextractLicenses(// upstream:tag at11dbe297f8, MIT notice kept). It differs from upstream only in thatEXTRACTION_FILE_SEPARATORis exported, and twoeslint-disable-next-line no-emptycomments sit on Angular's emptycatch {}blocks. A spec runs Angular's own extractor (loaded by path, asassets.spec.tsdoes) on the same fixtures and expects identical output.metafile: true(angular-bundler.tsalready did).metafiles()). Shared bundles don't pass their new metafile toentriesByOutputName, so core keeps matching them by file name as before.extractLicensesand this isn't the dev server, then after each successful Angular output it appends to the3rdpartylicenses.txtat the output root an entry for every package of the federation bundles that the file doesn't contain yet. Entries are compared as whole text: both sides come from the same extractor, so a package Angular already listed is skipped, and Angular's part of the file is left byte for byte.cacheExternalArtifactsdescription inschema.jsonsays so.Trade-off: the externals cache in production builds
On a remote with 9 shared packages (Windows, warm
.angular/cache, three runs each), a production build took 11.3–13.2 s without the externals cache and 9.6–10.8 s with it. CI builds that start without a cache are unaffected. Development builds andng servekeep the cache.If you'd rather keep the cache in production too, core would have to persist something per shared bundle (for example the input paths with
bytesInOutput > 0) in its cache metadata and hand it back on a hit. I'm happy to do that next in core and here, but it changes core's adapter contract, so I didn't want to start with it.Not changed
legalCommentsstaysoptimize ? 'eof' : 'inline'. With this change it could follow Angular ('none'underextractLicenses), but that changes bundle output, so it belongs in its own change.dist/node_modules/<dep>/without apackage.jsonare skipped.remotebuilder runs no Angular application build, so there is no3rdpartylicenses.txtto complete.Tests
license-extractor.spec.ts: parity with Angular's extractor; tree-shaken andSEE LICENSE INcases.federation-licenses.spec.ts: appends after Angular's entries; ends up identical to what Angular writes when it bundles everything itself; adds nothing on a second run; leaves the file alone when nothing is missing; writes nothing when Angular wrote no file.entry.pnpm typecheck,pnpm lint(0 errors, same warnings asmain),pnpm knipandpnpm buildpass.pnpm teston Windows: the 10 new tests pass. The 33 failures are the same 33 that fail onmainon this machine (symlinkEPERMwithout Developer Mode, backslash paths). I couldn't run the suite on Linux.fromPackageJsonwithdenseChunkinganddenseExternals, this branch packed and installed into a copy of the app.node_modulespackage named in the maps is listed, except two that a library vendors without apackage.json(see above).ng serve: servesremoteEntry.json.🤖 Generated with Claude Code