@module-federation/webpack-bundler-runtime 1.0.0-canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "public": true,
3
+ "name": "@module-federation/webpack-bundler-runtime",
4
+ "version": "1.0.0-canary.1",
5
+ "description": "Module Federation Runtime for webpack",
6
+ "keywords": [
7
+ "Module Federation",
8
+ "bundler runtime"
9
+ ],
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "author": "zhanghang <hanric.zhang@gmail.com>",
14
+ "main": "./index.cjs.js",
15
+ "module": "./index.esm.js",
16
+ "types": "./index.cjs.d.ts",
17
+ "dependencies": {
18
+ "@module-federation/runtime": "1.0.0-canary.1"
19
+ },
20
+ "peerDependencies": {}
21
+ }
@@ -0,0 +1,2 @@
1
+ import { ConsumesOptions } from './types';
2
+ export declare function consumes(options: ConsumesOptions): void;
package/src/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { Federation } from './types';
2
+ declare const federation: Federation;
3
+ export default federation;
@@ -0,0 +1,2 @@
1
+ import { WebpackRequire } from './types';
2
+ export declare function initializeSharing(shareScopeName: string, webpackRequire: WebpackRequire): Promise<boolean> | boolean;
@@ -0,0 +1,2 @@
1
+ import { InstallInitialConsumesOptions } from './types';
2
+ export declare function installInitialConsumes(options: InstallInitialConsumesOptions): void;
@@ -0,0 +1,2 @@
1
+ import { WebpackRequire } from './types';
2
+ export declare function proxyShareScopeMap(__webpack_require__: WebpackRequire): void;
@@ -0,0 +1,2 @@
1
+ import { RemotesOptions } from './types';
2
+ export declare function remotes(options: RemotesOptions): void;
package/src/types.d.ts ADDED
@@ -0,0 +1,87 @@
1
+ import * as runtime from '@module-federation/runtime';
2
+ import { initializeSharing } from './initializeSharing';
3
+ type ExcludeUndefined<T> = T extends undefined ? never : T;
4
+ type NonUndefined<T = Shared> = ExcludeUndefined<T>;
5
+ type InitOptions = Parameters<typeof runtime.init>[0];
6
+ type Shared = InitOptions['shared'];
7
+ type SharedConfig = NonUndefined<NonUndefined[string]['shareConfig']>;
8
+ type ModuleCache = runtime.FederationHost['moduleCache'];
9
+ type InferModule<T> = T extends Map<string, infer U> ? U : never;
10
+ type InferredModule = InferModule<ModuleCache>;
11
+ export type RemoteEntryExports = NonUndefined<InferredModule['remoteEntryExports']>;
12
+ type ExtractInitParameters<T> = T extends {
13
+ init: (shareScope: infer U, ...args: any[]) => void;
14
+ } ? U : never;
15
+ type InferredShareScope = ExtractInitParameters<RemoteEntryExports>;
16
+ type InferredGlobalShareScope = {
17
+ [scope: string]: InferredShareScope;
18
+ };
19
+ type IdToExternalAndNameMappingItem = [
20
+ string,
21
+ string,
22
+ string | number,
23
+ string,
24
+ string
25
+ ];
26
+ interface IdToExternalAndNameMappingItemWithPromise extends IdToExternalAndNameMappingItem {
27
+ p?: Promise<any> | number;
28
+ }
29
+ export interface WebpackRequire {
30
+ (moduleId: string | number): any;
31
+ o: (obj: Record<string, any>, key: string | number) => boolean;
32
+ R: Array<string | number>;
33
+ m: Record<string, (mod: any) => any>;
34
+ c: Record<string, any>;
35
+ I: typeof initializeSharing;
36
+ S?: InferredGlobalShareScope;
37
+ federation: Federation;
38
+ }
39
+ interface ShareInfo {
40
+ shareConfig: SharedConfig;
41
+ scope: Array<string>;
42
+ }
43
+ interface ModuleToHandlerMappingItem {
44
+ getter: () => Promise<any>;
45
+ shareInfo: ShareInfo;
46
+ shareKey: string;
47
+ }
48
+ export interface RemotesOptions {
49
+ chunkId: string | number;
50
+ promises: Promise<any>[];
51
+ chunkMapping: Record<string, Array<string | number>>;
52
+ idToExternalAndNameMapping: Record<string, IdToExternalAndNameMappingItemWithPromise>;
53
+ webpackRequire: WebpackRequire;
54
+ }
55
+ export interface HandleInitialConsumesOptions {
56
+ moduleId: string | number;
57
+ moduleToHandlerMapping: Record<string, ModuleToHandlerMappingItem>;
58
+ webpackRequire: WebpackRequire;
59
+ }
60
+ export interface InstallInitialConsumesOptions {
61
+ moduleToHandlerMapping: Record<string, ModuleToHandlerMappingItem>;
62
+ webpackRequire: WebpackRequire;
63
+ installedModules: Record<string, Promise<any> | 0>;
64
+ initialConsumes: Array<string | number>;
65
+ }
66
+ export interface ConsumesOptions {
67
+ chunkId: string | number;
68
+ promises: Promise<any>[];
69
+ chunkMapping: Record<string, Array<string | number>>;
70
+ installedModules: Record<string, Promise<any> | 0>;
71
+ moduleToHandlerMapping: Record<string, ModuleToHandlerMappingItem>;
72
+ webpackRequire: WebpackRequire;
73
+ }
74
+ export interface Federation {
75
+ runtime?: typeof runtime;
76
+ instance?: runtime.FederationHost;
77
+ initOptions?: InitOptions;
78
+ installInitialConsumes?: (options: InstallInitialConsumesOptions) => any;
79
+ bundlerRuntime?: {
80
+ remotes: (options: RemotesOptions) => void;
81
+ consumes: (options: ConsumesOptions) => void;
82
+ I: (name: string, webpackRequire: WebpackRequire) => Promise<boolean> | boolean;
83
+ S: InferredGlobalShareScope;
84
+ installInitialConsumes: (options: InstallInitialConsumesOptions) => any;
85
+ };
86
+ }
87
+ export {};