New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

import-remote-module

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

import-remote-module

在webpack5构建的项目时,使用federation实现加载在线模块,并且实现*动态加载在线模块*

  • 0.0.1
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

webpack5 federation 动态加载模块

在webpack5构建的项目时,使用federation实现加载在线模块,并且实现动态加载在线模块

安装

npm i require-remote

使用

import requireRemote, {setRemoteConfig} from 'require-remote';

setRemoteConfig({
  vizComponent: 'http://localhost:8887/vizComponent/remoteEntry.js'
})

const ButtonGroup = requireRemote('vizComponent/libs/ButtonGroup')

<ButtonGroup 
  dimensionsData={[
    {label: '状态A', value: 'a'}, 
    {label: '状态B', value: 'b'}
  ]} 
/>

webpack config中配置

const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');

config.plugins.push(
  new ModuleFederationPlugin({
    name: 'vizWeb',
    shared: {
      react: { singleton: true },
      'react-dom': { singleton: true },
    },
  }),
);

FAQs

Package last updated on 11 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc