You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
export in library works only for last entry module #15936
Sorry, my memory is a little fuzzy on this issue (I'm trying to use the discussion thread to re-jog my memory https://github.com/orgs/webpack/discussions/15929).
I think the issue was around exposing the exported functions to the HTML from multiple files. As far as I could find out, exporting everything to a global library should have done exactly this but it wouldn't.
Because I was trying to modernise a very large legacy system, adding additional scripts to every page wasn't feasible and neither was barrel files. In the end, I didn't touch the older stuff and only modernised newer functionality because of this friction with webpack (I originally decided to use webpack because I thought it had this functionality and would allow me to move forward whilst keeping the system functioning).
Basically, if webpack exposed all exported functions for a named global library, I would expect it to also expose all exported functions for a non-named library. The fact that only the last entry gets exposed does feel like a bug and not intented (maybe it should be all or none?)
I've traced the root cause: in AbstractLibraryPlugin.js, finishEntryModule is only called on the last entry dependency (deps[deps.length - 1]), so exports from earlier entries in the array are never flagged as used and get dropped from the library output.
My plan is to call finishEntryModule for all entry dependencies and adjust the startup runtime so the library exposes the merged exports of all entry modules, plus add test cases under test/configCases/library. Please let me know if this direction sounds right — happy to adjust based on feedback.
I've implemented the approach described in my earlier comment — fix in the library plugin layer, test case included, zero regressions in the library test suite. The PR (#21662) was auto-closed by the quality bot, which appears to be flagging my contributor history rather than the change itself (CLA signed, changeset included). Would a maintainer be willing to take a look and reopen if the approach looks right?
Activity
webpack-bot commentedon Sep 16, 2022
This issue had no activity for at least three months.
It's subject to automatic issue closing if there is no activity in the next 15 days.
alexander-akait commentedon Sep 16, 2022
bump
alan-agius4 commentedon Sep 19, 2022
Is there any workaround for this? Other than creating a barrel?
alexander-akait commentedon Sep 19, 2022
@alan-agius4 currently, no workaround (only multi compiler builds), but feel free to fix send a PR with fix
TGRHavoc commentedon Dec 6, 2022
Does anyone know where one would get started at debugging/fixing this issue?
Judahmeek commentedon Jan 29, 2024
@TGRHavoc I'd start by checking what the default for the
output.library.nameconfiguration is.A client of mine used some custom output.library.name logic back in the day to support multiple library sub-modules.
9 remaining items
fix: expose exports from all entry modules in library output
whoami-amrit commentedon Apr 11, 2026
I was trying to replicate this issue and noticed as per the documentation, we are multi-part entries are used in this case - https://github.com/webpack/webpack/tree/main/examples/multi-part-library
So this seems like a intentional design choice. Don't you think?
Workarounds
index.html@TGRHavoc
TGRHavoc commentedon Apr 11, 2026
Sorry, my memory is a little fuzzy on this issue (I'm trying to use the discussion thread to re-jog my memory https://github.com/orgs/webpack/discussions/15929).
I think the issue was around exposing the exported functions to the HTML from multiple files. As far as I could find out, exporting everything to a global library should have done exactly this but it wouldn't.
Because I was trying to modernise a very large legacy system, adding additional scripts to every page wasn't feasible and neither was barrel files. In the end, I didn't touch the older stuff and only modernised newer functionality because of this friction with webpack (I originally decided to use webpack because I thought it had this functionality and would allow me to move forward whilst keeping the system functioning).
Basically, if webpack exposed all exported functions for a named global library, I would expect it to also expose all exported functions for a non-named library. The fact that only the last entry gets exposed does feel like a bug and not intented (maybe it should be all or none?)
webdevelopersrinu commentedon Aug 10, 2026
Hi I'd like to work on this issue.
I've traced the root cause: in
AbstractLibraryPlugin.js,finishEntryModuleis only called on the last entry dependency (deps[deps.length - 1]), so exports from earlier entries in the array are never flagged as used and get dropped from the library output.My plan is to call
finishEntryModulefor all entry dependencies and adjust the startup runtime so the library exposes the merged exports of all entry modules, plus add test cases undertest/configCases/library. Please let me know if this direction sounds right — happy to adjust based on feedback.webdevelopersrinu commentedon Aug 10, 2026
I've implemented the approach described in my earlier comment — fix in the library plugin layer, test case included, zero regressions in the library test suite. The PR (#21662) was auto-closed by the quality bot, which appears to be flagging my contributor history rather than the change itself (CLA signed, changeset included). Would a maintainer be willing to take a look and reopen if the approach looks right?
LeonxLJX commentedon Sep 2, 2026
feat(entry): add entry.mergeExports to expose every entry module's ex…
feat(library): add library.mergeEntryExports to expose every entry mo…
feat(library): add library.entryExports to expose every entry module
feat(library): add library.entryExports to expose every entry module
feat(library): add library.entryExports to expose every entry module
feat(library): add library.entryExports to expose every entry module (#…