question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack 5 and Module Fed.: Duplication of lib code when using multiple named entry points and eager: true

See original GitHub issue

Bug report

When having several named entry points and sharing a lib with eager:true, the lib code is duplicated to all resulting bundles.

Example for entry points:

  entry: {
    main: "./shell/main", 
    styles: "./shell/styles.css",
    polyfills: "./shell/polyfills"
  },

Example for shared:

      shared: {
        "rxjs": {
          eager: true,
          singleton: true,
        },
      }

What is the current behavior?

The shared lib is duplicated to all bundles (main and polyfills in the example shown).

What is the expected behavior?

The shared lib should not be duplicated but only put into one bundle

Other relevant information: webpack version: Every version since webpack 5 Node.js version: 16.13.2 LTS Operating System: windows Additional tools: no

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
manfredsteyercommented, Jan 13, 2022

Thanks for this info. At first sight, dependOn works nicely:

entry: {
  main: { 
    import: "./shell/main",
    dependOn: 'polyfills'
  }, 
  styles: "./shell/styles.css",
  polyfills: "./shell/polyfills"
},
0reactions
webpack-botcommented, May 8, 2022

Issue was closed because of inactivity.

If you think this is still a valid issue, please file a new issue with additional information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module Federation - webpack
A container is created through a container entry, which exposes asynchronous access to the specific modules. The exposed access is separated into two...
Read more >
Webpack module federation is not working with eager shared ...
It seems like the main reason of why it failed initially was that remoteEntry.js file was loaded after the code that actually runs...
Read more >
Webpack 5 Module Federation: A game-changer in JavaScript ...
A scalable solution to sharing code between independent applications has never been convenient, and near impossible at scale.
Read more >
How to Build a Micro Frontend with Webpack's Module ...
Introduced in Webpack 5, the Module Federation plugin gives developers a way to create multiple separate builds that form a single application.
Read more >
How to Build a Micro Frontend with Webpack's Module ... - Bitovi
Introduced in Webpack 5, the Module Federation plugin gives developers a way to create multiple separate builds that form a single application.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found