Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: hoisting for "module-import" externals should be present in dynamic chunk#20559

Open
stefanbinoj wants to merge 2 commits intowebpack:mainfrom
stefanbinoj:fix/hoisting_imports
Open

feat: hoisting for "module-import" externals should be present in dynamic chunk#20559
stefanbinoj wants to merge 2 commits intowebpack:mainfrom
stefanbinoj:fix/hoisting_imports

Conversation

@stefanbinoj
Copy link
Contributor

fixes #20362

Before (main branch) After (new branch)
Screenshot 2026-02-25 at 7 25 38 AM Screenshot 2026-02-25 at 8 21 37 AM

What kind of change does this PR introduce?
Previously while having externalsType: 'module-import' and one external: external-lib this external-lib was hoisted in the entry point of bundled output. This PR aims to hoist this external-lib to the dynamic chunk where importing of this package was done

Did you add tests for your changes?
Yes

Does this PR introduce a breaking change?
No

If relevant, what needs to be documented once your changes are merged or what have you already documented?
I think so, since it is a feat request

Also take a look at this repo the org_dist/ shows previously generated bundles with hoisting in main entry point while dist/ shows new bundle that have been ran with this new branch it has hoisted only in dynamic chunk!

@changeset-bot
Copy link

changeset-bot bot commented Mar 1, 2026

⚠️ No Changeset found

Latest commit: 29f0198

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@stefanbinoj
Copy link
Contributor Author

Hi @alexander-akait just wanted to check if this is the right solution or not? As it passes the tests (that i have written) also fixes the issue in minimal reporducable repo as said in the description.

Or should the fix be around chunkInitFragments as commented in #20362 (comment)

if (
this._resolveExternalType(this.externalType) === "module" &&
this.buildInfo &&
this.buildInfo.javascriptModule
Copy link
Contributor Author

Choose a reason for hiding this comment

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

checks output is esm

@alexander-akait
Copy link
Member

That is wrong fix

@alexander-akait
Copy link
Member

We should look at chunkInitFragments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"module-import" externals from dynamic chunks are added/hoisted into the main entrypoint instead of the dynamic chunk

2 participants