single-spa vs @angular-architects/module-federation vs @module-federation/nextjs-mf vs import-map-overrides
Micro Frontend Frameworks
single-spa@angular-architects/module-federation@module-federation/nextjs-mfimport-map-overridesSimilar Packages:
Micro Frontend Frameworks

Micro Frontend Frameworks are architectural patterns that allow multiple teams to develop and deploy independent frontend applications that can be integrated into a single user interface. This approach promotes scalability, team autonomy, and technology diversity, enabling organizations to build large applications more efficiently. Micro Frontend Frameworks provide tools and libraries to manage the integration of these independent applications, handle routing, share state, and ensure seamless communication between them. They help overcome challenges related to monolithic frontend architectures, such as long release cycles, tight coupling, and difficulty in adopting new technologies. By leveraging Micro Frontend Frameworks, organizations can improve collaboration, reduce dependencies, and deliver features faster while maintaining a cohesive user experience.

Npm Package Weekly Downloads Trend
3 Years
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
single-spa384,21413,8162.12 MB55a year agoMIT
@angular-architects/module-federation155,630817203 kB4106 months agoMIT
@module-federation/nextjs-mf73,8482,340171 kB8021 days agoMIT
import-map-overrides16,161362230 kB135 months agoMIT
Feature Comparison: single-spa vs @angular-architects/module-federation vs @module-federation/nextjs-mf vs import-map-overrides

Framework Compatibility

  • single-spa:

    single-spa is also framework-agnostic, allowing you to integrate applications built with different frameworks into a single micro frontend architecture.

  • @angular-architects/module-federation:

    @angular-architects/module-federation is specifically designed for Angular applications, providing seamless integration with Angular CLI and Angular's module system.

  • @module-federation/nextjs-mf:

    @module-federation/nextjs-mf is tailored for Next.js applications, leveraging Next.js features like server-side rendering and static site generation while implementing Module Federation.

  • import-map-overrides:

    import-map-overrides is framework-agnostic and can be used with any JavaScript application that supports import maps, making it versatile for various projects.

Code Sharing

  • single-spa:

    single-spa supports code sharing between micro frontends by allowing them to register shared dependencies, ensuring that shared libraries are loaded only once.

  • @angular-architects/module-federation:

    @angular-architects/module-federation enables code sharing between Angular applications by configuring shared modules and components in the Webpack configuration.

  • @module-federation/nextjs-mf:

    @module-federation/nextjs-mf facilitates code sharing between Next.js applications using Module Federation, allowing you to share components and utilities across different Next.js projects.

  • import-map-overrides:

    import-map-overrides allows for dynamic code sharing by modifying the import map at runtime, enabling you to override module paths and share code as needed.

Dynamic Imports

  • single-spa:

    single-spa supports dynamic imports of micro frontends, allowing them to load and unload as needed based on the application's routing and state.

  • @angular-architects/module-federation:

    @angular-architects/module-federation supports dynamic imports of Angular modules, allowing you to load modules on demand and reduce the initial bundle size.

  • @module-federation/nextjs-mf:

    @module-federation/nextjs-mf supports dynamic imports of Next.js components and modules, enabling on-demand loading and improving performance.

  • import-map-overrides:

    import-map-overrides enhances dynamic imports by allowing you to override module paths at runtime, making it easier to test and develop with different module versions.

Routing and Navigation

  • single-spa:

    single-spa provides a robust routing system for micro frontends, allowing you to define routes for each micro frontend and manage navigation between them.

  • @angular-architects/module-federation:

    @angular-architects/module-federation integrates with Angular's routing system, allowing you to define routes for federated modules and navigate between them seamlessly.

  • @module-federation/nextjs-mf:

    @module-federation/nextjs-mf works with Next.js routing, allowing you to define routes for federated components and navigate between them while leveraging Next.js's built-in routing features.

  • import-map-overrides:

    import-map-overrides does not handle routing directly, but it can be used alongside any routing solution to dynamically override module imports based on the current route or application state.

Ease of Use: Code Examples

  • single-spa:

    Single SPA Example

    import { registerApplication, start } from 'single-spa';
    
    registerApplication(
      'app1',
      () => import('http://localhost:3001/app1.js'),
      (location) => location.pathname.startsWith('/app1')
    );
    
    registerApplication(
      'app2',
      () => import('http://localhost:3002/app2.js'),
      (location) => location.pathname.startsWith('/app2')
    );
    
    start();
    
  • @angular-architects/module-federation:

    Angular Module Federation Example

    // webpack.config.js
    const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
    
    module.exports = {
      plugins: [
        new ModuleFederationPlugin({
          name: 'app1',
          filename: 'remoteEntry.js',
          exposes: {
            './Component': './src/app/component/component.ts',
          },
          shared: { angular: { singleton: true } },
        }),
      ],
    };
    
  • @module-federation/nextjs-mf:

    Next.js Module Federation Example

    // next.config.js
    const { ModuleFederationPlugin } = require('webpack').container;
    
    module.exports = {
      webpack: (config) => {
        config.plugins.push(
          new ModuleFederationPlugin({
            name: 'app2',
            filename: 'remoteEntry.js',
            remotes: {
              app1: 'app1@http://localhost:3001/remoteEntry.js',
            },
            shared: { react: { singleton: true }, 'react-dom': { singleton: true } },
          })
        );
        return config;
      },
    };
    
  • import-map-overrides:

    Import Map Overrides Example

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>Import Map Overrides</title>
      <script type="importmap">
        {
          "imports": {
            "lodash": "https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.js"
          }
        }
      </script>
      <script src="https://unpkg.com/import-map-overrides"></script>
      <script>
        // Override the lodash import
        importMapOverrides.setOverrides({
          "lodash": "https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.js"
        });
    
        import('lodash').then((_) => {
          console.log(_.VERSION);
        });
      </script>
    </head>
    <body>
    </body>
    </html>
    
How to Choose: single-spa vs @angular-architects/module-federation vs @module-federation/nextjs-mf vs import-map-overrides
  • single-spa:

    Opt for single-spa if you are building a micro frontend architecture that requires a framework-agnostic solution. single-spa allows you to integrate multiple frontend applications built with different frameworks (e.g., React, Angular, Vue) into a single application. It provides a robust routing system and lifecycle management for each micro frontend, ensuring smooth transitions and efficient resource loading.

  • @angular-architects/module-federation:

    Choose @angular-architects/module-federation if you are working on an Angular application and want to implement Module Federation for sharing code between multiple Angular apps. This package provides a straightforward setup and configuration for Angular projects, making it easy to integrate with existing Angular CLI workflows.

  • @module-federation/nextjs-mf:

    Select @module-federation/nextjs-mf if you are using Next.js and want to leverage Module Federation to share components, utilities, or other code between different Next.js applications. This package is optimized for Next.js and provides features that align with its architecture, making it ideal for projects that heavily utilize Next.js features.

  • import-map-overrides:

    Use import-map-overrides if you need to dynamically override module imports in your application, especially during development or testing. This package allows you to modify the import map at runtime, enabling you to swap out modules, use local versions, or test different implementations without changing the original codebase.

README for single-spa

npm version NPM Downloads

single-spa

Join the chat on Slack

Donate to this project

Official single-spa hosting

baseplate-logo-standard

A javascript framework for front-end microservices

Build micro frontends that coexist and can (but don't need to) be written with their own framework. This allows you to:

Sponsors

DataCamp-Logo Toast-Logo asurion-logo

To add your company's logo to this section:

Documentation

You can find the single-spa documentation on the website.

Check out the Getting Started page for a quick overview.

Demo and examples

Please see the examples page on the website.

Want to help?

Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing on the single-spa website.

Contributing

The main purpose of this repository is to continue to evolve single-spa, making it better and easier to use. Development of single-spa, and the single-spa ecosystem happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving single-spa.

Code of Conduct

Single-spa has adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.

Contributing Guide

Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to single-spa.