{"_id":"@module-federation/dev-server","_rev":"28-45cce9a16aebd84cb3dd71808aa1a22a","name":"@module-federation/dev-server","dist-tags":{"latest":"0.0.15","next":"0.0.0-next-20240401084119"},"versions":{"0.0.15":{"name":"@module-federation/dev-server","version":"0.0.15","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.15","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"b9653fec03cf3e537f50da8f7a093d4b4b1bd31d","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.15.tgz","fileCount":51,"integrity":"sha512-TpOHPZSEt9utU0QY6UFV2Jig4duK3mJJzlYSc2pvK6wyhfT0nSaBMicpu0Lr/AyYzLT7wskvtVTRSjSUSoql/w==","signatures":[{"sig":"MEQCIBSyNTWXFEiVBSFJx7P3FKfg4/2rIADxJSQ/tmsVZZaSAiAgdgXqt2l76GmnvBFUkYLzw0eruGRi1Z7H+R5qgIcaaQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137283},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.15.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/c1fa4acf5554d4d278fe86de1a5cf9c2/module-federation-dev-server-0.0.15.tgz","_integrity":"sha512-TpOHPZSEt9utU0QY6UFV2Jig4duK3mJJzlYSc2pvK6wyhfT0nSaBMicpu0Lr/AyYzLT7wskvtVTRSjSUSoql/w==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.15"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.15_1711013331850_0.024922447455079766","host":"s3://npm-registry-packages"}},"0.0.0-next-20240321102113":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240321102113","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240321102113","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"ed863b4b63fe548ed9bc058ca79beaaeb994b7c6","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240321102113.tgz","fileCount":51,"integrity":"sha512-unUWN5X1dQ1F1dsrn5gf70opUeeXdxn+Xpc0viPmnwkiwcM7KJEtzS6m9zDvFXj0Uwja+wJ4z4ZvUgvDA+8BFA==","signatures":[{"sig":"MEYCIQD8PPF6pgZtxVnd6xXlULzuwZCFS4leZiCcJOzWvvENaQIhAIIi5ubyJNTzk+GRPEDnnHb3Sjh/IEkzRNj25PqLcxYg","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137321},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240321102113.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/bdbe9a8a63c4f312b540df4a1776d35c/module-federation-dev-server-0.0.0-next-20240321102113.tgz","_integrity":"sha512-unUWN5X1dQ1F1dsrn5gf70opUeeXdxn+Xpc0viPmnwkiwcM7KJEtzS6m9zDvFXj0Uwja+wJ4z4ZvUgvDA+8BFA==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240321102113"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240321102113_1711016486644_0.8390999114431932","host":"s3://npm-registry-packages"}},"0.0.0-next-20240321124455":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240321124455","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240321124455","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"ee7f735eb8438772b8117c31251a144da778fa4f","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240321124455.tgz","fileCount":51,"integrity":"sha512-8I45EedIP7DXAkIKs2kudr3cHV+uN4VHM6lPb8/8bu81LWggYMTb11hPYJ2hprirGcCzJuAtbFIxvrKaPNCxPg==","signatures":[{"sig":"MEUCIG8m2vAC3KFy2HITfD72SIbGJ/g+rkY+zi1AmC/KIxj3AiEAlWZcaZ8PCsq0vbkZeSXlt/ts2SneJzGQK9v9kd8tP88=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137321},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240321124455.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/3213fd85d6f3941255149d56b20c62d2/module-federation-dev-server-0.0.0-next-20240321124455.tgz","_integrity":"sha512-8I45EedIP7DXAkIKs2kudr3cHV+uN4VHM6lPb8/8bu81LWggYMTb11hPYJ2hprirGcCzJuAtbFIxvrKaPNCxPg==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240321124455"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240321124455_1711025108627_0.6654069635773339","host":"s3://npm-registry-packages"}},"0.0.0-next-20240321142841":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240321142841","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240321142841","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"c7da6e9ff7b849e2f97d8b7dd5d32e2203085232","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240321142841.tgz","fileCount":51,"integrity":"sha512-AAEV8kRR86Pu6H4D/H6K1/pr/bato93jIC3Khw3L+UgSnoeLt4lPEj67j/E4r6j1oTMMoHQ/s01LGrA32QiuWQ==","signatures":[{"sig":"MEUCIQCnlXEbQIbJQwZNP97/Lf7FO0YDchEsT1lm6VY80Su40wIgcJAW3w/ANjsTmDQ1I08Q24AR/8oN4FnT9y5Cc9aqA8Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137655},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240321142841.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/898abde3b6349801daa9d465626f8d78/module-federation-dev-server-0.0.0-next-20240321142841.tgz","_integrity":"sha512-AAEV8kRR86Pu6H4D/H6K1/pr/bato93jIC3Khw3L+UgSnoeLt4lPEj67j/E4r6j1oTMMoHQ/s01LGrA32QiuWQ==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240321142841"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240321142841_1711031335080_0.9305335303973992","host":"s3://npm-registry-packages"}},"0.0.0-next-20240322034056":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240322034056","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240322034056","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"573b8b778a0c119f04b187ca6a94b1c5a955f597","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240322034056.tgz","fileCount":51,"integrity":"sha512-Sq723hJET8Rz9+IBn+fis2aPvOIiLGsRJI4JYdxqsb82upllNEm5LUGsJS+xls5I9p8jcYz681qEQh+kukJmkQ==","signatures":[{"sig":"MEUCIQCATqhgeH/CBc+NokgqzWg69pxxK/2HUkD/ndcL2FCoqQIgXe7L5vj4G8we45OE1MpHWHY9ydTKkMGSEgn3eGgrJ+w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137655},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240322034056.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/4ba9cdc61de9fce49cfbca6c318bdb66/module-federation-dev-server-0.0.0-next-20240322034056.tgz","_integrity":"sha512-Sq723hJET8Rz9+IBn+fis2aPvOIiLGsRJI4JYdxqsb82upllNEm5LUGsJS+xls5I9p8jcYz681qEQh+kukJmkQ==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240322034056"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240322034056_1711078868636_0.5408527449657259","host":"s3://npm-registry-packages"}},"0.0.0-next-20240324060529":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240324060529","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240324060529","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"4c00a91c2e7452fbe1468353069cfe5c2f6b06a8","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240324060529.tgz","fileCount":51,"integrity":"sha512-nRdSlud4sjqh42ToxW59I23ARN105KjRVNvACQViTkpCL5614XtuX2emI+6lZDRUeFJoOKU2j6tbm6KyMv99ag==","signatures":[{"sig":"MEUCIQCj9AMj3F+SA+zYa0khw7QEcfuGHzUNd1HroW5OrkaEnwIgHgRKW2zD8YBQNuAIGjCn4YtGWzEqBQOdd4cq/MipAcQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137655},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240324060529.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/b14a06de039fe42b0461c228d72a8589/module-federation-dev-server-0.0.0-next-20240324060529.tgz","_integrity":"sha512-nRdSlud4sjqh42ToxW59I23ARN105KjRVNvACQViTkpCL5614XtuX2emI+6lZDRUeFJoOKU2j6tbm6KyMv99ag==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240324060529"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240324060529_1711260341884_0.14833644137085833","host":"s3://npm-registry-packages"}},"0.0.0-next-20240324065321":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240324065321","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240324065321","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"8d3961aa6eb1155a5c358181201e03096443fd18","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240324065321.tgz","fileCount":51,"integrity":"sha512-RRBrXsXcd6GjpnEG8X7PsrcY1uTpEQiekWXBSPmQeBlLv0XifLJaibpbP0ORkaRXcYJIKV14ELNyASAJnzHAEA==","signatures":[{"sig":"MEQCIHRebRQB1VNhwr5BL9KC8TQd1PNobc6de4nfmhKEubElAiADrUYfGhdYz5Mz8DcWTq+ZatK2yNGstc2jnFZ7PmYyWw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137649},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240324065321.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/73ba681c403e7cc6791b91c2cd8551be/module-federation-dev-server-0.0.0-next-20240324065321.tgz","_integrity":"sha512-RRBrXsXcd6GjpnEG8X7PsrcY1uTpEQiekWXBSPmQeBlLv0XifLJaibpbP0ORkaRXcYJIKV14ELNyASAJnzHAEA==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240324065321"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240324065321_1711263214136_0.25781629939744044","host":"s3://npm-registry-packages"}},"0.0.0-next-20240324073358":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240324073358","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240324073358","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"d38ad5e0e67e1d3c44f5d584f21d73e8b746e822","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240324073358.tgz","fileCount":51,"integrity":"sha512-ZspE/5h76FKBOwE+ACGD9rFBWXuH4tF8qB2ZM7Upjhcp3MKlxVJR0WXrJNp01xqSvxF+weTDs6SwETQmXtVuvA==","signatures":[{"sig":"MEYCIQCwVlplVIkV/a05x2Uqmy22ngNvX2vovH8xw52tVrySPgIhAPYiy/S72BrufnoPc38O7ChZVhhperqT8LIE8BBsGHGg","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137649},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240324073358.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/589ee347a3923a1ad94a866448b3bebd/module-federation-dev-server-0.0.0-next-20240324073358.tgz","_integrity":"sha512-ZspE/5h76FKBOwE+ACGD9rFBWXuH4tF8qB2ZM7Upjhcp3MKlxVJR0WXrJNp01xqSvxF+weTDs6SwETQmXtVuvA==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240324073358"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240324073358_1711265650934_0.5975014896224002","host":"s3://npm-registry-packages"}},"0.0.0-next-20240324082735":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240324082735","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240324082735","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"e3efd3f870aaf0694f8d911b2f60c4fb0c503aee","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240324082735.tgz","fileCount":51,"integrity":"sha512-WJn7E4Sk2mEYTXTx+8lbQ9M+1GpWM4uobvwM1au/Dfipa1B1Iq/BdVgMxSmZ+V/t/jz2SMnWz10egCZf1wl2VQ==","signatures":[{"sig":"MEYCIQCum/8ZVTILlvdn4AbKLSCBF4dzZ0Hd966KtP+tWALnpgIhAKS1YwSvy6tTsqE22Y31Zu81LaoLMeLTMR/DUAeQmVC9","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137649},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240324082735.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/cb7ee377705c9d29c39103bbc5dd7f8a/module-federation-dev-server-0.0.0-next-20240324082735.tgz","_integrity":"sha512-WJn7E4Sk2mEYTXTx+8lbQ9M+1GpWM4uobvwM1au/Dfipa1B1Iq/BdVgMxSmZ+V/t/jz2SMnWz10egCZf1wl2VQ==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240324082735"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240324082735_1711268868302_0.8935744193597068","host":"s3://npm-registry-packages"}},"0.0.0-next-20240324084915":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240324084915","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240324084915","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"cf50ae14ae8925f0843131284533c5d2de64e34d","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240324084915.tgz","fileCount":51,"integrity":"sha512-aQzkIzo2Ug0nFT+zffI8ZpViWB+vMskM+B5GadMGODD5yPNPgp5gCAQucJhD7qs9+8osv76Db7p01rJQ2iGpSQ==","signatures":[{"sig":"MEQCIFuhNlGD1buhg6aoM4UYSFhRXu5GZOjKG39OkHGpx6cGAiAWMzatBcDMYQ17IaHWVTN6C+YW4v4jWy8BdtYj0856dw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137649},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240324084915.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/ca4ddce36c800d5b0805c4f3bc4fd5e2/module-federation-dev-server-0.0.0-next-20240324084915.tgz","_integrity":"sha512-aQzkIzo2Ug0nFT+zffI8ZpViWB+vMskM+B5GadMGODD5yPNPgp5gCAQucJhD7qs9+8osv76Db7p01rJQ2iGpSQ==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240324084915"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240324084915_1711270167571_0.1489408899894029","host":"s3://npm-registry-packages"}},"0.0.0-next-20240324091053":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240324091053","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240324091053","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"2cc53c67b03cc623289a5e4da575d3d9e75e6090","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240324091053.tgz","fileCount":51,"integrity":"sha512-dFfGhm6oYDbZaPNClmgT1XOvxNKfbLzY3BkA2/tX2FX9QyZQ6QAIC8TaoRiEprwbghYjBwZbWzDpLwZPXKcS3g==","signatures":[{"sig":"MEYCIQCZQiKxJfocYGyTEe7IwPhMHsHNAoHfI5iigZ5gtpQoBgIhAMOSRAf1hC9vg6BuPmwV4pNaoAqEf8sQDGgT4T8FOhjh","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137649},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240324091053.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/5bd5f188a4403130b87bc888b939732e/module-federation-dev-server-0.0.0-next-20240324091053.tgz","_integrity":"sha512-dFfGhm6oYDbZaPNClmgT1XOvxNKfbLzY3BkA2/tX2FX9QyZQ6QAIC8TaoRiEprwbghYjBwZbWzDpLwZPXKcS3g==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240324091053"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240324091053_1711271465285_0.654230156681308","host":"s3://npm-registry-packages"}},"0.0.0-next-20240325030531":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240325030531","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240325030531","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"bb7c16a13d5978c6f1c54fe756f43e2f2c4b2d1b","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240325030531.tgz","fileCount":51,"integrity":"sha512-le3+PDejzJTmCqWqOu/MJCzxC37YvV7PkV6+k9Ft288eRaOTp5hZZnUTtnTi9bGNpmA80x0OhM2NcsMi7qajAA==","signatures":[{"sig":"MEUCIDqU7rYV+SYXb0Jiho2AsKU2L3EShGeD0Pum8SJwSX2WAiEAwn0+kItEqy96vGCzcKbiABOY914DeLuHT7jGyNLnPms=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137649},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240325030531.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/08071761f7129cffc83ad516cad47fef/module-federation-dev-server-0.0.0-next-20240325030531.tgz","_integrity":"sha512-le3+PDejzJTmCqWqOu/MJCzxC37YvV7PkV6+k9Ft288eRaOTp5hZZnUTtnTi9bGNpmA80x0OhM2NcsMi7qajAA==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240325030531"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240325030531_1711335944438_0.40976181801556155","host":"s3://npm-registry-packages"}},"0.0.0-next-20240325035415":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240325035415","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240325035415","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"dd77b975844b509165d712458b5a229511c16087","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240325035415.tgz","fileCount":51,"integrity":"sha512-Ps7C4gnMCrIqGJFoZRSIw3FvHfQOA7XD0XyBS6rzJeLfzwXSyEeIbDpexRRlhPwMhFYCa3j3U2eY1eo4Rys54w==","signatures":[{"sig":"MEUCIQC3K14Sk2eydGCXAq++hz+6WSbBlqo1oB+gNWNcHY9kdAIgHTLEh3e3Xq6mpFxewuJFfihW2OYzRIcodOkZOQTrCLA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137649},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240325035415.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/65310646f13fb027a085335e52aa6f23/module-federation-dev-server-0.0.0-next-20240325035415.tgz","_integrity":"sha512-Ps7C4gnMCrIqGJFoZRSIw3FvHfQOA7XD0XyBS6rzJeLfzwXSyEeIbDpexRRlhPwMhFYCa3j3U2eY1eo4Rys54w==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240325035415"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240325035415_1711338875333_0.010588768983671448","host":"s3://npm-registry-packages"}},"0.0.0-next-20240325072950":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240325072950","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240325072950","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"34d433bc0f90493c3c0add021d3131c607aa1295","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240325072950.tgz","fileCount":51,"integrity":"sha512-qsnAD/4HZ4e0Fcdtv7TmTzlC+UdSML+7ISYIli4thwXCELr96TcQLiYbGYHmrOYp1kiDT6P0iWgtgEkeU0BiLQ==","signatures":[{"sig":"MEUCIQCU19QgI0wAjdjxAeGTz1OO2A9k9LbRzbrQcz4re5GykQIgbshvtbt8FqJBrdsX32uo8TfOIvLRVNYDKPp+V9C2fuM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137649},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240325072950.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/bc121e565a76c719e02d0a21d765c2d5/module-federation-dev-server-0.0.0-next-20240325072950.tgz","_integrity":"sha512-qsnAD/4HZ4e0Fcdtv7TmTzlC+UdSML+7ISYIli4thwXCELr96TcQLiYbGYHmrOYp1kiDT6P0iWgtgEkeU0BiLQ==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240325072950"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240325072950_1711351810940_0.9711887187044379","host":"s3://npm-registry-packages"}},"0.0.0-next-20240325084555":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240325084555","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240325084555","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"7979e131749ab7397bebbb52fa41e327c41622e3","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240325084555.tgz","fileCount":51,"integrity":"sha512-q0XmtZLBUwOQSSRkQQSikI7YfGSKYEyGWKp3j8rPy46fc84ISAV0mp/pbGplWvlAfynmGabFXxxHxtekefhDng==","signatures":[{"sig":"MEUCIQDGkJzJ/eixAy0uerMBJQdNlowlrEkCyCoupHOLSFTD4wIgG17UEoTBJOwgQupxtqM1pCo3WZgeXhdx0koGj9meAWQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137649},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240325084555.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/581adc3bf7b4e9dcb6061afcec3dbd16/module-federation-dev-server-0.0.0-next-20240325084555.tgz","_integrity":"sha512-q0XmtZLBUwOQSSRkQQSikI7YfGSKYEyGWKp3j8rPy46fc84ISAV0mp/pbGplWvlAfynmGabFXxxHxtekefhDng==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240325084555"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240325084555_1711356377455_0.9237738826611346","host":"s3://npm-registry-packages"}},"0.0.0-next-20240325110954":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240325110954","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240325110954","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"483c1fcf9a0346d1a52530297319175bded15e1c","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240325110954.tgz","fileCount":51,"integrity":"sha512-V0+Qdt5S6CHlm6atp5Ty7jF1thNnufpR+neVuZXqKFasryw1KYlAL1ymXQ70AuineZuVz+f+qkWBZqXLhk/s5Q==","signatures":[{"sig":"MEQCIGrhA97LaY3HeeZmLEqlYWzUInVR99LdI78quUDWeMZBAiBNC5rg3OeEFzzY5x7m+yxC5DyHSkzMHzMlOLd0dHosUg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137649},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240325110954.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/ccc201a97dac46d4a7f049bd1584772e/module-federation-dev-server-0.0.0-next-20240325110954.tgz","_integrity":"sha512-V0+Qdt5S6CHlm6atp5Ty7jF1thNnufpR+neVuZXqKFasryw1KYlAL1ymXQ70AuineZuVz+f+qkWBZqXLhk/s5Q==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240325110954"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240325110954_1711365014345_0.8785158297943174","host":"s3://npm-registry-packages"}},"0.0.0-next-20240326061945":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240326061945","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240326061945","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"f0d251a87849644f2346242cdd5aa6cb35f828f9","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240326061945.tgz","fileCount":51,"integrity":"sha512-I40mI+ey5r+1qaLyuft6uDF7UgeZYsfmdGZ9ljkIgskRSByoEMxF0gdKMn3tEYxsJv2MhM8gEnAbj4U1X5o+kQ==","signatures":[{"sig":"MEYCIQCpRSZ+nRYYuk0+1vqVz575qZ4wZWoOgja3dIw9qOs/vQIhAJ+4SBGV9hga6/2X0myXw8F7DZRkk8tIlto5V8wddu8w","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137649},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240326061945.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/9d786e3669f01582b544929cb10805a2/module-federation-dev-server-0.0.0-next-20240326061945.tgz","_integrity":"sha512-I40mI+ey5r+1qaLyuft6uDF7UgeZYsfmdGZ9ljkIgskRSByoEMxF0gdKMn3tEYxsJv2MhM8gEnAbj4U1X5o+kQ==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240326061945"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240326061945_1711434006000_0.9162706081546672","host":"s3://npm-registry-packages"}},"0.0.0-next-20240326081159":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240326081159","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240326081159","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"90244377c80279d66cf1c69c74a1dbde59205b12","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240326081159.tgz","fileCount":51,"integrity":"sha512-2VTn92Vt+rz2wVZfUv2zOHi8KOQti07KcqyPbAGH/Nr26M2+jrvGZpZSuiGbQr+wwosXGZBrJFT8+YQIfD/MRw==","signatures":[{"sig":"MEUCIHbf7/XR0KYyiJVpoTMpqGuyQaK0DZ/peQj8CY8YoUaLAiEA9fF/ujQEwpofSRgXLGbvWoj+B2PmcyPW/9qxbITdQm4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137649},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240326081159.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/3adc126336720537374d2617f95663f8/module-federation-dev-server-0.0.0-next-20240326081159.tgz","_integrity":"sha512-2VTn92Vt+rz2wVZfUv2zOHi8KOQti07KcqyPbAGH/Nr26M2+jrvGZpZSuiGbQr+wwosXGZBrJFT8+YQIfD/MRw==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240326081159"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240326081159_1711440739470_0.12317145835382082","host":"s3://npm-registry-packages"}},"0.0.0-next-20240326102030":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240326102030","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240326102030","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"40de3838d01005e9c16698a237ded22cdc18d63d","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240326102030.tgz","fileCount":51,"integrity":"sha512-a5FXhf6Tlmw8b7NGMRrFyOdQgpU0qMbihK6Sh7SSqjlNk0YGxyX6j2dPUSrKxOQo0THTZYcB8F93bzlliddImw==","signatures":[{"sig":"MEQCIAXFhbUIBhct4Rybc+rknYD7wIxS7mdvpgCDzamI1ghjAiAHqO9x9Kpel06LIyj+hE36aJaAgksUuWj+2QnR2fuggA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137649},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240326102030.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# `@module-federation/runtime`\n\n- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.\n- Only consume part of the export of the remote module and will not fully download the remote module\n- The runtime calling process can be extended through the module-runtime plug-in mechanism\n\n## API\n\n```javascript\n// Can load modules using only the runtime SDK without relying on build plugins\n// When not using build plugins, shared dependencies cannot be automatically reused\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n    name: '@demo/app-main',\n    remotes: [\n        {\n            name: \"@demo/app2\",\n            entry: \"http://localhost:3006/remoteEntry.js\",\n            alias: \"app2\"\n        },\n    ],\n});\n\n// Load by alias\nloadRemote<{add: (...args: Array<number>)=> number }>(\"app2/util\").then((md)=>{\n    md.add(1,2,3);\n});\n```\n\n### init\n\n- Type: `init(options: InitOptions): void`\n- Create runtime instance , it can dynamically register remotes by re-call , but only one instance will exist.\n- InitOptions:\n\n```ts\ntype InitOptions {\n    //The name of the current host\n    name: string;\n    // The version of the current host will use the host version of the corresponding version online.\n    // remoteInfo in remotes will use the online version\n    version?: string;\n    // In the area where the module is deployed, the consumer will transparently transmit this data to the producer\n    //After setting, when the producer data fails to be obtained normally, the backup data will be automatically obtained according to this configuration.\n    region?: `EnhancedRegion`;\n    // List of dependent remote modules\n    // tip: The remotes configured at runtime are not completely consistent with the types and data passed in the build plugin, and the passed in * ^ ~ version rules are not supported at runtime.\n    remotes: Array<RemoteInfo>;\n    // List of dependencies that need to be shared by the current host\n    // When using the build plugin, users can configure the dependencies that need to be shared in the build plugin, and the build plugin will inject the dependencies that need to be shared into the runtime shared configuration.\n    // Shared must be manually passed in the version instance reference when it is passed in at runtime, because it cannot be directly passed in at runtime.\n    shared?: ShareInfos;\n};\n\ntype RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {\n   alias?: string;\n};\n\ninterface RemotesWithVersion {\n   name: string;\n   version: string;\n}\n\ninterface RemotesWithEntry {\n   name: string;\n   entry: string;\n}\n\ntype ShareInfos = {\n   // Dependent package name, dependent basic information, and sharing strategy\n   [pkgName: string]: Share;\n};\n\ntype Share = {\n   // Versions of shared dependencies\n   version: string;\n   //Which modules consume the current shared dependencies?\n   useIn?: Array<string>;\n   //Which module does the shared dependency come from?\n   from?: string;\n   // Get the factory function of the shared dependency instance. When the cached shared instance cannot be loaded, its own shared dependency will be loaded.\n   lib: () => Module;\n   // Sharing strategy, what strategy will be used to determine the reuse of shared dependencies\n   shareConfig?: SharedConfig;\n   // Dependencies between shares\n   deps?: Array<string>;\n   // Under what scope the current shared dependencies are placed, the default is default\n   scope?: string | Array<string>;\n};\n```\n\n### loadRemote\n\n- Type: `loadRemote(id: string)`\n- Used to load initialized remote modules, when used with build plugins, it can be loaded directly through native `import(\"remoteName/expose\")` syntax, and the build plugin will automatically convert it into `loadRemote` usage.\n\n- Example\n\n```javascript\nimport { init, loadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [\n    {\n      name: '@demo/app2',\n      alias: 'app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n    },\n  ],\n});\n\n// remoteName + expose\nloadRemote('@demo/app2/util').then((m) => m.add(1, 2, 3));\n\n// alias + expose\nloadRemote('app2/util').then((m) => m.add(1, 2, 3));\n```\n\n### loadShare\n\n- Type: `loadShare(pkgName: string)`\n- Gets the `share` dependency. When there are `share` dependencies that match the current `host` in the global environment, the existing and satisfying `share` dependencies will be reused first. Otherwise, load its own dependencies and store them in the global cache.\n- This `API` is generally not called directly by users, but is used by build plugins to convert their own dependencies.\n\n- Example\n\n```js\nimport { init, loadRemote, loadShare } from '@module-federation/runtime';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\ninit({\n  name: '@demo/main-app',\n  remotes: [],\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n    'react-dom': {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => ReactDOM,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n});\n\nloadShare('react').then((reactFactory) => {\n  console.log(reactFactory());\n});\n```\n\n### preloadRemote\n\n- Type: `preloadRemote(preloadOptions: Array<PreloadRemoteArgs>)`\n- Used to preload remote assets like remoteEntry.js .\n\n- Type\n\n```typescript\nasync function preloadRemote(preloadOptions: Array<PreloadRemoteArgs>) {}\n\ntype depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;\ntype PreloadRemoteArgs = {\n  // Preload the name and alias of the remote\n  nameOrAlias: string;\n  // Expose to be preloaded\n  // Default to preload all exposes\n  // Only the required expose will be loaded when an expose is provided\n  exposes?: Array<string>; // Default request\n  // Default is sync, only load synchronous code referenced in the expose\n  // Set to all to load synchronous and asynchronous references\n  resourceCategory?: 'all' | 'sync';\n  // Load all dependencies when no value is configured\n  // Only the resources needed will be loaded after configuring the dependency\n  depsRemote?: boolean | Array<depsPreloadArg>;\n  // No filtering of resources when not configured\n  // Will filter out unwanted resources after configuring\n  filter?: (assetUrl: string) => boolean;\n};\n```\n\n- Details\n\n**Info**: Only if the entry is manifest can more resources be loaded. The manifest plugin will be supported in 2024.Q1\n\nThrough `preloadRemote`, module resources can be preloaded at an earlier stage to avoid waterfall requests. `preloadRemote` can preload the following content:\n\n- The `remoteEntry` of `remote`\n- `expose` assets of `remote`\n- Synchronous resources or asynchronous resources of `remote`\n- `remote` resources that `remote` depends on\n\n* Example\n\n```ts\nimport { init, preloadRemote } from '@module-federation/runtime';\n\ninit({\n  name: '@demo/preload-remote',\n  remotes: [\n    {\n      name: '@demo/sub1',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub2',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n    {\n      name: '@demo/sub3',\n      entry: 'http://localhost:2001/vmok-manifest.json',\n    },\n  ],\n});\n\n// Preload @demo/sub1 module\n// Filter resource information that contains ignore in the resource name\n// Only preload sub-dependent @demo/sub1-button modules\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub1',\n    filter(assetUrl) {\n      return assetUrl.indexOf('ignore') === -1;\n    },\n    depsRemote: [{ nameOrAlias: '@demo/sub1-button' }],\n  },\n]);\n\n// Preload @demo/sub2 module\n// Preload all exposes under @demo/sub2\n// Preload the synchronous resources and asynchronous resources of @demo/sub2\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub2',\n    resourceCategory: 'all',\n  },\n]);\n\n// Preload expose of @demo/sub3 module\npreloadRemote([\n  {\n    nameOrAlias: '@demo/sub3',\n    resourceCategory: 'all',\n    exposes: ['add'],\n  },\n]);\n```\n\n## hooks\n\nLifecycle hooks for FederationHost interaction.\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst runtimePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'my-runtime-plugin',\n    beforeInit(args) {\n      console.log('beforeInit: ', args);\n      return args;\n    },\n    beforeRequest(args) {\n      console.log('beforeRequest: ', args);\n      return args;\n    },\n    afterResolve(args) {\n      console.log('afterResolve', args);\n      return args;\n    },\n    onLoad(args) {\n      console.log('onLoad: ', args);\n      return args;\n    },\n    async loadShare(args) {\n      console.log('loadShare:', args);\n    },\n    async beforeLoadShare(args) {\n      console.log('beforeloadShare:', args);\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [runtimePlugin()],\n});\n```\n\n### beforeInit\n\n`SyncWaterfallHook`\n\nUpdates Federation Host configurations before the initialization process of remote containers.\n\n- type\n\n```ts\nfunction beforeInit(args: BeforeInitOptions): BeforeInitOptions;\n\ntype BeforeInitOptions = {\n  userOptions: UserOptions;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  shareInfo: ShareInfos;\n};\n\ninterface FederationRuntimeOptions {\n  id?: string;\n  name: string;\n  version?: string;\n  remotes: Array<Remote>;\n  shared: ShareInfos;\n  plugins: Array<FederationRuntimePlugin>;\n  inBrowser: boolean;\n}\n```\n\n### init\n\n`SyncHook`\n\nCalled during the initialization of remote containers.\n\n- type\n\n```ts\nfunction init(args: InitOptions): void;\n\ntype InitOptions = {\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### beforeRequest\n\n`AsyncWaterfallHook`\n\nInvoked before resolving a remote container, useful for injecting the container or updating something ahead of the lookup.\n\n- type\n\n```ts\nasync function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestOptions>;\n\ntype BeforeRequestOptions = {\n  id: string;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n};\n```\n\n### afterResolve\n\n`AsyncWaterfallHook`\n\nCalled after resolving a container, allowing redirection or modification of resolved information.\n\n- type\n\n```ts\nasync function afterResolve(args: AfterResolveOptions): Promise<AfterResolveOptions>;\n\ntype AfterResolveOptions = {\n  id: string;\n  pkgNameOrAlias: string;\n  expose: string;\n  remote: Remote;\n  options: FederationRuntimeOptions;\n  origin: FederationHost;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot?: ModuleInfo;\n};\n```\n\n### onLoad\n\n`AsyncHook`\n\nTriggered once a federated module is loaded, allowing access and modification to the exports of the loaded file.\n\n- type\n\n```ts\nasync function onLoad(args: OnLoadOptions): Promise<void>;\n\ntype OnLoadOptions = {\n  id: string;\n  expose: string;\n  pkgNameOrAlias: string;\n  remote: Remote;\n  options: ModuleOptions;\n  origin: FederationHost;\n  exposeModule: any;\n  exposeModuleFactory: any;\n  moduleInstance: Module;\n};\n\ntype ModuleOptions = {\n  remoteInfo: RemoteInfo;\n  host: FederationHost;\n};\n\ninterface RemoteInfo {\n  name: string;\n  version?: string;\n  buildVersion?: string;\n  entry: string;\n  type: RemoteEntryType;\n  entryGlobalName: string;\n  shareScope: string;\n}\n```\n\n### handlePreloadModule\n\n`SyncHook`\n\nHandles preloading logic for federated modules.\n\n- type\n\n```ts\nfunction handlePreloadModule(args: HandlePreloadModuleOptions): void;\n\ntype HandlePreloadModuleOptions = {\n  id: string;\n  name: string;\n  remoteSnapshot: ModuleInfo;\n  preloadConfig: PreloadRemoteArgs;\n};\n```\n\n### errorLoadRemote\n\n`AsyncHook`\n\nInvoked if loading a federated module fails, enabling custom error handling.\n\n- type\n\n```ts\nasync function errorLoadRemote(args: ErrorLoadRemoteOptions): Promise<void | unknown>;\n\ntype ErrorLoadRemoteOptions = {\n  id: string;\n  error: unknown;\n  from: 'build' | 'runtime';\n  origin: FederationHost;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst fallbackPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'fallback-plugin',\n    errorLoadRemote(args) {\n      const fallback = 'fallback';\n      return fallback;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  remotes: [\n    {\n      name: '@demo/app2',\n      entry: 'http://localhost:3006/remoteEntry.js',\n      alias: 'app2',\n    },\n  ],\n  plugins: [fallbackPlugin()],\n});\n\nloadRemote('app2/un-existed-module').then((mod) => {\n  expect(mod).toEqual('fallback');\n});\n```\n\n### beforeLoadShare\n\n`AsyncWaterfallHook`\n\nCalled before attempting to load or negotiate shared modules between federated apps.\n\n- type\n\n```ts\nasync function beforeLoadShare(args: BeforeLoadShareOptions): Promise<BeforeLoadShareOptions>;\n\ntype BeforeLoadShareOptions = {\n  pkgName: string;\n  shareInfo?: Shared;\n  shared: Options['shared'];\n  origin: FederationHost;\n};\n```\n\n### resolveShare\n\n`SyncWaterfallHook`\n\nAllows manual resolution of shared module requests.\n\n- type\n\n```ts\nfunction resolveShare(args: ResolveShareOptions): ResolveShareOptions;\n\ntype ResolveShareOptions = {\n  shareScopeMap: ShareScopeMap;\n  scope: string;\n  pkgName: string;\n  version: string;\n  GlobalFederation: Federation;\n  resolver: () => Shared | undefined;\n};\n```\n\n- example\n\n```ts\nimport { init, loadRemote } from '@module-federation/runtime';\n\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst customSharedPlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'custom-shared-plugin',\n    resolveShare(args) {\n      const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;\n\n      if (pkgName !== 'react') {\n        return args;\n      }\n\n      args.resolver = function () {\n        shareScopeMap[scope][pkgName][version] = window.React; // replace local share scope manually with desired module\n        return shareScopeMap[scope][pkgName][version];\n      };\n      return args;\n    },\n  };\n};\n\ninit({\n  name: '@demo/app-main',\n  shared: {\n    react: {\n      version: '17.0.0',\n      scope: 'default',\n      lib: () => React,\n      shareConfig: {\n        singleton: true,\n        requiredVersion: '^17.0.0',\n      },\n    },\n  },\n  plugins: [customSharedPlugin()],\n});\n\nwindow.React = () => 'Desired Shared';\n\nloadShare('react').then((reactFactory) => {\n  expect(reactFactory()).toEqual(window.React());\n});\n```\n\n### beforePreloadRemote\n\n`AsyncHook`\n\nInvoked before any preload logic is executed by the preload handler.\n\n- type\n\n```ts\nasync function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePreloadRemoteOptions;\n\ntype BeforePreloadRemoteOptions = {\n  preloadOps: Array<PreloadRemoteArgs>;\n  options: Options;\n  origin: FederationHost;\n};\n```\n\n### generatePreloadAssets\n\n`AsyncHook`\n\nCalled for generating preload assets based on configurations.\n\n- type\n\n```ts\nasync function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>;\n\ntype GeneratePreloadAssetsOptions = {\n  origin: FederationHost;\n  preloadOptions: PreloadOptions[number];\n  remote: Remote;\n  remoteInfo: RemoteInfo;\n  remoteSnapshot: ModuleInfo;\n  globalSnapshot: GlobalModuleInfo;\n};\n\ninterface PreloadAssets {\n  cssAssets: Array<string>;\n  jsAssetsWithoutEntry: Array<string>;\n  entryAssets: Array<EntryAssets>;\n}\n```\n\n## loaderHook\n\nPlugin system for module loading operations.\n\n### createScript\n\n`SyncHook`\n\n- type\n\n```ts\nfunction createScript(args: CreateScriptOptions): HTMLScriptElement | void;\n\ntype CreateScriptOptions = {\n  url: string;\n};\n```\n\n- example\n\n```ts\nimport { init } from '@module-federation/runtime';\nimport type { FederationRuntimePlugin } from '@module-federation/runtime';\n\nconst changeScriptAttributePlugin: () => FederationRuntimePlugin = function () {\n  return {\n    name: 'change-script-attribute',\n    createScript({ url }) {\n      if (url === testRemoteEntry) {\n        let script = document.createElement('script');\n        script.src = testRemoteEntry;\n        script.setAttribute('loader-hooks', 'isTrue');\n        script.setAttribute('crossorigin', 'anonymous');\n        return script;\n      }\n    },\n  };\n};\n```\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/9ba1cbed0d514b0736197476d55c07d8/module-federation-dev-server-0.0.0-next-20240326102030.tgz","_integrity":"sha512-a5FXhf6Tlmw8b7NGMRrFyOdQgpU0qMbihK6Sh7SSqjlNk0YGxyX6j2dPUSrKxOQo0THTZYcB8F93bzlliddImw==","_npmVersion":"10.2.4","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240326102030"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240326102030_1711448450480_0.7277420652555713","host":"s3://npm-registry-packages"}},"0.0.0-next-20240401040901":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240401040901","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240401040901","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"b55a3dd1cba88f0e1d3d2576d05de3ab0cf06b27","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240401040901.tgz","fileCount":51,"integrity":"sha512-SYyagW2t7SGw16CNy5mEjvwIPAS88XS3BGZhBo8qmd+xh7H5/QuzN7EhGr8KKsmQP2EpSe+r6qiDveIInGtZ1g==","signatures":[{"sig":"MEQCIF6hAQL0celdR0p0kpW8ouXUTBGShGNPVjPeojzYOQtgAiAMjzlo7IVqCs7wYSQwFYXcF7XXM1bp/UY86p+FxlZQ6A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":120772},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240401040901.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# @module-federation/dev-server\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/2c2f7b188f50232db3c8c686f82f1ee3/module-federation-dev-server-0.0.0-next-20240401040901.tgz","_integrity":"sha512-SYyagW2t7SGw16CNy5mEjvwIPAS88XS3BGZhBo8qmd+xh7H5/QuzN7EhGr8KKsmQP2EpSe+r6qiDveIInGtZ1g==","_npmVersion":"10.2.4","description":"","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240401040901"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240401040901_1711944554604_0.6770372549032042","host":"s3://npm-registry-packages"}},"0.0.0-next-20240401073754":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240401073754","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240401073754","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"539002b7cf6bb5a913f495f9932ad66cd1382109","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240401073754.tgz","fileCount":51,"integrity":"sha512-uDn8WfjFvddbCV33oDA9G5TlJCaOUj2evrnzS1Exazxt9PT13JwUQPhTobZvnFR8kZun0jBiOARQMy3YSBqWPg==","signatures":[{"sig":"MEQCICu7qVLgbq1zLjoumeHB2ftQZtoa5WZuI6TTbwiWeh0xAiBfhyXBb1VSov4BwtjJJAEVDGZPbR/taLFbElotWwVSew==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":120772},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240401073754.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# @module-federation/dev-server\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/031e7269b393297b4f674c371298fcf1/module-federation-dev-server-0.0.0-next-20240401073754.tgz","_integrity":"sha512-uDn8WfjFvddbCV33oDA9G5TlJCaOUj2evrnzS1Exazxt9PT13JwUQPhTobZvnFR8kZun0jBiOARQMy3YSBqWPg==","_npmVersion":"10.2.4","description":"","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240401073754"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240401073754_1711957087386_0.0966052405752984","host":"s3://npm-registry-packages"}},"0.0.0-next-20240401084119":{"name":"@module-federation/dev-server","version":"0.0.0-next-20240401084119","author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","_id":"@module-federation/dev-server@0.0.0-next-20240401084119","maintainers":[{"name":"heal","email":"TwoHeal@163.com"},{"name":"valorkin","email":"valorkin@gmail.com"},{"name":"zackarychapple","email":"zackarychapple30@gmail.com"},{"name":"ilteoood","email":"matteopietro.dazzi@gmail.com"},{"name":"gioboa","email":"giorgiob.boa@gmail.com"},{"name":"ranshamay","email":"ranshamay@gmail.com"},{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},{"name":"tysonrm","email":"tyson.midboe@gmail.com"}],"dist":{"shasum":"39d2e5232846dc490b5ba890ec20bf3a8c01daca","tarball":"https://registry.npmjs.org/@module-federation/dev-server/-/dev-server-0.0.0-next-20240401084119.tgz","fileCount":51,"integrity":"sha512-oks2rJ+ajW3cOSJgnL8p+2eD2tOAgc2utFtg3C+JJ8VBH3UYITT2ZLeiyOb49DeLUsZ/1Kp5K+ck8ZO0ruP/2g==","signatures":[{"sig":"MEQCIH3i2T/pKWyn1PKNQNimtUjZwoHoYwzeNn9JaNpt/rBSAiAe4R8428/e7ghqiCy58YVU8HNP3Q6VnwsTVkc6TBSaWg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":120772},"main":"./dist/index.cjs","_from":"file:module-federation-dev-server-0.0.0-next-20240401084119.tgz","types":"./dist/index.cjs.d.ts","module":"./dist/index.esm.js","readme":"# @module-federation/dev-server\n","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./*":"./*","./launch-web-client":{"types":"./dist/launch-web-client.iife.d.ts","import":"./dist/launch-web-client.iife.js","require":"./dist/launch-web-client.iife.js"}},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"_resolved":"/tmp/ade9edd24faf5a8fcccff48369887e7c/module-federation-dev-server-0.0.0-next-20240401084119.tgz","_integrity":"sha512-oks2rJ+ajW3cOSJgnL8p+2eD2tOAgc2utFtg3C+JJ8VBH3UYITT2ZLeiyOb49DeLUsZ/1Kp5K+ck8ZO0ruP/2g==","_npmVersion":"10.2.4","description":"","directories":{},"_nodeVersion":"18.19.1","dependencies":{"ws":"8.5.0","koa":"2.11.0","chalk":"3.0.0","log4js":"6.9.1","fs-extra":"9.1.0","isomorphic-ws":"5.0.0","node-schedule":"2.1.0","@module-federation/sdk":"0.0.0-next-20240401084119"},"publishConfig":{"access":"public"},"typesVersions":{"*":{".":["./dist/index.cjs.d.ts"],"launch-web-client":["./dist/launch-web-client.iife.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"@types/ws":"8.5.3","@types/koa":"2.11.2","@types/node-schedule":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/dev-server_0.0.0-next-20240401084119_1711960893385_0.47522401028997074","host":"s3://npm-registry-packages"}}},"time":{"created":"2024-03-21T09:28:51.771Z","modified":"2025-09-03T04:32:49.386Z","0.0.15":"2024-03-21T09:28:52.017Z","0.0.0-next-20240321102113":"2024-03-21T10:21:26.795Z","0.0.0-next-20240321124455":"2024-03-21T12:45:08.811Z","0.0.0-next-20240321142841":"2024-03-21T14:28:55.280Z","0.0.0-next-20240322034056":"2024-03-22T03:41:08.776Z","0.0.0-next-20240324060529":"2024-03-24T06:05:42.058Z","0.0.0-next-20240324065321":"2024-03-24T06:53:34.333Z","0.0.0-next-20240324073358":"2024-03-24T07:34:11.077Z","0.0.0-next-20240324082735":"2024-03-24T08:27:48.477Z","0.0.0-next-20240324084915":"2024-03-24T08:49:27.730Z","0.0.0-next-20240324091053":"2024-03-24T09:11:05.455Z","0.0.0-next-20240325030531":"2024-03-25T03:05:44.604Z","0.0.0-next-20240325035415":"2024-03-25T03:54:35.473Z","0.0.0-next-20240325072950":"2024-03-25T07:30:11.107Z","0.0.0-next-20240325084555":"2024-03-25T08:46:17.599Z","0.0.0-next-20240325110954":"2024-03-25T11:10:14.525Z","0.0.0-next-20240326061945":"2024-03-26T06:20:06.209Z","0.0.0-next-20240326081159":"2024-03-26T08:12:19.642Z","0.0.0-next-20240326102030":"2024-03-26T10:20:50.817Z","0.0.0-next-20240401040901":"2024-04-01T04:09:14.819Z","0.0.0-next-20240401073754":"2024-04-01T07:38:07.723Z","0.0.0-next-20240401084119":"2024-04-01T08:41:33.584Z"},"author":{"name":"hanric","email":"hanric.zhang@gmail.com"},"license":"MIT","description":"- Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules. - Only consume part of the export of the remote module and will not fully downloa","maintainers":[{"email":"zackary.l.jackson@gmail.com","name":"zackljackson"},{"email":"TwoHeal@163.com","name":"heal"},{"email":"codingzx@gmail.com","name":"shawzhou"},{"email":"giorgiob.boa@gmail.com","name":"gioboa"}],"readme":"","readmeFilename":""}