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

Skip to content

fix: respect entryFileNames directory for bootstrap file output#786

Merged
gioboa merged 2 commits into
module-federation:mainfrom
LumeWeb:fix/bootstrap-entryFileNames-path
Jun 7, 2026
Merged

fix: respect entryFileNames directory for bootstrap file output#786
gioboa merged 2 commits into
module-federation:mainfrom
LumeWeb:fix/bootstrap-entryFileNames-path

Conversation

@pcfreak30

Copy link
Copy Markdown
Contributor

The MF bootstrap file was emitted with a hardcoded fileName (mf-entry-bootstrap-N.js) at the build root, bypassing Rollup's entryFileNames pattern. When users configure entryFileNames to place JS in a subdirectory (e.g. static/js/), the bootstrap file still landed at the root while all other entries went to static/js/.

Derive the directory prefix from the emitted hostInit file path at build time (since Vite/Rolldown normalizes entryFileNames before plugins can read it). Rebase the import paths inside the bootstrap to be relative to its new location instead of the HTML root, preventing doubled paths like static/js/static/js/.

Falls back to root-level output when no subdirectory is detected for backward compatibility.


The new bootstrap concept broke how I use MF, and so this adds back the needed flexibility for my use case.

@pcfreak30

Copy link
Copy Markdown
Contributor Author

@gioboa

@pkg-pr-new

pkg-pr-new Bot commented Jun 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@module-federation/vite@786

commit: ca8db0e

@pcfreak30 pcfreak30 force-pushed the fix/bootstrap-entryFileNames-path branch from cb6e989 to 9907029 Compare June 6, 2026 20:27
@pcfreak30

Copy link
Copy Markdown
Contributor Author

@gioboa please re-approve workflow run

@gioboa gioboa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for your help @pcfreak30
I have two small comments:

  • With base: "/app/", the bootstrap file is emitted under static/js/, but the generated host init import is rebased to ../app/static/js/hostInit-abc.js. From static/js/, this resolves incorrectly; it should import the sibling file as ./hostInit-abc.js.
  • Absolute URLs should not be rebased. When renderBuiltUrl or similar returns https://..., rebaseImport() currently treats it like a local bare path and rewrites it to ../https://..., producing an invalid import URL.

pcfreak30 added 2 commits June 7, 2026 15:28
The MF bootstrap file was emitted with a hardcoded fileName
(mf-entry-bootstrap-N.js) at the build root, bypassing Rollup's
entryFileNames pattern. When users configure entryFileNames to
place JS in a subdirectory (e.g. static/js/), the bootstrap file
still landed at the root while all other entries went to static/js/.

Derive the directory prefix from the emitted hostInit file path at
build time (since Vite/Rolldown normalizes entryFileNames before
plugins can read it). Rebase the import paths inside the bootstrap
to be relative to its new location instead of the HTML root,
preventing doubled paths like static/js/static/js/.

Falls back to root-level output when no subdirectory is detected
for backward compatibility.
@pcfreak30 pcfreak30 force-pushed the fix/bootstrap-entryFileNames-path branch from 58b89df to ca8db0e Compare June 7, 2026 19:28
@pcfreak30

Copy link
Copy Markdown
Contributor Author

@gioboa done

@pcfreak30

Copy link
Copy Markdown
Contributor Author

@gioboa if you still see issues, let me know how to re-prod as an example so I can troubleshoot.

@gioboa gioboa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tests With Different Frameworks

Screenshot 2026-06-07 at 22 09 53

@gioboa gioboa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That's amazing thanks @pcfreak30 👏

@gioboa gioboa merged commit 701a696 into module-federation:main Jun 7, 2026
19 checks passed
@pcfreak30 pcfreak30 deleted the fix/bootstrap-entryFileNames-path branch June 7, 2026 20:42
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.

2 participants