Skip to content

fix(federation): enable minification for production bundles — @originjs/vite-plugin-federation workaround #99

Description

@ojfbot

Problem

`@originjs/vite-plugin-federation` ≤1.4.x mangles its own placeholder identifiers (`_federation_expose`, `_federation_shared`) when esbuild or terser minification is applied, causing the remote to fail at runtime in the shell.

Current workaround in `packages/browser-app/vite.config.ts`:
```ts
build: {
minify: false, // affects the ENTIRE build, not just the federation chunk
}
```

This ships the production bundle (~1.6 MB exposed Dashboard chunk + main bundle) completely unminified, causing a page-load regression and exposing source-level identifiers.

Goal

Re-enable minification for production builds while keeping Module Federation working.

Investigation paths

  1. Upgrade vite-plugin-federation — check if a version > 1.4.1 fixes minification.
  2. Selective exclusion via rollupOptions — skip minification for remoteEntry.js chunk only.
  3. Terser keep_fnames — may preserve federation identifiers while minifying the rest.
  4. Check upstream: https://github.com/originjs/vite-plugin-federation/issues

Acceptance criteria

  • pnpm build produces a minified dist/assets/remoteEntry.js
  • Shell mounts cv-builder Dashboard without runtime errors
  • No _federation* identifier mangling in output

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions