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可实现加载在线模块,import-remote-module配合federation实现动态加载在线模块

  • 0.0.3
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

webpack5 federation 动态加载模块

使用webpack5构建项目时,使用federation可实现加载在线模块,import-remote-module配合federation实现动态加载在线模块

安装

npm i import-remote-module

使用

import importRemote, {setRemoteConfig} from 'import-remote-module';

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

const ButtonGroup = importRemote('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