JSPM

  • Created
  • Published
  • Downloads 211888
  • Score
    100M100P100Q191384F
  • License MulanPSL2

A Vite plugin which support Module Federation.

Package Exports

  • @originjs/vite-plugin-federation

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@originjs/vite-plugin-federation) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

vite-plugin-federation

A Vite plugin which support Module Federation. Inspired by Webpack Module Federation feature.

Install

Using npm:

npm install @originjs/vite-plugin-federation --save-dev

Usage

  • for a Vite project, in vite.config.js:
import { defineConfig } from 'vite'
import federation from "@originjs/vite-plugin-federation";

export default defineConfig({
  plugins: [
    federation({
      name: 'module-name',
      filename: 'remoteEntry.js',
      exposes: {
        './Button': './src/Button.vue',
      },
      remotes:{
          foo: 'remote_foo'
      }
      shared: ['vue']
    })
  ],
})
  • for a Rollup project, in rollup.config.js:
import federation from '@originjs/vite-plugin-federation'

export default {
  input: 'src/index.js',
  output: {
    format: 'esm',
    dir: 'dist'
  },
  plugins: [
    federation({
      filename: 'remoteEntry.js',
      exposes: {
        './Button': './src/button'
      },
      shared: ['react']
    })
  ]
}

Examples