Giter Site home page Giter Site logo

module-federation-exposes-webpack-plugin's Introduction

module-federation-exposes-webpack-plugin

安装

$ yarn add module-federation-exposes-webpack-plugin -D

or

$ npm install module-federation-exposes-webpack-plugin -D

使用

webpack.config.ts:

import path from "path";
import webpack, { Configuration } from "webpack";
import ModuleFederationExposesPlugin from "module-federation-exposes-webpack-plugin";

const config: Configuration = {
  plugins: [
    new ModuleFederationExposesPlugin({
      exportFile: path.resolve(__dirname, "index.ts"),
      generateDir: path.resolve(__dirname, "../exposes"),
      transform: (libraryName: string) => {
        return libraryName.replace("./", "../fixtures/");
      },
    }),
  ],
};

export default config;

exportFile导出文件的内容如下时:

export { map } from "./utils";
export { get as myGet } from "./utils";
export { get, pick as myPick } from "./utils";
export { default } from "./utils";
export { default as Utils, filter } from "./utils";
export * as util from "./utils";
export * from "./utils";
export type { TUtils } from "./utils";

会在当前目录的上一级生成 exposese 文件夹,文件列表如下:

文件名 内容
map.ts export { map as default } from "../fixtures/utils";
myGet.ts export { get as default } from "../fixtures/utils";
get.ts export { get as default } from "../fixtures/utils";
myPick.ts export { pick as default } from "../fixtures/utils";
default.ts export { default } from "../fixtures/utils";
Utils.ts export { default } from "../fixtures/utils";
filter.ts export { filter as default } from "../fixtures/utils";
util.ts export * as default from "../fixtures/utils";
inde.json { "./map": "./exposes/map", "./myGet": "./exposes/myGet", "./get": "./exposes/get", "./myPick": "./exposes/myPick", "./default": "./exposes/default", "./Utils": "./exposes/Utils", "./filter": "./exposes/filter","./util": "./exposes/util"}

配置

字段名 类型 是否必填 默认值 描述
exportFile string 导出组件的入口文件
generateDir string 生成的文件目录
filetype ts | js ts 生成的文件类型
transform (libraryName: string) => string 转换引入的包名称

module-federation-exposes-webpack-plugin's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.