@module-federation/sdk 0.1.4 → 0.1.5

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.
@@ -1 +0,0 @@
1
- export * from "./src/normalize-webpack-path";
@@ -1,51 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var path = require('path');
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
10
-
11
- function getWebpackPath(compiler) {
12
- var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
13
- framework: "other"
14
- };
15
- try {
16
- // @ts-ignore just throw err
17
- compiler.webpack();
18
- return "";
19
- } catch (err) {
20
- var _err_stack;
21
- var trace = ((_err_stack = err.stack) === null || _err_stack === void 0 ? void 0 : _err_stack.split("\n")) || [];
22
- var webpackErrLocation = trace.find(function(item) {
23
- return item.includes("at webpack");
24
- }) || "";
25
- var webpackLocationWithDetail = webpackErrLocation.replace(/[^\(\)]+/, "").slice(1, -1);
26
- var webpackPath = webpackLocationWithDetail.split(":").slice(0, -2).join(":");
27
- if ((options === null || options === void 0 ? void 0 : options.framework) === "nextjs") {
28
- if (webpackPath.endsWith("webpack.js")) {
29
- return webpackPath.replace("webpack.js", "index.js");
30
- }
31
- return "";
32
- }
33
- return require.resolve("webpack", {
34
- paths: [
35
- webpackPath
36
- ]
37
- });
38
- }
39
- }
40
- var normalizeWebpackPath = function(fullPath) {
41
- if (fullPath === "webpack") {
42
- return process.env["FEDERATION_WEBPACK_PATH"] || fullPath;
43
- }
44
- if (process.env["FEDERATION_WEBPACK_PATH"]) {
45
- return path__default["default"].resolve(process.env["FEDERATION_WEBPACK_PATH"], fullPath.replace("webpack", "../../"));
46
- }
47
- return fullPath;
48
- };
49
-
50
- exports.getWebpackPath = getWebpackPath;
51
- exports.normalizeWebpackPath = normalizeWebpackPath;
@@ -1,42 +0,0 @@
1
- import path from 'path';
2
-
3
- function getWebpackPath(compiler) {
4
- var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
5
- framework: "other"
6
- };
7
- try {
8
- // @ts-ignore just throw err
9
- compiler.webpack();
10
- return "";
11
- } catch (err) {
12
- var _err_stack;
13
- var trace = ((_err_stack = err.stack) === null || _err_stack === void 0 ? void 0 : _err_stack.split("\n")) || [];
14
- var webpackErrLocation = trace.find(function(item) {
15
- return item.includes("at webpack");
16
- }) || "";
17
- var webpackLocationWithDetail = webpackErrLocation.replace(/[^\(\)]+/, "").slice(1, -1);
18
- var webpackPath = webpackLocationWithDetail.split(":").slice(0, -2).join(":");
19
- if ((options === null || options === void 0 ? void 0 : options.framework) === "nextjs") {
20
- if (webpackPath.endsWith("webpack.js")) {
21
- return webpackPath.replace("webpack.js", "index.js");
22
- }
23
- return "";
24
- }
25
- return require.resolve("webpack", {
26
- paths: [
27
- webpackPath
28
- ]
29
- });
30
- }
31
- }
32
- var normalizeWebpackPath = function(fullPath) {
33
- if (fullPath === "webpack") {
34
- return process.env["FEDERATION_WEBPACK_PATH"] || fullPath;
35
- }
36
- if (process.env["FEDERATION_WEBPACK_PATH"]) {
37
- return path.resolve(process.env["FEDERATION_WEBPACK_PATH"], fullPath.replace("webpack", "../../"));
38
- }
39
- return fullPath;
40
- };
41
-
42
- export { getWebpackPath, normalizeWebpackPath };
package/dist/package.json DELETED
@@ -1,44 +0,0 @@
1
- {
2
- "name": "@module-federation/sdk",
3
- "version": "0.1.4",
4
- "license": "MIT",
5
- "description": "A sdk for support module federation",
6
- "keywords": [
7
- "Module Federation",
8
- "sdk"
9
- ],
10
- "files": [
11
- "dist/",
12
- "README.md"
13
- ],
14
- "publishConfig": {
15
- "access": "public"
16
- },
17
- "author": "zhanghang <hanric.zhang@gmail.com>",
18
- "sideEffects": false,
19
- "main": "./index.cjs.js",
20
- "module": "./index.esm.js",
21
- "types": "./dist/index.cjs.d.ts",
22
- "exports": {
23
- ".": {
24
- "types": "./dist/index.cjs.d.ts",
25
- "import": "./dist/index.esm.js",
26
- "require": "./dist/index.cjs.js"
27
- },
28
- "./normalize-webpack-path": {
29
- "types": "./dist/normalize-webpack-path.cjs.d.ts",
30
- "import": "./dist/normalize-webpack-path.esm.js",
31
- "require": "./dist/normalize-webpack-path.cjs.js"
32
- }
33
- },
34
- "typesVersions": {
35
- "*": {
36
- ".": [
37
- "./dist/index.cjs.d.ts"
38
- ],
39
- "normalize-webpack-path": [
40
- "./dist/normalize-webpack-path.cjs.d.ts"
41
- ]
42
- }
43
- }
44
- }
@@ -1,23 +0,0 @@
1
- export declare const FederationModuleManifest = "federation-manifest.json";
2
- export declare const MANIFEST_EXT = ".json";
3
- export declare const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
4
- export declare const BROWSER_LOG_VALUE = "1";
5
- export declare const NameTransformSymbol: {
6
- AT: string;
7
- HYPHEN: string;
8
- SLASH: string;
9
- };
10
- export declare const NameTransformMap: {
11
- [x: string]: string;
12
- };
13
- export declare const EncodedNameTransformMap: {
14
- [x: string]: string;
15
- };
16
- export declare const SEPARATOR = ":";
17
- export declare const ManifestFileName = "mf-manifest.json";
18
- export declare const StatsFileName = "mf-stats.json";
19
- export declare const MFModuleType: {
20
- NPM: string;
21
- APP: string;
22
- };
23
- export declare const MODULE_DEVTOOL_IDENTIFIER = "__MF_DEVTOOLS_MODULE_INFO__";
package/dist/src/dom.d.ts DELETED
@@ -1,14 +0,0 @@
1
- export declare function safeWrapper<T extends (...args: Array<any>) => any>(callback: T, disableWarn?: boolean): Promise<ReturnType<T> | undefined>;
2
- export declare function isStaticResourcesEqual(url1: string, url2: string): boolean;
3
- export declare function createScript(url: string, cb: (value: void | PromiseLike<void>) => void, attrs?: Record<string, any>, createScriptHook?: (url: string) => HTMLScriptElement | void): {
4
- script: HTMLScriptElement;
5
- needAttach: boolean;
6
- };
7
- export declare function createLink(url: string, cb: (value: void | PromiseLike<void>) => void, attrs?: Record<string, string>, createLinkHook?: (url: string) => HTMLLinkElement | void): {
8
- link: HTMLLinkElement;
9
- needAttach: boolean;
10
- };
11
- export declare function loadScript(url: string, info: {
12
- attrs?: Record<string, any>;
13
- createScriptHook?: (url: string) => HTMLScriptElement | void;
14
- }): Promise<void>;
package/dist/src/env.d.ts DELETED
@@ -1,7 +0,0 @@
1
- declare global {
2
- var FEDERATION_DEBUG: string | undefined;
3
- }
4
- declare function isBrowserEnv(): boolean;
5
- declare function isDebugMode(): boolean;
6
- declare const getProcessEnv: () => Record<string, string | undefined>;
7
- export { isBrowserEnv, isDebugMode, getProcessEnv };
@@ -1,10 +0,0 @@
1
- import { Manifest, ProviderModuleInfo, ModuleInfo, ManifestProvider } from './types';
2
- interface IOptions {
3
- remotes?: Record<string, string>;
4
- overrides?: Record<string, string>;
5
- version?: string;
6
- }
7
- export declare const simpleJoinRemoteEntry: (rPath: string, rName: string) => string;
8
- export declare function generateSnapshotFromManifest(manifest: Manifest, options?: IOptions): ProviderModuleInfo;
9
- export declare function isManifestProvider(moduleInfo: ModuleInfo | ManifestProvider): moduleInfo is ManifestProvider;
10
- export {};
@@ -1,9 +0,0 @@
1
- export * from './constant';
2
- export * from './types';
3
- export * from './utils';
4
- export { generateSnapshotFromManifest, isManifestProvider, simpleJoinRemoteEntry, } from './generateSnapshotFromManifest';
5
- export * from './logger';
6
- export * from './env';
7
- export * from './dom';
8
- export * from './node';
9
- export * from './normalizeOptions';
@@ -1,8 +0,0 @@
1
- declare class Logger {
2
- enable: boolean;
3
- identifier: string;
4
- constructor(identifier?: string);
5
- info(msg: string, info?: any): void;
6
- logOriginalInfo(...args: unknown[]): void;
7
- }
8
- export { Logger };
@@ -1,5 +0,0 @@
1
- export declare function createScriptNode(url: string, cb: (error?: Error, scriptContext?: any) => void, attrs?: Record<string, any>, createScriptHook?: (url: string) => any | void): void;
2
- export declare function loadScriptNode(url: string, info: {
3
- attrs?: Record<string, any>;
4
- createScriptHook?: (url: string) => void;
5
- }): Promise<void>;
@@ -1,5 +0,0 @@
1
- import type webpack from 'webpack';
2
- export declare function getWebpackPath(compiler: webpack.Compiler, options?: {
3
- framework: 'nextjs' | 'other';
4
- }): string;
5
- export declare const normalizeWebpackPath: (fullPath: string) => string;
@@ -1 +0,0 @@
1
- export declare function normalizeOptions<T>(enableDefault: boolean, defaultOptions: T, key: string): <U extends boolean | T | undefined>(options: U) => T | false;
@@ -1,10 +0,0 @@
1
- export interface RemoteWithEntry {
2
- name: string;
3
- entry: string;
4
- }
5
- export interface RemoteWithVersion {
6
- name: string;
7
- version: string;
8
- }
9
- export type RemoteEntryInfo = RemoteWithEntry | RemoteWithVersion;
10
- export type Module = any;
@@ -1,5 +0,0 @@
1
- export * from './common';
2
- export * from './manifest';
3
- export * from './stats';
4
- export * from './snapshot';
5
- export * from './plugins';
@@ -1,26 +0,0 @@
1
- import { StatsMetaData, StatsAssets, StatsExpose, BasicStatsMetaData } from './stats';
2
- import { RemoteWithEntry, RemoteWithVersion } from './common';
3
- export interface ManifestShared {
4
- id: string;
5
- name: string;
6
- version: string;
7
- singleton: boolean;
8
- requiredVersion: string;
9
- hash: string;
10
- assets: StatsAssets;
11
- }
12
- export interface ManifestRemoteCommonInfo {
13
- federationContainerName: string;
14
- moduleName: string;
15
- alias: string;
16
- }
17
- export type ManifestRemote<T = ManifestRemoteCommonInfo> = (Omit<RemoteWithEntry, 'name'> & T) | (Omit<RemoteWithVersion, 'name'> & T);
18
- export type ManifestExpose = Pick<StatsExpose, 'assets' | 'id' | 'name' | 'path'>;
19
- export interface Manifest<T = BasicStatsMetaData, K = ManifestRemoteCommonInfo> {
20
- id: string;
21
- name: string;
22
- metaData: StatsMetaData<T>;
23
- shared: ManifestShared[];
24
- remotes: ManifestRemote<K>[];
25
- exposes: ManifestExpose[];
26
- }
@@ -1,159 +0,0 @@
1
- /**
2
- * Modules that should be exposed by this container. When provided, property name is used as public name, otherwise public name is automatically inferred from request.
3
- */
4
- export type Exposes = (ExposesItem | ExposesObject)[] | ExposesObject;
5
- /**
6
- * Module that should be exposed by this container.
7
- */
8
- export type ExposesItem = string;
9
- /**
10
- * Modules that should be exposed by this container.
11
- */
12
- export type ExposesItems = ExposesItem[];
13
- /**
14
- * Add a container for define/require functions in the AMD module.
15
- */
16
- export type AmdContainer = string;
17
- /**
18
- * Add a comment in the UMD wrapper.
19
- */
20
- export type AuxiliaryComment = string | LibraryCustomUmdCommentObject;
21
- /**
22
- * Specify which export should be exposed as library.
23
- */
24
- export type LibraryExport = string[] | string;
25
- /**
26
- * The name of the library (some types allow unnamed libraries too).
27
- */
28
- export type LibraryName = string[] | string | LibraryCustomUmdObject;
29
- /**
30
- * Type of library (types included by default are 'var', 'module', 'assign', 'assign-properties', 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs-module', 'commonjs-static', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others might be added by plugins).
31
- */
32
- export type LibraryType = ('var' | 'module' | 'assign' | 'assign-properties' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system') | string;
33
- /**
34
- * If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module.
35
- */
36
- export type UmdNamedDefine = boolean;
37
- /**
38
- * The name of the runtime chunk. If set a runtime chunk with this name is created or an existing entrypoint is used as runtime.
39
- */
40
- export type EntryRuntime = false | string;
41
- export interface ContainerPluginOptions {
42
- /**
43
- * Modules that should be exposed by this container. When provided, property name is used as public name, otherwise public name is automatically inferred from request.
44
- */
45
- exposes: Exposes;
46
- /**
47
- * The filename for this container relative path inside the `output.path` directory.
48
- */
49
- filename?: string;
50
- /**
51
- * Options for library.
52
- */
53
- library?: LibraryOptions;
54
- /**
55
- * The name for this container.
56
- */
57
- name: string;
58
- /**
59
- * The name of the runtime chunk. If set a runtime chunk with this name is created or an existing entrypoint is used as runtime.
60
- */
61
- runtime?: EntryRuntime;
62
- /**
63
- * The name of the share scope which is shared with the host (defaults to 'default').
64
- */
65
- shareScope?: string;
66
- /**
67
- * Runtime plugin file paths or package name.
68
- */
69
- runtimePlugins?: string[];
70
- }
71
- /**
72
- * Modules that should be exposed by this container. Property names are used as public paths.
73
- */
74
- export interface ExposesObject {
75
- /**
76
- * Modules that should be exposed by this container.
77
- */
78
- [k: string]: ExposesConfig | ExposesItem | ExposesItems;
79
- }
80
- /**
81
- * Advanced configuration for modules that should be exposed by this container.
82
- */
83
- export interface ExposesConfig {
84
- /**
85
- * Request to a module that should be exposed by this container.
86
- */
87
- import: ExposesItem | ExposesItems;
88
- /**
89
- * Custom chunk name for the exposed module.
90
- */
91
- name?: string;
92
- }
93
- /**
94
- * Options for library.
95
- */
96
- export interface LibraryOptions {
97
- /**
98
- * Add a container for define/require functions in the AMD module.
99
- */
100
- amdContainer?: AmdContainer;
101
- /**
102
- * Add a comment in the UMD wrapper.
103
- */
104
- auxiliaryComment?: AuxiliaryComment;
105
- /**
106
- * Specify which export should be exposed as library.
107
- */
108
- export?: LibraryExport;
109
- /**
110
- * The name of the library (some types allow unnamed libraries too).
111
- */
112
- name?: LibraryName;
113
- /**
114
- * Type of library (types included by default are 'var', 'module', 'assign', 'assign-properties', 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs-module', 'commonjs-static', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others might be added by plugins).
115
- */
116
- type: LibraryType;
117
- /**
118
- * If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module.
119
- */
120
- umdNamedDefine?: UmdNamedDefine;
121
- }
122
- /**
123
- * Set explicit comments for `commonjs`, `commonjs2`, `amd`, and `root`.
124
- */
125
- export interface LibraryCustomUmdCommentObject {
126
- /**
127
- * Set comment for `amd` section in UMD.
128
- */
129
- amd?: string;
130
- /**
131
- * Set comment for `commonjs` (exports) section in UMD.
132
- */
133
- commonjs?: string;
134
- /**
135
- * Set comment for `commonjs2` (module.exports) section in UMD.
136
- */
137
- commonjs2?: string;
138
- /**
139
- * Set comment for `root` (global variable) section in UMD.
140
- */
141
- root?: string;
142
- }
143
- /**
144
- * Description object for all UMD variants of the library name.
145
- */
146
- export interface LibraryCustomUmdObject {
147
- /**
148
- * Name of the exposed AMD library in the UMD.
149
- */
150
- amd?: string;
151
- /**
152
- * Name of the exposed commonjs export in the UMD.
153
- */
154
- commonjs?: string;
155
- /**
156
- * Name of the property exposed globally by a UMD library.
157
- */
158
- root?: string[] | string;
159
- }
@@ -1,52 +0,0 @@
1
- /**
2
- * Specifies the default type of externals ('amd*', 'umd*', 'system' and 'jsonp' depend on output.libraryTarget set to the same value).
3
- */
4
- export type ExternalsType = 'var' | 'module' | 'assign' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system' | 'promise' | 'import' | 'script' | 'node-commonjs';
5
- /**
6
- * Container locations and request scopes from which modules should be resolved and loaded at runtime. When provided, property name is used as request scope, otherwise request scope is automatically inferred from container location.
7
- */
8
- export type Remotes = (RemotesItem | RemotesObject)[] | RemotesObject;
9
- /**
10
- * Container location from which modules should be resolved and loaded at runtime.
11
- */
12
- export type RemotesItem = string;
13
- /**
14
- * Container locations from which modules should be resolved and loaded at runtime.
15
- */
16
- export type RemotesItems = RemotesItem[];
17
- export interface ContainerReferencePluginOptions {
18
- /**
19
- * The external type of the remote containers.
20
- */
21
- remoteType: ExternalsType;
22
- /**
23
- * Container locations and request scopes from which modules should be resolved and loaded at runtime. When provided, property name is used as request scope, otherwise request scope is automatically inferred from container location.
24
- */
25
- remotes: Remotes;
26
- /**
27
- * The name of the share scope shared with all remotes (defaults to 'default').
28
- */
29
- shareScope?: string;
30
- }
31
- /**
32
- * Container locations from which modules should be resolved and loaded at runtime. Property names are used as request scopes.
33
- */
34
- export interface RemotesObject {
35
- /**
36
- * Container locations from which modules should be resolved and loaded at runtime.
37
- */
38
- [k: string]: RemotesConfig | RemotesItem | RemotesItems;
39
- }
40
- /**
41
- * Advanced configuration for container locations from which modules should be resolved and loaded at runtime.
42
- */
43
- export interface RemotesConfig {
44
- /**
45
- * Container locations from which modules should be resolved and loaded at runtime.
46
- */
47
- external: RemotesItem | RemotesItems;
48
- /**
49
- * The name of the share scope shared with this remote.
50
- */
51
- shareScope?: string;
52
- }