refactor: replace loadEsmModule with dynamic import()#31539
Merged
alan-agius4 merged 1 commit intoangular:mainfrom Oct 21, 2025
Merged
refactor: replace loadEsmModule with dynamic import()#31539alan-agius4 merged 1 commit intoangular:mainfrom
loadEsmModule with dynamic import()#31539alan-agius4 merged 1 commit intoangular:mainfrom
Conversation
fe08dd7 to
22f7ebc
Compare
clydin
reviewed
Oct 21, 2025
packages/angular/build/src/tools/angular/compilation/angular-compilation.ts
Outdated
Show resolved
Hide resolved
packages/angular/build/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.ts
Show resolved
Hide resolved
22f7ebc to
c3e25f9
Compare
c3e25f9 to
109141a
Compare
The custom `loadEsmModule` helper function was a workaround to prevent TypeScript from downleveling dynamic imports to `require()` calls, which would fail to load ESM modules. With modern TypeScript and Node.js versions, this workaround is no longer necessary. This commit removes the `loadEsmModule` utility and replaces all its usages with standard dynamic `import()` expressions. This simplifies the codebase and relies on the native module loading capabilities of the environment.
109141a to
4e0a0f9
Compare
clydin
approved these changes
Oct 21, 2025
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The custom
loadEsmModulehelper function was a workaround to prevent TypeScript from downleveling dynamic imports torequire()calls, which would fail to load ESM modules.With modern TypeScript and Node.js versions, this workaround is no longer necessary. This commit removes the
loadEsmModuleutility and replaces all its usages with standard dynamicimport()expressions.This simplifies the codebase and relies on the native module loading capabilities of the environment.