@module-federation/metro 0.0.0-chore-bump-node-22-20260710161714
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/LICENSE +21 -0
- package/README.md +11 -0
- package/babel-plugin/index.js +115 -0
- package/babel-plugin/patch-initialize-core.js +61 -0
- package/babel-plugin/patch-require.js +174 -0
- package/bootstrap/index.d.ts +1 -0
- package/bootstrap/index.js +1 -0
- package/dist/babel/transformer.js +15 -0
- package/dist/commands/bundle-host/index.d.ts +13 -0
- package/dist/commands/bundle-host/index.js +100 -0
- package/dist/commands/bundle-host/index.mjs +47 -0
- package/dist/commands/bundle-host/options.d.ts +5 -0
- package/dist/commands/bundle-host/options.js +43 -0
- package/dist/commands/bundle-host/options.mjs +6 -0
- package/dist/commands/bundle-host/types.d.ts +22 -0
- package/dist/commands/bundle-host/types.js +18 -0
- package/dist/commands/bundle-host/types.mjs +1 -0
- package/dist/commands/bundle-remote/index.d.ts +12 -0
- package/dist/commands/bundle-remote/index.js +241 -0
- package/dist/commands/bundle-remote/index.mjs +190 -0
- package/dist/commands/bundle-remote/options.d.ts +32 -0
- package/dist/commands/bundle-remote/options.js +113 -0
- package/dist/commands/bundle-remote/options.mjs +66 -0
- package/dist/commands/bundle-remote/types.d.ts +16 -0
- package/dist/commands/bundle-remote/types.js +18 -0
- package/dist/commands/bundle-remote/types.mjs +1 -0
- package/dist/commands/index.d.ts +48 -0
- package/dist/commands/index.js +76 -0
- package/dist/commands/index.mjs +13 -0
- package/dist/commands/types.d.ts +14 -0
- package/dist/commands/types.js +18 -0
- package/dist/commands/types.mjs +1 -0
- package/dist/commands/utils/create-module-path-remapper.d.ts +7 -0
- package/dist/commands/utils/create-module-path-remapper.js +68 -0
- package/dist/commands/utils/create-module-path-remapper.mjs +31 -0
- package/dist/commands/utils/create-resolver.d.ts +20 -0
- package/dist/commands/utils/create-resolver.js +61 -0
- package/dist/commands/utils/create-resolver.mjs +24 -0
- package/dist/commands/utils/get-community-plugin.d.ts +28 -0
- package/dist/commands/utils/get-community-plugin.js +53 -0
- package/dist/commands/utils/get-community-plugin.mjs +17 -0
- package/dist/commands/utils/load-metro-config.d.ts +3 -0
- package/dist/commands/utils/load-metro-config.js +85 -0
- package/dist/commands/utils/load-metro-config.mjs +41 -0
- package/dist/commands/utils/path-utils.d.ts +2 -0
- package/dist/commands/utils/path-utils.js +51 -0
- package/dist/commands/utils/path-utils.mjs +11 -0
- package/dist/commands/utils/save-bundle-and-map.d.ts +5 -0
- package/dist/commands/utils/save-bundle-and-map.js +80 -0
- package/dist/commands/utils/save-bundle-and-map.mjs +33 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +44 -0
- package/dist/index.mjs +3 -0
- package/dist/logger.d.ts +2 -0
- package/dist/logger.js +43 -0
- package/dist/logger.mjs +6 -0
- package/dist/modules/HMRClient.ts +31 -0
- package/dist/modules/HMRClientShim.ts +1 -0
- package/dist/modules/asyncRequire.ts +156 -0
- package/dist/modules/asyncStartup.tsx +43 -0
- package/dist/modules/getDevServer.ts +15 -0
- package/dist/modules/metroCorePlugin.ts +87 -0
- package/dist/plugin/babel-transformer.d.ts +11 -0
- package/dist/plugin/babel-transformer.js +72 -0
- package/dist/plugin/babel-transformer.mjs +25 -0
- package/dist/plugin/constants.d.ts +10 -0
- package/dist/plugin/constants.js +76 -0
- package/dist/plugin/constants.mjs +12 -0
- package/dist/plugin/generators.d.ts +13 -0
- package/dist/plugin/generators.js +164 -0
- package/dist/plugin/generators.mjs +102 -0
- package/dist/plugin/helpers.d.ts +8 -0
- package/dist/plugin/helpers.js +127 -0
- package/dist/plugin/helpers.mjs +58 -0
- package/dist/plugin/index.d.ts +11 -0
- package/dist/plugin/index.js +219 -0
- package/dist/plugin/index.mjs +172 -0
- package/dist/plugin/manifest-middleware.d.ts +12 -0
- package/dist/plugin/manifest-middleware.js +217 -0
- package/dist/plugin/manifest-middleware.mjs +170 -0
- package/dist/plugin/manifest.d.ts +16 -0
- package/dist/plugin/manifest.js +246 -0
- package/dist/plugin/manifest.mjs +185 -0
- package/dist/plugin/normalize-extra-options.d.ts +8 -0
- package/dist/plugin/normalize-extra-options.js +50 -0
- package/dist/plugin/normalize-extra-options.mjs +13 -0
- package/dist/plugin/normalize-options.d.ts +7 -0
- package/dist/plugin/normalize-options.js +139 -0
- package/dist/plugin/normalize-options.mjs +92 -0
- package/dist/plugin/resolver.d.ts +26 -0
- package/dist/plugin/resolver.js +203 -0
- package/dist/plugin/resolver.mjs +159 -0
- package/dist/plugin/rewrite-request.d.ts +14 -0
- package/dist/plugin/rewrite-request.js +89 -0
- package/dist/plugin/rewrite-request.mjs +42 -0
- package/dist/plugin/serializer.d.ts +6 -0
- package/dist/plugin/serializer.js +191 -0
- package/dist/plugin/serializer.mjs +144 -0
- package/dist/plugin/validate-options.d.ts +2 -0
- package/dist/plugin/validate-options.js +165 -0
- package/dist/plugin/validate-options.mjs +117 -0
- package/dist/runtime/host-entry.js +3 -0
- package/dist/runtime/init-host.js +31 -0
- package/dist/runtime/remote-entry.js +57 -0
- package/dist/runtime/remote-hmr.js +19 -0
- package/dist/runtime/remote-module-registry.js +57 -0
- package/dist/runtime/remote-module.js +2 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.js +18 -0
- package/dist/types.mjs +1 -0
- package/dist/utils/errors.d.ts +8 -0
- package/dist/utils/errors.js +54 -0
- package/dist/utils/errors.mjs +14 -0
- package/dist/utils/federated-remote-types.d.ts +12 -0
- package/dist/utils/federated-remote-types.js +140 -0
- package/dist/utils/federated-remote-types.mjs +90 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +47 -0
- package/dist/utils/index.mjs +3 -0
- package/dist/utils/metro-compat.d.ts +23 -0
- package/dist/utils/metro-compat.js +74 -0
- package/dist/utils/metro-compat.mjs +26 -0
- package/dist/utils/vm-manager.d.ts +21 -0
- package/dist/utils/vm-manager.js +118 -0
- package/dist/utils/vm-manager.mjs +70 -0
- package/package.json +106 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import 'mf:async-require';
|
|
2
|
+
import { loadSharedToRegistry } from 'mf:remote-module-registry';
|
|
3
|
+
import { init as runtimeInit } from '@module-federation/runtime';
|
|
4
|
+
__PLUGINS__;
|
|
5
|
+
const usedRemotes = __REMOTES__;
|
|
6
|
+
const usedShared = __SHARED__;
|
|
7
|
+
const exposesMap = __EXPOSES_MAP__;
|
|
8
|
+
function get(moduleName) {
|
|
9
|
+
if (!(moduleName in exposesMap)) throw new Error(`Module ${moduleName} does not exist in container.`);
|
|
10
|
+
return exposesMap[moduleName]().then((m)=>()=>m);
|
|
11
|
+
}
|
|
12
|
+
const initTokens = {};
|
|
13
|
+
const name = __NAME__;
|
|
14
|
+
const shareScopeName = 'default';
|
|
15
|
+
const shareStrategy = __SHARE_STRATEGY__;
|
|
16
|
+
let hmrInitialized = false;
|
|
17
|
+
async function init(shared = {}, initScope = []) {
|
|
18
|
+
const instance = runtimeInit({
|
|
19
|
+
name,
|
|
20
|
+
remotes: usedRemotes,
|
|
21
|
+
shared: usedShared,
|
|
22
|
+
plugins,
|
|
23
|
+
shareStrategy
|
|
24
|
+
});
|
|
25
|
+
let initToken = initTokens[shareScopeName];
|
|
26
|
+
if (!initToken) initToken = initTokens[shareScopeName] = {
|
|
27
|
+
from: name
|
|
28
|
+
};
|
|
29
|
+
if (initScope.indexOf(initToken) >= 0) return;
|
|
30
|
+
initScope.push(initToken);
|
|
31
|
+
instance.initShareScopeMap(shareScopeName, shared);
|
|
32
|
+
const initSharingPromise = Promise.all(instance.initializeSharing(shareScopeName, {
|
|
33
|
+
strategy: shareStrategy,
|
|
34
|
+
from: 'build',
|
|
35
|
+
initScope
|
|
36
|
+
}));
|
|
37
|
+
__EARLY_SHARED__.forEach(loadSharedToRegistry);
|
|
38
|
+
await initSharingPromise;
|
|
39
|
+
if (__DEV__ && !hmrInitialized) {
|
|
40
|
+
const hmr = require('mf:remote-hmr');
|
|
41
|
+
hmr.setup();
|
|
42
|
+
hmrInitialized = true;
|
|
43
|
+
}
|
|
44
|
+
await Promise.all(Object.keys(shared).map(loadSharedToRegistry));
|
|
45
|
+
return instance;
|
|
46
|
+
}
|
|
47
|
+
globalThis.__FEDERATION__ ??= {};
|
|
48
|
+
globalThis.__FEDERATION__.__NATIVE__ ??= {};
|
|
49
|
+
globalThis.__FEDERATION__.__NATIVE__[name] ??= {};
|
|
50
|
+
globalThis.__FEDERATION__.__NATIVE__[name].deps ??= {
|
|
51
|
+
shared: {},
|
|
52
|
+
remotes: {}
|
|
53
|
+
};
|
|
54
|
+
globalThis.__FEDERATION__.__NATIVE__[name].exports = {
|
|
55
|
+
get,
|
|
56
|
+
init
|
|
57
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function parseUrl(url) {
|
|
2
|
+
const urlPattern = /^((https?):\/\/([^:/]+)(?::(\d+))?)\/?(.*)?$/;
|
|
3
|
+
const match = url.match(urlPattern);
|
|
4
|
+
if (!match) throw new Error('Invalid URL: ' + url);
|
|
5
|
+
const [, origin, scheme, host, port, path] = match;
|
|
6
|
+
return {
|
|
7
|
+
origin,
|
|
8
|
+
scheme,
|
|
9
|
+
host,
|
|
10
|
+
port,
|
|
11
|
+
path
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export function setup() {
|
|
15
|
+
const HMRClient = require('react-native/Libraries/Utilities/HMRClient');
|
|
16
|
+
const platform = require('react-native').Platform.OS;
|
|
17
|
+
const { scheme, host, port, path } = parseUrl(globalThis.__FEDERATION__.__NATIVE__[__METRO_GLOBAL_PREFIX__].origin);
|
|
18
|
+
HMRClient.default.setup(platform, path, host, port, true, scheme);
|
|
19
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { loadRemote, loadShare, loadShareSync } from '@module-federation/runtime';
|
|
2
|
+
const registry = {};
|
|
3
|
+
const loading = {};
|
|
4
|
+
const earlyModuleTest = __EARLY_MODULE_TEST__;
|
|
5
|
+
function cloneModule(module, target) {
|
|
6
|
+
for (const key of Object.getOwnPropertyNames(module)){
|
|
7
|
+
const descriptor = Object.getOwnPropertyDescriptor(module, key);
|
|
8
|
+
Object.defineProperty(target, key, descriptor);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export async function loadAndGetShared(id) {
|
|
12
|
+
await loadSharedToRegistry(id);
|
|
13
|
+
return getModuleFromRegistry(id);
|
|
14
|
+
}
|
|
15
|
+
export async function loadAndGetRemote(id) {
|
|
16
|
+
await loadRemoteToRegistry(id);
|
|
17
|
+
return getModuleFromRegistry(id);
|
|
18
|
+
}
|
|
19
|
+
export async function loadRemoteToRegistry(id) {
|
|
20
|
+
const promise = loading[id];
|
|
21
|
+
if (promise) await promise;
|
|
22
|
+
else {
|
|
23
|
+
registry[id] = {};
|
|
24
|
+
loading[id] = (async ()=>{
|
|
25
|
+
const remoteModule = await loadRemote(id);
|
|
26
|
+
cloneModule(remoteModule, registry[id]);
|
|
27
|
+
})();
|
|
28
|
+
await loading[id];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function loadSharedToRegistry(id) {
|
|
32
|
+
if (earlyModuleTest.test(id)) return loadSharedToRegistrySync(id);
|
|
33
|
+
return loadSharedToRegistryAsync(id);
|
|
34
|
+
}
|
|
35
|
+
export async function loadSharedToRegistryAsync(id) {
|
|
36
|
+
const promise = loading[id];
|
|
37
|
+
if (promise) await promise;
|
|
38
|
+
else {
|
|
39
|
+
registry[id] = {};
|
|
40
|
+
loading[id] = (async ()=>{
|
|
41
|
+
const factory = await loadShare(id);
|
|
42
|
+
const sharedModule = factory();
|
|
43
|
+
cloneModule(sharedModule, registry[id]);
|
|
44
|
+
})();
|
|
45
|
+
await loading[id];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export function loadSharedToRegistrySync(id) {
|
|
49
|
+
if (loading[id]) return;
|
|
50
|
+
loading[id] = loadShareSync(id);
|
|
51
|
+
registry[id] = loading[id]();
|
|
52
|
+
}
|
|
53
|
+
export function getModuleFromRegistry(id) {
|
|
54
|
+
const module = registry[id];
|
|
55
|
+
if (!module) throw new Error(`Module ${id} not found in registry`);
|
|
56
|
+
return module;
|
|
57
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
|
+
export interface ModuleFederationConfig extends moduleFederationPlugin.ModuleFederationPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use runtimePlugins instead. Scheduled for removal in the next major version.
|
|
5
|
+
*/
|
|
6
|
+
plugins?: string[];
|
|
7
|
+
}
|
|
8
|
+
export type ShareObject = Record<string, moduleFederationPlugin.SharedConfig>;
|
|
9
|
+
export interface ModuleFederationConfigNormalized {
|
|
10
|
+
name: string;
|
|
11
|
+
filename: string;
|
|
12
|
+
remotes: Record<string, string>;
|
|
13
|
+
exposes: Record<string, string>;
|
|
14
|
+
shared: ShareObject;
|
|
15
|
+
shareStrategy: moduleFederationPlugin.SharedStrategy;
|
|
16
|
+
plugins: string[];
|
|
17
|
+
dts: boolean | moduleFederationPlugin.PluginDtsOptions;
|
|
18
|
+
}
|
|
19
|
+
export type ModuleFederationExtraOptions = {
|
|
20
|
+
flags?: MetroMFFlags;
|
|
21
|
+
};
|
|
22
|
+
export type MetroMFFlags = {
|
|
23
|
+
unstable_patchHMRClient?: boolean;
|
|
24
|
+
unstable_patchInitializeCore?: boolean;
|
|
25
|
+
unstable_patchRuntimeRequire?: boolean;
|
|
26
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
const inlineString = (str = '')=>str.replace(/(\s{2,})/gm, ' ').trim();
|
|
31
|
+
class EnhancedError extends Error {
|
|
32
|
+
constructor(msg, originalError){
|
|
33
|
+
super(inlineString(msg));
|
|
34
|
+
if (null != originalError) this.stack = 'string' == typeof originalError ? originalError : originalError.stack || ''.split('\n').slice(0, 2).join('\n');
|
|
35
|
+
else this.stack = '';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
class ConfigError extends EnhancedError {
|
|
39
|
+
}
|
|
40
|
+
class CLIError extends EnhancedError {
|
|
41
|
+
}
|
|
42
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
43
|
+
CLIError: ()=>CLIError,
|
|
44
|
+
ConfigError: ()=>ConfigError
|
|
45
|
+
});
|
|
46
|
+
exports.CLIError = __webpack_exports__.CLIError;
|
|
47
|
+
exports.ConfigError = __webpack_exports__.ConfigError;
|
|
48
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
49
|
+
"CLIError",
|
|
50
|
+
"ConfigError"
|
|
51
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
52
|
+
Object.defineProperty(exports, '__esModule', {
|
|
53
|
+
value: true
|
|
54
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
const inlineString = (str = '')=>str.replace(/(\s{2,})/gm, ' ').trim();
|
|
3
|
+
class EnhancedError extends Error {
|
|
4
|
+
constructor(msg, originalError){
|
|
5
|
+
super(inlineString(msg));
|
|
6
|
+
if (null != originalError) this.stack = 'string' == typeof originalError ? originalError : originalError.stack || ''.split('\n').slice(0, 2).join('\n');
|
|
7
|
+
else this.stack = '';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
class ConfigError extends EnhancedError {
|
|
11
|
+
}
|
|
12
|
+
class CLIError extends EnhancedError {
|
|
13
|
+
}
|
|
14
|
+
export { CLIError, ConfigError };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ModuleFederationConfigNormalized } from '../types';
|
|
2
|
+
export type FederatedTypesMeta = {
|
|
3
|
+
zipName: string;
|
|
4
|
+
apiFileName: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function maybeGenerateFederatedRemoteTypes(opts: {
|
|
7
|
+
federationConfig: ModuleFederationConfigNormalized;
|
|
8
|
+
projectRoot: string;
|
|
9
|
+
outputDir: string;
|
|
10
|
+
logger: Pick<Console, 'info' | 'warn'>;
|
|
11
|
+
}): Promise<FederatedTypesMeta | undefined>;
|
|
12
|
+
export declare function applyTypesMetaToManifest(manifest: Record<string, any>, typesMeta: FederatedTypesMeta | undefined): Record<string, any>;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
+
})();
|
|
27
|
+
(()=>{
|
|
28
|
+
__webpack_require__.r = (exports1)=>{
|
|
29
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
30
|
+
value: 'Module'
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
33
|
+
value: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
var __webpack_exports__ = {};
|
|
38
|
+
__webpack_require__.r(__webpack_exports__);
|
|
39
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
applyTypesMetaToManifest: ()=>applyTypesMetaToManifest,
|
|
41
|
+
maybeGenerateFederatedRemoteTypes: ()=>maybeGenerateFederatedRemoteTypes
|
|
42
|
+
});
|
|
43
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
44
|
+
const external_node_util_namespaceObject = require("node:util");
|
|
45
|
+
var external_node_util_default = /*#__PURE__*/ __webpack_require__.n(external_node_util_namespaceObject);
|
|
46
|
+
async function maybeGenerateFederatedRemoteTypes(opts) {
|
|
47
|
+
const { federationConfig, projectRoot, outputDir, logger } = opts;
|
|
48
|
+
if (false === federationConfig.dts) return;
|
|
49
|
+
const dtsPlugin = await import("@module-federation/dts-plugin");
|
|
50
|
+
const dtsPluginCore = await import("@module-federation/dts-plugin/core");
|
|
51
|
+
const dtsConfig = true === federationConfig.dts ? {
|
|
52
|
+
consumeTypes: false
|
|
53
|
+
} : 'object' != typeof federationConfig.dts || null === federationConfig.dts || Object.prototype.hasOwnProperty.call(federationConfig.dts, 'consumeTypes') ? federationConfig.dts : {
|
|
54
|
+
...federationConfig.dts,
|
|
55
|
+
consumeTypes: false
|
|
56
|
+
};
|
|
57
|
+
const mfOptions = {
|
|
58
|
+
name: federationConfig.name,
|
|
59
|
+
filename: federationConfig.filename,
|
|
60
|
+
remotes: federationConfig.remotes,
|
|
61
|
+
exposes: federationConfig.exposes,
|
|
62
|
+
shared: federationConfig.shared,
|
|
63
|
+
dts: dtsConfig
|
|
64
|
+
};
|
|
65
|
+
const normalizedDtsOptions = dtsPlugin.normalizeDtsOptions(mfOptions, projectRoot, {
|
|
66
|
+
defaultGenerateOptions: {
|
|
67
|
+
generateAPITypes: true,
|
|
68
|
+
compileInChildProcess: false,
|
|
69
|
+
abortOnError: false,
|
|
70
|
+
extractThirdParty: false,
|
|
71
|
+
extractRemoteTypes: false
|
|
72
|
+
},
|
|
73
|
+
defaultConsumeOptions: {
|
|
74
|
+
abortOnError: true,
|
|
75
|
+
consumeAPITypes: true
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
if (!normalizedDtsOptions) return;
|
|
79
|
+
const dtsManagerOptions = dtsPlugin.normalizeGenerateTypesOptions({
|
|
80
|
+
context: projectRoot,
|
|
81
|
+
outputDir,
|
|
82
|
+
dtsOptions: normalizedDtsOptions,
|
|
83
|
+
pluginOptions: mfOptions
|
|
84
|
+
});
|
|
85
|
+
if (!dtsManagerOptions) return;
|
|
86
|
+
if (dtsManagerOptions.host) {
|
|
87
|
+
let remoteTypeUrls = dtsManagerOptions.host.remoteTypeUrls;
|
|
88
|
+
if ('function' == typeof remoteTypeUrls) remoteTypeUrls = await remoteTypeUrls();
|
|
89
|
+
await dtsPluginCore.consumeTypes({
|
|
90
|
+
...dtsManagerOptions,
|
|
91
|
+
host: {
|
|
92
|
+
...dtsManagerOptions.host,
|
|
93
|
+
remoteTypeUrls
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
logger.info(`${external_node_util_default().styleText('blue', 'Generating federated types (d.ts)')}`);
|
|
98
|
+
await dtsPlugin.generateTypesAPI({
|
|
99
|
+
dtsManagerOptions
|
|
100
|
+
});
|
|
101
|
+
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = dtsPluginCore.retrieveTypesAssetsInfo(dtsManagerOptions.remote);
|
|
102
|
+
const produced = {};
|
|
103
|
+
const fileExists = async (p)=>{
|
|
104
|
+
try {
|
|
105
|
+
await external_node_fs_namespaceObject.promises.stat(p);
|
|
106
|
+
return true;
|
|
107
|
+
} catch {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
if (zipTypesPath && zipName && await fileExists(zipTypesPath)) produced.zipName = zipName;
|
|
112
|
+
if (apiTypesPath && apiFileName && await fileExists(apiTypesPath)) produced.apiFileName = apiFileName;
|
|
113
|
+
if (process.env['FEDERATION_DEBUG']) logger.info(`dts debug: zipTypesPath=${zipTypesPath} zipExists=${String(Boolean(produced.zipName))} apiTypesPath=${apiTypesPath} apiExists=${String(Boolean(produced.apiFileName))}`);
|
|
114
|
+
if (!produced.zipName && !produced.apiFileName) return void logger.warn(`${external_node_util_default().styleText('yellow', 'Federated types enabled, but no types files were produced.')}`);
|
|
115
|
+
logger.info(`Done writing federated types:\n${external_node_util_default().styleText('dim', [
|
|
116
|
+
produced.zipName,
|
|
117
|
+
produced.apiFileName
|
|
118
|
+
].filter(Boolean).join('\n'))}`);
|
|
119
|
+
return {
|
|
120
|
+
zipName: produced.zipName ?? '',
|
|
121
|
+
apiFileName: produced.apiFileName ?? ''
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function applyTypesMetaToManifest(manifest, typesMeta) {
|
|
125
|
+
if (!typesMeta?.zipName && !typesMeta?.apiFileName) return manifest;
|
|
126
|
+
manifest.metaData = manifest.metaData || {};
|
|
127
|
+
manifest.metaData.types = manifest.metaData.types || {};
|
|
128
|
+
if (typesMeta.zipName) manifest.metaData.types.zip = typesMeta.zipName;
|
|
129
|
+
if (typesMeta.apiFileName) manifest.metaData.types.api = typesMeta.apiFileName;
|
|
130
|
+
return manifest;
|
|
131
|
+
}
|
|
132
|
+
exports.applyTypesMetaToManifest = __webpack_exports__.applyTypesMetaToManifest;
|
|
133
|
+
exports.maybeGenerateFederatedRemoteTypes = __webpack_exports__.maybeGenerateFederatedRemoteTypes;
|
|
134
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
135
|
+
"applyTypesMetaToManifest",
|
|
136
|
+
"maybeGenerateFederatedRemoteTypes"
|
|
137
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
138
|
+
Object.defineProperty(exports, '__esModule', {
|
|
139
|
+
value: true
|
|
140
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { promises } from "node:fs";
|
|
3
|
+
import node_util from "node:util";
|
|
4
|
+
async function maybeGenerateFederatedRemoteTypes(opts) {
|
|
5
|
+
const { federationConfig, projectRoot, outputDir, logger } = opts;
|
|
6
|
+
if (false === federationConfig.dts) return;
|
|
7
|
+
const dtsPlugin = await import("@module-federation/dts-plugin");
|
|
8
|
+
const dtsPluginCore = await import("@module-federation/dts-plugin/core");
|
|
9
|
+
const dtsConfig = true === federationConfig.dts ? {
|
|
10
|
+
consumeTypes: false
|
|
11
|
+
} : 'object' != typeof federationConfig.dts || null === federationConfig.dts || Object.prototype.hasOwnProperty.call(federationConfig.dts, 'consumeTypes') ? federationConfig.dts : {
|
|
12
|
+
...federationConfig.dts,
|
|
13
|
+
consumeTypes: false
|
|
14
|
+
};
|
|
15
|
+
const mfOptions = {
|
|
16
|
+
name: federationConfig.name,
|
|
17
|
+
filename: federationConfig.filename,
|
|
18
|
+
remotes: federationConfig.remotes,
|
|
19
|
+
exposes: federationConfig.exposes,
|
|
20
|
+
shared: federationConfig.shared,
|
|
21
|
+
dts: dtsConfig
|
|
22
|
+
};
|
|
23
|
+
const normalizedDtsOptions = dtsPlugin.normalizeDtsOptions(mfOptions, projectRoot, {
|
|
24
|
+
defaultGenerateOptions: {
|
|
25
|
+
generateAPITypes: true,
|
|
26
|
+
compileInChildProcess: false,
|
|
27
|
+
abortOnError: false,
|
|
28
|
+
extractThirdParty: false,
|
|
29
|
+
extractRemoteTypes: false
|
|
30
|
+
},
|
|
31
|
+
defaultConsumeOptions: {
|
|
32
|
+
abortOnError: true,
|
|
33
|
+
consumeAPITypes: true
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
if (!normalizedDtsOptions) return;
|
|
37
|
+
const dtsManagerOptions = dtsPlugin.normalizeGenerateTypesOptions({
|
|
38
|
+
context: projectRoot,
|
|
39
|
+
outputDir,
|
|
40
|
+
dtsOptions: normalizedDtsOptions,
|
|
41
|
+
pluginOptions: mfOptions
|
|
42
|
+
});
|
|
43
|
+
if (!dtsManagerOptions) return;
|
|
44
|
+
if (dtsManagerOptions.host) {
|
|
45
|
+
let remoteTypeUrls = dtsManagerOptions.host.remoteTypeUrls;
|
|
46
|
+
if ('function' == typeof remoteTypeUrls) remoteTypeUrls = await remoteTypeUrls();
|
|
47
|
+
await dtsPluginCore.consumeTypes({
|
|
48
|
+
...dtsManagerOptions,
|
|
49
|
+
host: {
|
|
50
|
+
...dtsManagerOptions.host,
|
|
51
|
+
remoteTypeUrls
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
logger.info(`${node_util.styleText('blue', 'Generating federated types (d.ts)')}`);
|
|
56
|
+
await dtsPlugin.generateTypesAPI({
|
|
57
|
+
dtsManagerOptions
|
|
58
|
+
});
|
|
59
|
+
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = dtsPluginCore.retrieveTypesAssetsInfo(dtsManagerOptions.remote);
|
|
60
|
+
const produced = {};
|
|
61
|
+
const fileExists = async (p)=>{
|
|
62
|
+
try {
|
|
63
|
+
await promises.stat(p);
|
|
64
|
+
return true;
|
|
65
|
+
} catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
if (zipTypesPath && zipName && await fileExists(zipTypesPath)) produced.zipName = zipName;
|
|
70
|
+
if (apiTypesPath && apiFileName && await fileExists(apiTypesPath)) produced.apiFileName = apiFileName;
|
|
71
|
+
if (process.env['FEDERATION_DEBUG']) logger.info(`dts debug: zipTypesPath=${zipTypesPath} zipExists=${String(Boolean(produced.zipName))} apiTypesPath=${apiTypesPath} apiExists=${String(Boolean(produced.apiFileName))}`);
|
|
72
|
+
if (!produced.zipName && !produced.apiFileName) return void logger.warn(`${node_util.styleText('yellow', 'Federated types enabled, but no types files were produced.')}`);
|
|
73
|
+
logger.info(`Done writing federated types:\n${node_util.styleText('dim', [
|
|
74
|
+
produced.zipName,
|
|
75
|
+
produced.apiFileName
|
|
76
|
+
].filter(Boolean).join('\n'))}`);
|
|
77
|
+
return {
|
|
78
|
+
zipName: produced.zipName ?? '',
|
|
79
|
+
apiFileName: produced.apiFileName ?? ''
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function applyTypesMetaToManifest(manifest, typesMeta) {
|
|
83
|
+
if (!typesMeta?.zipName && !typesMeta?.apiFileName) return manifest;
|
|
84
|
+
manifest.metaData = manifest.metaData || {};
|
|
85
|
+
manifest.metaData.types = manifest.metaData.types || {};
|
|
86
|
+
if (typesMeta.zipName) manifest.metaData.types.zip = typesMeta.zipName;
|
|
87
|
+
if (typesMeta.apiFileName) manifest.metaData.types.api = typesMeta.apiFileName;
|
|
88
|
+
return manifest;
|
|
89
|
+
}
|
|
90
|
+
export { applyTypesMetaToManifest, maybeGenerateFederatedRemoteTypes };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
CLIError: ()=>external_errors_js_namespaceObject.CLIError,
|
|
32
|
+
ConfigError: ()=>external_errors_js_namespaceObject.ConfigError,
|
|
33
|
+
VirtualModuleManager: ()=>external_vm_manager_js_namespaceObject.VirtualModuleManager
|
|
34
|
+
});
|
|
35
|
+
const external_errors_js_namespaceObject = require("./errors.js");
|
|
36
|
+
const external_vm_manager_js_namespaceObject = require("./vm-manager.js");
|
|
37
|
+
exports.CLIError = __webpack_exports__.CLIError;
|
|
38
|
+
exports.ConfigError = __webpack_exports__.ConfigError;
|
|
39
|
+
exports.VirtualModuleManager = __webpack_exports__.VirtualModuleManager;
|
|
40
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
41
|
+
"CLIError",
|
|
42
|
+
"ConfigError",
|
|
43
|
+
"VirtualModuleManager"
|
|
44
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
45
|
+
Object.defineProperty(exports, '__esModule', {
|
|
46
|
+
value: true
|
|
47
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metro Compatibility Layer
|
|
3
|
+
*
|
|
4
|
+
* Provides backwards-compatible imports for Metro 0.82 and 0.83+
|
|
5
|
+
*
|
|
6
|
+
* Metro 0.83 introduced a restrictive `exports` field that only allows
|
|
7
|
+
* `metro/private/*` paths instead of direct `metro/src/*` imports.
|
|
8
|
+
*
|
|
9
|
+
* This module dynamically resolves the correct import path based on the
|
|
10
|
+
* installed Metro version, ensuring compatibility with both versions.
|
|
11
|
+
*/
|
|
12
|
+
import type DefaultServer from 'metro/src/Server';
|
|
13
|
+
import type DefaultBaseJSBundle from 'metro/src/DeltaBundler/Serializers/baseJSBundle';
|
|
14
|
+
import type DefaultCountingSet from 'metro/src/lib/CountingSet';
|
|
15
|
+
import type DefaultBundleToString from 'metro/src/lib/bundleToString';
|
|
16
|
+
import type { MixedSourceMap } from 'metro-source-map';
|
|
17
|
+
export declare const Server: typeof DefaultServer;
|
|
18
|
+
export type Server = DefaultServer;
|
|
19
|
+
export declare const baseJSBundle: typeof DefaultBaseJSBundle;
|
|
20
|
+
export declare const CountingSet: typeof DefaultCountingSet;
|
|
21
|
+
export declare const bundleToString: typeof DefaultBundleToString;
|
|
22
|
+
export declare const relativizeSourceMapInline: (sourceMap: MixedSourceMap, sourcesRoot: string) => void;
|
|
23
|
+
export type { RequestOptions, OutputOptions } from 'metro/src/shared/types';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
function resolveAndImport(metro83Path, metro82Path) {
|
|
31
|
+
let resolvedPath;
|
|
32
|
+
try {
|
|
33
|
+
resolvedPath = require.resolve(metro83Path);
|
|
34
|
+
} catch {
|
|
35
|
+
try {
|
|
36
|
+
resolvedPath = require.resolve(metro82Path);
|
|
37
|
+
} catch {
|
|
38
|
+
throw new Error(`Could not resolve 'metro' module. Tried:\n - ${metro83Path}\n - ${metro82Path}\nEnsure 'metro' is installed.`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return require(resolvedPath);
|
|
42
|
+
}
|
|
43
|
+
function getDefaultExport(mod) {
|
|
44
|
+
if (null != mod && 'object' == typeof mod && 'default' in mod) return mod.default;
|
|
45
|
+
return mod;
|
|
46
|
+
}
|
|
47
|
+
const Server = getDefaultExport(resolveAndImport('metro/private/Server', 'metro/src/Server'));
|
|
48
|
+
const baseJSBundle = getDefaultExport(resolveAndImport('metro/private/DeltaBundler/Serializers/baseJSBundle', 'metro/src/DeltaBundler/Serializers/baseJSBundle'));
|
|
49
|
+
const CountingSet = getDefaultExport(resolveAndImport('metro/private/lib/CountingSet', 'metro/src/lib/CountingSet'));
|
|
50
|
+
const bundleToString = getDefaultExport(resolveAndImport('metro/private/lib/bundleToString', 'metro/src/lib/bundleToString'));
|
|
51
|
+
const relativizeSourceMapModule = resolveAndImport('metro/private/lib/relativizeSourceMap', 'metro/src/lib/relativizeSourceMap');
|
|
52
|
+
const relativizeSourceMapInline = relativizeSourceMapModule.relativizeSourceMapInline || getDefaultExport(relativizeSourceMapModule);
|
|
53
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
54
|
+
CountingSet: CountingSet,
|
|
55
|
+
Server: Server,
|
|
56
|
+
baseJSBundle: baseJSBundle,
|
|
57
|
+
bundleToString: bundleToString,
|
|
58
|
+
relativizeSourceMapInline: relativizeSourceMapInline
|
|
59
|
+
});
|
|
60
|
+
exports.CountingSet = __webpack_exports__.CountingSet;
|
|
61
|
+
exports.Server = __webpack_exports__.Server;
|
|
62
|
+
exports.baseJSBundle = __webpack_exports__.baseJSBundle;
|
|
63
|
+
exports.bundleToString = __webpack_exports__.bundleToString;
|
|
64
|
+
exports.relativizeSourceMapInline = __webpack_exports__.relativizeSourceMapInline;
|
|
65
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
66
|
+
"CountingSet",
|
|
67
|
+
"Server",
|
|
68
|
+
"baseJSBundle",
|
|
69
|
+
"bundleToString",
|
|
70
|
+
"relativizeSourceMapInline"
|
|
71
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
72
|
+
Object.defineProperty(exports, '__esModule', {
|
|
73
|
+
value: true
|
|
74
|
+
});
|