Repository navigation
fix(@angular/build): strip tooling fields from package.json and improve tslib resolution in library builder - #34314
alan-agius4 wants to merge 1 commit into
Conversation
…ve tslib resolution in library builder Strip additional development and tooling configuration fields (`ngPackage`, `browserslist`, `prettier`, `stylelint`, `jest`, `husky`) from generated `package.json` manifests, avoid adding `tslib` to `dependencies` when already present in `peerDependencies`, and fallback to local package resolution for `tslib` when not hoisted at the workspace root.
There was a problem hiding this comment.
Code Review
This pull request updates the library builder pipeline to strip additional development and tooling fields from the generated package.json, prevents adding tslib to dependencies if it is already specified in peerDependencies, and introduces a fallback mechanism to resolve packages locally when they cannot be resolved from the workspace root. A review comment points out that using __filename with createRequire in the fallback resolver will cause a ReferenceError at runtime in ES modules, and suggests using import.meta.url instead.
| try { | ||
| return workspaceRequire.resolve(specifier); | ||
| } catch { | ||
| localRequire ??= createRequire(__filename); |
There was a problem hiding this comment.
In Node.js ES modules (ESM), the global __filename variable is not defined and will throw a ReferenceError at runtime if the fallback path is triggered. Since @angular/build is distributed as ESM and requires modern Node.js versions, you should use import.meta.url with createRequire instead of __filename.
| localRequire ??= createRequire(__filename); | |
| localRequire ??= createRequire(import.meta.url); |
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Strip additional development and tooling configuration fields (
ngPackage,browserslist,prettier,stylelint,jest,husky) from generatedpackage.jsonmanifests, avoid addingtslibtodependencieswhen already present inpeerDependencies, and fallback to local package resolution fortslibwhen not hoisted at the workspace root.