Notoriously Punctual Manatee

    esbuild-federation-share-scope
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.2 • Public • Published

    esbuild-federation-share-scope

    Enables federation share scope for interop with Webpack 5 Module Federation containers.

    Usage

    Bundler configuration:

    esbuild.build({
      // ... your usual config
      plugins: [
        federationShareScopePlugin(process.cwd(), {
          shared: ["react"],
          // OR:
          // shared: {
          //   "react": {
          //     shareKey: "react",
          //     shareScope: ["default"],
          //     version: "17.0.0"
          //   }
          // }
        }),
      ],
    });

    Access to share scope:

    // Effectively __webpack_init_sharing__, __webpack_share_scopes__ respectively
    import { initSharing, shareScopes } from "@runtime/federation";
    
    // external webpack built federation container
    const container = window[remote];
    
    // initialize share scope
    initSharing("default")
      // initialize the container
      .then(() => container.init(shareScopes[shareScope]))
      // get an exposed module
      .then(() => container.get("./exposed"))
      // run the module factory to get the module value
      .then(factory => factory())

    Keywords

    none

    Install

    npm i esbuild-federation-share-scope

    DownloadsWeekly Downloads

    1

    Version

    0.0.2

    License

    ISC

    Unpacked Size

    6.3 kB

    Total Files

    8

    Last publish

    Collaborators

    • jacob-ebey