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.

ESBuildMinifyPlugin with format: iife breaks Webpack Module Federation

See original GitHub issue

Bug description

ESBuildMinifyPlugin with format: iife breaks Webpack Module Federation

Same error if you set format: iife in parent/child MF project.

Reproduction

With format: iife you get error after button click: https://codesandbox.io/s/webpack-module-federation-forked-rcl1v3?file=/comic/webpack.config.js image

Without format: iife you don’t get error after button click: https://codesandbox.io/s/webpack-module-federation-forked-c7fo45?file=/comic/webpack.config.js

Node.js package manager

npm

Environment

Checkout codesandbox

Can you contribute a fix?

  • I’m interested in opening a pull request for this issue.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
crutch12commented, Jul 20, 2022

@privatenumber I don’t want to have some global variables in window. I’ve got a bug with window._ intersection before…

0reactions
crutch12commented, Aug 6, 2022

Are you using the minifier to transpile?

I didn’t know but used it as transpiler 😃 I missed node_modules when was building with esbuild-loader And then minifier transpiled my ...spread syntax with global functions.

So it’s okay to run without iife, but you should transpile all .js like files like this:

{
  // test: /\.tsx?$/, // doesn't transpile node_modules .js/.cjs/.mjs/etc.
  test: /\.[cm]?[jt]sx?$/,
  loader: 'esbuild-loader',
  options: {
    loader: 'tsx',
    target: 'es2015',
  },
},
Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: minifier used to transpile pollutes global scope ... - GitHub
I've got another problem with format: 'iife' - it breaks Webpack Module Federation :D #258 ...
Read more >
Module Federation - webpack
This object is used as a shared scope in the remote container and is filled with the provided modules from a host. It...
Read more >
Tutorial - A Guide to Module Federation for Enterprise
This plugin by Module Federation Author Zack Jackson allows for tapping into the Webpack MutateRuntime compilation hook to mutate publicPath ...
Read more >
Webpack module federation is not working with eager shared ...
I was looking into Webpack 5 Module federation feature, and have some trouble understanding why my code does not work.
Read more >
Getting Started with Module Federation - YouTube
Learn all about this exciting new way to share code between web applications. This is a code level walkthrough where you get to...
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