Skip to content

Conversation

@ScriptedAlchemy
Copy link
Member

@ScriptedAlchemy ScriptedAlchemy commented Apr 13, 2024

Description

If a runtime chunk has entrypoints which do not contain runtime plugins or they are tree shaken, startup will fail

Related Issue

#2343
Resolves problem like this:

__webpack_require__.federation.initOptions.plugins = ([
	/* unused export ["default"] */ undefined ? /* unused export ["default"] */ undefined() : false,
	/* unused export ["default"] */ undefined ? /* unused export ["default"] */ undefined() : false,
].filter(Boolean))

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

@netlify
Copy link

netlify bot commented Apr 13, 2024

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 3979f46
🔍 Latest deploy log https://app.netlify.com/sites/module-federation-docs/deploys/661f72e6946c3100086bf299
😎 Deploy Preview https://deploy-preview-2324--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ScriptedAlchemy ScriptedAlchemy self-assigned this Apr 15, 2024
'])',
Template.indent(
runtimePLuginNames.map(
(item) => `${item} ? ${item}() : false,`,
Copy link
Member

Choose a reason for hiding this comment

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

we should filter the shaked plugin , and it's content should not be false, otherwise the runtime will throw error
image

Copy link
Member Author

Choose a reason for hiding this comment

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

like this?

    this.options.plugins = this.options.plugins.reduce((res, plugin) => {
      if(!plugin) return res;
      if (res && !res.find((item) => item.name === plugin.name)) {
        res.push(plugin);
      }
      return res;
    }, pluginRes || []);
    ```

Copy link
Member

Choose a reason for hiding this comment

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

Yeah that's nice

@ScriptedAlchemy ScriptedAlchemy merged commit 648353b into main Apr 17, 2024
@ScriptedAlchemy ScriptedAlchemy deleted the fix/unused-plugin branch April 17, 2024 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants