@module-federation/utilities 3.0.8 → 3.0.10

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/dist/package.json DELETED
@@ -1,57 +0,0 @@
1
- {
2
- "name": "@module-federation/utilities",
3
- "version": "3.0.8",
4
- "type": "commonjs",
5
- "main": "./index.cjs.js",
6
- "types": "./dist/index.cjs.d.ts",
7
- "license": "MIT",
8
- "publishConfig": {
9
- "access": "public"
10
- },
11
- "files": [
12
- "dist/",
13
- "README.md"
14
- ],
15
- "repository": "https://github.com/module-federation/universe/tree/main/packages/utilities",
16
- "devDependencies": {
17
- "react": "18.2.0"
18
- },
19
- "dependencies": {
20
- "@module-federation/sdk": "workspace:*"
21
- },
22
- "peerDependencies": {
23
- "webpack": "^5.40.0",
24
- "react-dom": "^16 || ^17 || ^18",
25
- "react": "^16 || ^17 || ^18"
26
- },
27
- "peerDependenciesMeta": {
28
- "react": {
29
- "optional": true
30
- },
31
- "react-dom": {
32
- "optional": true
33
- },
34
- "next": {
35
- "optional": true
36
- }
37
- },
38
- "exports": {
39
- ".": {
40
- "module": "./index.esm.js",
41
- "import": "./index.cjs.mjs",
42
- "default": "./index.cjs.js"
43
- },
44
- "./package.json": "./package.json"
45
- },
46
- "typesVersions": {
47
- "*": {
48
- ".": [
49
- "./dist/index.cjs.d.ts"
50
- ],
51
- "type": [
52
- "./dist/type.cjs.d.ts"
53
- ]
54
- }
55
- },
56
- "module": "./index.esm.js"
57
- }
@@ -1,7 +0,0 @@
1
- import { Compilation } from 'webpack';
2
- export type LoggerInstance = Compilation['logger'] | Console;
3
- export declare class Logger {
4
- private static loggerInstance;
5
- static getLogger(): LoggerInstance;
6
- static setLogger(logger: Compilation['logger']): LoggerInstance;
7
- }
@@ -1,19 +0,0 @@
1
- import React, { type ErrorInfo } from 'react';
2
- export interface ErrorBoundaryProps {
3
- children: React.ReactNode;
4
- }
5
- export interface ErrorBoundaryState {
6
- hasError: boolean;
7
- }
8
- /**
9
- * Generic error boundary component.
10
- */
11
- declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
12
- constructor(props: ErrorBoundaryProps);
13
- static getDerivedStateFromError(): {
14
- hasError: boolean;
15
- };
16
- componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
17
- render(): React.ReactNode;
18
- }
19
- export default ErrorBoundary;
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import type { ComponentClass, ComponentType, PropsWithChildren } from 'react';
3
- export interface FederationBoundaryProps {
4
- dynamicImporter: () => Promise<ComponentType<any>>;
5
- fallback?: () => Promise<ComponentType<any>>;
6
- customBoundary?: ComponentClass<PropsWithChildren<any>>;
7
- [props: string]: any;
8
- }
9
- /**
10
- * Wrapper around dynamic import.
11
- * Adds error boundaries and fallback options.
12
- */
13
- declare const FederationBoundary: React.FC<FederationBoundaryProps>;
14
- export default FederationBoundary;
@@ -1,10 +0,0 @@
1
- export * from './types';
2
- export type { ImportRemoteOptions } from './utils/importRemote';
3
- export type { LoggerInstance } from './Logger';
4
- export { createRuntimeVariables, getContainer, injectScript, getModule, } from './utils/common';
5
- export { isObjectEmpty } from './utils/isEmpty';
6
- export { importRemote } from './utils/importRemote';
7
- export { Logger } from './Logger';
8
- export { getRuntimeRemotes } from './utils/getRuntimeRemotes';
9
- export { importDelegatedModule } from './utils/importDelegatedModule';
10
- export { extractUrlAndGlobal, loadScript } from './utils/pure';
@@ -1,18 +0,0 @@
1
- import type { Compiler, Compilation, Chunk, NormalModule } from 'webpack';
2
- declare class DelegateModulesPlugin {
3
- options: {
4
- debug: boolean;
5
- [key: string]: any;
6
- };
7
- _delegateModules: Map<string, NormalModule>;
8
- constructor(options: {
9
- debug?: boolean;
10
- [key: string]: any;
11
- });
12
- getChunkByName(chunks: Iterable<Chunk>, name: string): Chunk | undefined;
13
- private addDelegatesToChunks;
14
- private addModuleAndDependenciesToChunk;
15
- removeDelegatesNonRuntimeChunks(compilation: Compilation, chunks: Iterable<Chunk>): void;
16
- apply(compiler: Compiler): void;
17
- }
18
- export default DelegateModulesPlugin;
@@ -1,77 +0,0 @@
1
- /// <reference types="webpack/module" />
2
- import type { moduleFederationPlugin } from '@module-federation/sdk';
3
- import type { WebpackOptionsNormalized } from 'webpack';
4
- export type ModuleFederationPluginOptions = moduleFederationPlugin.ModuleFederationPluginOptions;
5
- export type WebpackRequire = {
6
- l: (url: string | undefined, cb: (event: any) => void, id: string | number) => Record<string, unknown>;
7
- };
8
- export type WebpackShareScopes = Record<string, Record<string, {
9
- loaded?: 1;
10
- get: () => Promise<unknown>;
11
- from: string;
12
- eager: boolean;
13
- }>> & {
14
- default?: string;
15
- };
16
- export type GlobalScopeType = {
17
- [K: string]: any;
18
- _config?: Record<string | number, any>;
19
- _medusa?: Record<string, any> | undefined;
20
- remoteLoading?: Record<string, Promise<AsyncContainer>>;
21
- };
22
- export declare const __webpack_init_sharing__: (parameter: string) => Promise<void>;
23
- export interface NextFederationPluginExtraOptions {
24
- enableImageLoaderFix?: boolean;
25
- enableUrlLoaderFix?: boolean;
26
- exposePages?: boolean;
27
- skipSharingNextInternals?: boolean;
28
- automaticPageStitching?: boolean;
29
- debug?: boolean;
30
- }
31
- export interface NextFederationPluginOptions extends ModuleFederationPluginOptions {
32
- extraOptions: NextFederationPluginExtraOptions;
33
- }
34
- export type Shared = ModuleFederationPluginOptions['shared'];
35
- export type Remotes = ModuleFederationPluginOptions['remotes'];
36
- export type SharedObject = Extract<Shared, ModuleFederationPluginOptions>;
37
- export type SharedConfig = Extract<SharedObject[keyof SharedObject], {
38
- eager?: boolean;
39
- }>;
40
- export type ExternalsType = Required<ModuleFederationPluginOptions['remoteType']>;
41
- type ModulePath = string;
42
- export type WebpackRemoteContainer = {
43
- __initialized?: boolean;
44
- get(modulePath: ModulePath): () => any;
45
- init: (obj?: typeof __webpack_share_scopes__) => void;
46
- };
47
- export type AsyncContainer = Promise<WebpackRemoteContainer>;
48
- export type RemoteData = {
49
- global: string;
50
- url: string;
51
- uniqueKey?: string;
52
- };
53
- export type RuntimeRemote = Partial<RemoteData> & {
54
- asyncContainer?: AsyncContainer;
55
- global?: string;
56
- url?: string;
57
- };
58
- export type RuntimeRemotesMap = Record<string, RuntimeRemote>;
59
- type Module = WebpackOptionsNormalized['module'];
60
- type Rules = Module['rules'];
61
- export type RuleSetRuleUnion = Rules[0];
62
- type RuleSetRule = Extract<RuleSetRuleUnion, {
63
- loader?: string;
64
- }>;
65
- export type Loader = Extract<RuleSetRule['use'], {
66
- loader?: string;
67
- }>;
68
- export type EventTypes = 'loadStart' | 'loadComplete' | 'loadError';
69
- type NextRoute = string;
70
- export type PageMap = Record<NextRoute, ModulePath>;
71
- export type GetModuleOptions = {
72
- modulePath: string;
73
- exportName?: string;
74
- remoteContainer: string | RemoteData;
75
- };
76
- export type RemoteVars = Record<string, Promise<WebpackRemoteContainer> | string | (() => Promise<WebpackRemoteContainer>)>;
77
- export {};
@@ -1,31 +0,0 @@
1
- import type { GetModuleOptions, RemoteData, Remotes, RuntimeRemote, WebpackRemoteContainer } from '../types';
2
- /**
3
- * Return initialized remote container by remote's key or its runtime remote item data.
4
- *
5
- * `runtimeRemoteItem` might be
6
- * { global, url } - values obtained from webpack remotes option `global@url`
7
- * or
8
- * { asyncContainer } - async container is a promise that resolves to the remote container
9
- */
10
- export declare const injectScript: (keyOrRuntimeRemoteItem: string | RuntimeRemote) => Promise<WebpackRemoteContainer>;
11
- /**
12
- * Creates runtime variables from the provided remotes.
13
- * If the value of a remote starts with 'promise ' or 'external ', it is transformed into a function that returns the promise call.
14
- * Otherwise, the value is stringified.
15
- * @param {Remotes} remotes - The remotes to create runtime variables from.
16
- * @returns {Record<string, string>} - The created runtime variables.
17
- */
18
- export declare const createRuntimeVariables: (remotes: Remotes) => Record<string, string>;
19
- /**
20
- * Returns initialized webpack RemoteContainer.
21
- * If its' script does not loaded - then load & init it firstly.
22
- */
23
- export declare const getContainer: (remoteContainer: string | RemoteData) => Promise<WebpackRemoteContainer | undefined>;
24
- /**
25
- * Return remote module from container.
26
- * If you provide `exportName` it automatically return exact property value from module.
27
- *
28
- * @example
29
- * remote.getModule('./pages/index', 'default')
30
- */
31
- export declare const getModule: ({ remoteContainer, modulePath, exportName, }: GetModuleOptions) => Promise<any>;
@@ -1,2 +0,0 @@
1
- import { RuntimeRemotesMap } from '../types';
2
- export declare const getRuntimeRemotes: () => RuntimeRemotesMap;
@@ -1,2 +0,0 @@
1
- import { RuntimeRemote } from '../types';
2
- export declare const importDelegatedModule: (keyOrRuntimeRemoteItem: string | RuntimeRemote) => Promise<any>;
@@ -1,31 +0,0 @@
1
- /**
2
- * Type definition for RemoteUrl
3
- * @typedef {string | function} RemoteUrl
4
- */
5
- type RemoteUrl = string | (() => Promise<string>);
6
- /**
7
- * Interface for ImportRemoteOptions
8
- * @interface
9
- * @property {RemoteUrl} url - The url of the remote module
10
- * @property {string} scope - The scope of the remote module
11
- * @property {string} module - The module to import
12
- * @property {string} [remoteEntryFileName] - The filename of the remote entry
13
- * @property {boolean} [bustRemoteEntryCache] - Flag to bust the remote entry cache
14
- */
15
- export interface ImportRemoteOptions {
16
- url: RemoteUrl;
17
- scope: string;
18
- module: string;
19
- remoteEntryFileName?: string;
20
- bustRemoteEntryCache?: boolean;
21
- esm?: boolean;
22
- }
23
- /**
24
- * Function to import remote
25
- * @async
26
- * @function
27
- * @param {ImportRemoteOptions} options - The options for importing the remote
28
- * @returns {Promise<T>} A promise that resolves with the imported module
29
- */
30
- export declare const importRemote: <T>({ url, scope, module, remoteEntryFileName, bustRemoteEntryCache, esm, }: ImportRemoteOptions) => Promise<T>;
31
- export {};
@@ -1 +0,0 @@
1
- export declare const isObjectEmpty: <T extends object>(obj: T) => boolean;
@@ -1,5 +0,0 @@
1
- import { RemoteVars, RuntimeRemote, RuntimeRemotesMap } from '../types';
2
- export declare const remoteVars: RemoteVars;
3
- export declare const extractUrlAndGlobal: (urlAndGlobal: string) => [string, string];
4
- export declare const loadScript: (keyOrRuntimeRemoteItem: string | RuntimeRemote) => any;
5
- export declare const getRuntimeRemotes: () => RuntimeRemotesMap;
@@ -1 +0,0 @@
1
- export { default as FederationBoundary } from '../components/FederationBoundary';