Skip to content

[Bug]: Cannot build module into UMD #350

@peawyoyoyin

Description

@peawyoyoyin

Describe the bug

Hello,

I am trying to use Vite to build my project into a remote module-federated application. However, due to my company's policy, we cannot move to ESM yet because we still need to support old browsers.

I am trying to build the module in to UMD format, however, seems like the module-federation/vite plugin always add pre-defined chunks (loadShare / remoteInit) into final bundle, so rollup thinks it is a code-splitting build. This fails rollup's internal validation.

Other formats also do not work:

  • There's a separate bug in systemJS that breaks 'system' with shared dependencies.
  • 'amd' and 'cjs' also do not work because my app has shared dependencies, adding shared dependencies uses top-level await which is not supported.
  • iife does not work similar to UMD.

Version

6.0.5

Reproduction

https://github.com/peawyoyoyin/mfe-vite-umd-issue-reproduction

Relevant log output

error during build:
Invalid value "umd" for option "output.format" - UMD and IIFE output formats are not supported for code-splitting builds.

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions