Skip to content

fix(@angular/build): strip tooling fields from package.json and improve tslib resolution in library builder - #34314

Closed
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix/library-package-manifests-cleanup
Closed

alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix/library-package-manifests-cleanup

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

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.

…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.
@alan-agius4
alan-agius4 deleted the fix/library-package-manifests-cleanup branch October 12, 2026 12:53

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
localRequire ??= createRequire(__filename);
localRequire ??= createRequire(import.meta.url);

@angular-automatic-lock-bot

Copy link
Copy Markdown

This pull request has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Nov 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant