Skip to content

fix(@angular/build): scope createRequire module resolution using paths to prevent parent paths#33483

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:fix/strict-module-resolution-paths
Jun 30, 2026
Merged

fix(@angular/build): scope createRequire module resolution using paths to prevent parent paths#33483
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:fix/strict-module-resolution-paths

Conversation

@clydin

@clydin clydin commented Jun 29, 2026

Copy link
Copy Markdown
Member

Ensure that custom resolvers created via createRequire use the strict paths resolution option when checking for the presence of local packages (such as zone.js, @angular/localize, @angular/core, or vitest test environments). This prevents Node's resolver from using the parent module context (located inside the virtual store .pnpm) and falsely finding packages that are not direct dependencies of the project.

@clydin clydin added the target: patch This PR is targeted for the next patch release label Jun 29, 2026
@clydin clydin linked an issue Jun 29, 2026 that may be closed by this pull request
1 task

@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 introduces a new utility function, createProjectResolver, to standardize and strictly scope module resolution to the project root, replacing various inline usages of createRequire across multiple builder and runner files. The feedback suggests improving the robustness of this utility by using path.join instead of manual slash concatenation, which can be fragile and prone to platform-specific path separator issues on Windows.

Comment thread packages/angular/build/src/utils/resolve-project.ts
…s to prevent parent paths

Ensure that custom resolvers created via createRequire use the strict paths resolution option when checking for the presence of local packages (such as zone.js, @angular/localize, @angular/core, or vitest test environments). This prevents Node's resolver from using the parent module context (located inside the virtual store .pnpm) and falsely finding packages that are not direct dependencies of the project.
@clydin clydin force-pushed the fix/strict-module-resolution-paths branch from 160426e to 927ac07 Compare June 29, 2026 14:50
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jun 29, 2026
@clydin clydin requested a review from alan-agius4 June 29, 2026 15:08
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 30, 2026
@alan-agius4 alan-agius4 merged commit 0010b92 into angular:main Jun 30, 2026
41 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

@clydin clydin deleted the fix/strict-module-resolution-paths branch June 30, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vitest error import zone.js/testing after updating to v22

2 participants