Skip to content

fix(@angular/build): alias createRequire banner import to avoid duplicate binding#32765

Open
arturovt wants to merge 1 commit intoangular:mainfrom
arturovt:fix/duplicate-createRequire
Open

fix(@angular/build): alias createRequire banner import to avoid duplicate binding#32765
arturovt wants to merge 1 commit intoangular:mainfrom
arturovt:fix/duplicate-createRequire

Conversation

@arturovt
Copy link
Contributor

ESBuild processes banner content as raw text outside of its module graph, so it cannot deduplicate or rename banner imports the way it does for user imports. If user code already imports createRequire from node:module, the injected banner produces a duplicate binding that causes a runtime error.

Alias the banner import to __ngCreateRequire to avoid colliding with any createRequire binding that esbuild may emit from bundled user code.

@arturovt arturovt force-pushed the fix/duplicate-createRequire branch from 7c6fc3b to 4dc0efb Compare March 13, 2026 17:17
@arturovt arturovt changed the title fix(bundle): alias createRequire banner import to avoid duplicate binding fix(@angular/build): alias createRequire banner import to avoid duplicate binding Mar 13, 2026
…cate binding

ESBuild processes banner content as raw text outside of its module graph,
so it cannot deduplicate or rename banner imports the way it does for user
imports. If user code already imports `createRequire` from `node:module`,
the injected banner produces a duplicate binding that causes a runtime error.

Alias the banner import to `__ngCreateRequire` to avoid colliding with any
`createRequire` binding that esbuild may emit from bundled user code.
@arturovt arturovt force-pushed the fix/duplicate-createRequire branch from 4dc0efb to 861a1b1 Compare March 13, 2026 17:20
Copy link

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

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 aliases an import of createRequire in an esbuild banner to prevent a potential duplicate binding issue. However, the same fix is needed in another location within the same file to fully resolve the problem.

Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

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

LGTM

@alan-agius4 alan-agius4 added target: patch This PR is targeted for the next patch release action: merge The PR is ready for merge by the caretaker labels Mar 13, 2026
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.

2 participants