0.21.8 • Published 1 year ago

@leanjs/webpack v0.21.8

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@leanjs/webpack

Installation

If you use a monorepo (recommended) execute the following command at the root of your repository:

yarn add -D -W @leanjs/webpack webpack

If your app is not in a monorepo, then run the following command instead of the above:

yarn add -D @leanjs/webpack webpack

RemoteWebpackPlugin

This plugin is an abstractions built on top of the following Webpack plugins:

  • ModuleFederationPlugin from webpack/lib/container/ModuleFederationPlugin
  • HtmlWebpackPlugin from html-webpack-plugin
  • VirtualModulesPlugin from webpack-virtual-modules

Basic usage

const { RemoteWebpackPlugin } = require("@leanjs/webpack");

module.exports = {
  plugins: [new RemoteWebpackPlugin()],
};

Configuration

RemoteWebpackPlugin(config: RemoteWebpackOptions) accepts the following arguments

interface RemoteWebpackOptions {
  /**
   * Add shared dependencies manually. Not required in a monorepo.
   * If this Webpack config is in a monorepo, this plugin will automatically
   * generate the shared dependencies based on the dependency graph
   */
  shared?: SharedDependencies;
  shared?: Record<string, string | SharedDependencies>;
}

interface SharedDependencies {
  /**
   * Include the provided and fallback module directly instead of async.
   * This allows to use this shared module in initial load too.
   * All possible shared modules need to be eager too.
   */
  eager?: boolean;

  /**
   * Version requirement from module in share scope.
   */
  requiredVersion?: string | false;

  /**
   * Allow only a single version of the shared module in share scope
   * (disabled by default).
   */
  singleton?: boolean;

  /**
   * Do not accept shared module if version is not valid
   * (defaults to yes, if local fallback module is available
   * and shared module is not a singleton, otherwise,
   * has no effect if there is no required version specified)
   */
  strictVersion?: boolean;

  /**
   * Version of the provided module.
   * Will replace lower matching versions, but not higher.
   */
  version?: string | false;
}

HostWebpackPlugin

This plugin is an abstractions built on top of the following Webpack plugins:

  • ModuleFederationPlugin from webpack/lib/container/ModuleFederationPlugin

Basic usage

const { HostWebpackPlugin } = require("@leanjs/webpack");

module.exports = {
  plugins: [new HostWebpackPlugin()],
};

Configuration

HostWebpackPlugin(config: HostWebpackOptions) accepts the following arguments

interface HostWebpackOptions {
  /**
   * Add shared dependencies manually. Not required in a monorepo.
   * If this Webpack config is in a monorepo, this plugin will automatically
   * generate the shared dependencies based on the dependency graph
   */
  shared?: SharedDependencies;
  /**
   * Define what dependencies are automatically shared.
   * You can disable auto sharing passing false to it.
   */
  autoShared?: AutoShared | boolean;
  /**
   * Applies to all shared dependencies that don't have `eager` defined.
   */
  eager?: boolean;
  /**
   * Which packages are managed by Module Federation.
   * By default none of the packages.
   */
  remotes?: {
    packages: string[];
  };
}

interface AutoShared {
  excludePackages?: string[];
  excludeDirPattern?: string;
}

interface SharedDependencies {
  /**
   * Include the provided and fallback module directly instead of async.
   * This allows to use this shared module in initial load too.
   * All possible shared modules need to be eager too.
   */
  eager?: boolean;

  /**
   * Version requirement from module in share scope.
   */
  requiredVersion?: string | false;

  /**
   * Allow only a single version of the shared module in share scope
   * (disabled by default).
   */
  singleton?: boolean;

  /**
   * Do not accept shared module if version is not valid
   * (defaults to yes, if local fallback module is available
   * and shared module is not a singleton, otherwise,
   * has no effect if there is no required version specified)
   */
  strictVersion?: boolean;

  /**
   * Version of the provided module.
   * Will replace lower matching versions, but not higher.
   */
  version?: string | false;
}
0.21.8

1 year ago

0.21.7

1 year ago

0.21.6

1 year ago

0.21.5

1 year ago

0.21.4

1 year ago

0.21.3

1 year ago

0.21.2

2 years ago

0.21.1

2 years ago

0.21.0

2 years ago

0.20.11

2 years ago

0.20.12

2 years ago

0.20.10

2 years ago

0.20.1

2 years ago

0.20.0

2 years ago

0.19.20

2 years ago

0.19.21

2 years ago

0.20.9

2 years ago

0.20.8

2 years ago

0.20.7

2 years ago

0.20.6

2 years ago

0.20.5

2 years ago

0.20.4

2 years ago

0.20.3

2 years ago

0.20.2

2 years ago

0.19.19

2 years ago

0.19.8

2 years ago

0.19.9

2 years ago

0.19.0

2 years ago

0.19.1

2 years ago

0.19.2

2 years ago

0.19.3

2 years ago

0.19.4

2 years ago

0.19.5

2 years ago

0.19.6

2 years ago

0.19.7

2 years ago

0.19.11

2 years ago

0.19.12

2 years ago

0.19.13

2 years ago

0.19.14

2 years ago

0.19.15

2 years ago

0.19.16

2 years ago

0.19.17

2 years ago

0.19.18

2 years ago

0.19.10

2 years ago

0.11.8

2 years ago

0.11.9

2 years ago

0.11.1

2 years ago

0.13.0

2 years ago

0.11.2

2 years ago

0.13.1

2 years ago

0.15.0

2 years ago

0.13.2

2 years ago

0.11.4

2 years ago

0.15.1

2 years ago

0.13.3

2 years ago

0.11.5

2 years ago

0.17.0

2 years ago

0.13.4

2 years ago

0.11.6

2 years ago

0.17.1

2 years ago

0.13.5

2 years ago

0.11.7

2 years ago

0.18.1

2 years ago

0.18.2

2 years ago

0.12.0

2 years ago

0.14.0

2 years ago

0.10.5

2 years ago

0.16.0

2 years ago

0.16.1

2 years ago

0.18.0

2 years ago

0.10.4

2 years ago

0.10.3

2 years ago

0.10.2

2 years ago

0.10.1

2 years ago

0.10.0

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.9.0

2 years ago

0.8.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago