JSPM

next-external-remotes-plugin

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 160
  • Score
    100M100P100Q82486F
  • License MIT

Package Exports

  • next-external-remotes-plugin
  • next-external-remotes-plugin/index.js

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 (next-external-remotes-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

next-external-remotes-plugin

This plugin is a fork from Zackary Jackson's ExternalTemplateRemotesPlugin (https://www.npmjs.com/package/external-remotes-plugin) and it was adapted to work properly with NextFederationPlugin (https://www.npmjs.com/package/@module-federation/nextjs-mf).

Installation

Using npm:

$ npm i next-external-remotes-plugin

Env config

In your env configuration add the URL for remote:

APP1="https://url-to-my-mf-in-some-environment"

Host next.config.js

Add the remote URL to publicRuntimeConfig, and the NextFederationPlugin and NextExternalTemplateRemotesPlugin config as follow:

const NextExternalTemplateRemotesPlugin = require('next-external-remotes-plugin');
    
module.exports = {    
    // ...
    // ...
    webpack(config) {
            config.plugins.push(
                new NextFederationPlugin({
                    name: 'container',
                    remotes: {
                        app1: 'app1@[window.__NEXT_DATA__.runtimeConfig.app1]'
                    },
                    filename: 'static/chunks/container.js',
                    shared: {},
                }),
                new NextExternalTemplateRemotesPlugin()
            );

        return config;
    },
    publicRuntimeConfig: {
        app1: process.env.APP1
    },
    // ...
    // ...
}