@module-federation/dts-plugin 2.4.0 → 2.5.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.
@@ -1,6 +1,7 @@
1
1
  const require_Action = require('./Action-CzhPMw2i.js');
2
2
  let fs = require("fs");
3
3
  fs = require_Action.__toESM(fs);
4
+ let url = require("url");
4
5
  let path = require("path");
5
6
  path = require_Action.__toESM(path);
6
7
  let _module_federation_sdk = require("@module-federation/sdk");
@@ -13,7 +14,6 @@ isomorphic_ws = require_Action.__toESM(isomorphic_ws);
13
14
  let http = require("http");
14
15
  let node_schedule = require("node-schedule");
15
16
  node_schedule = require_Action.__toESM(node_schedule);
16
- let url = require("url");
17
17
 
18
18
  //#region src/server/message/API/API.ts
19
19
  let APIKind = /* @__PURE__ */ function(APIKind) {
package/dist/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @module-federation/dts-plugin
2
2
 
3
+ ## 2.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - b79ba22: Update the dts plugin websocket dependency to a version that includes the CVE-2026-45736 fix.
8
+ - b553153: Fix `__dirname is not defined` ReferenceError when `@module-federation/dts-plugin` is consumed as ESM. `DevWorker`, `DevPlugin`, and `createBroker` now derive `__dirname` from `import.meta.url` (matching the existing `DtsWorker` shim) so the ESM build no longer emits bare `__dirname`.
9
+ - b9b3b8c: Fix Windows manifest type URL resolution in dts-plugin consumeTypes and allow the default IP family option to auto-select with `0`.
10
+ - Updated dependencies [b9b3b8c]
11
+ - @module-federation/sdk@2.5.1
12
+ - @module-federation/managers@2.5.1
13
+ - @module-federation/third-party-dts-extractor@2.5.1
14
+ - @module-federation/error-codes@2.5.1
15
+
16
+ ## 2.5.0
17
+
18
+ ### Patch Changes
19
+
20
+ - 13dce52: fix(dts-plugin): read manifest metadata when consuming DTS files from manifest remotes.
21
+ - Updated dependencies [5d4095d]
22
+ - Updated dependencies [0716c11]
23
+ - Updated dependencies [41281f4]
24
+ - @module-federation/sdk@2.5.0
25
+ - @module-federation/error-codes@2.5.0
26
+ - @module-federation/managers@2.5.0
27
+ - @module-federation/third-party-dts-extractor@2.5.0
28
+
3
29
  ## 2.4.0
4
30
 
5
31
  ### Patch Changes
@@ -1,11 +1,11 @@
1
1
  const require_Action = require('./Action-CzhPMw2i.js');
2
- const require_expose_rpc = require('./expose-rpc-CQq6zYK-.js');
2
+ const require_expose_rpc = require('./expose-rpc-XLxmAXIW.js');
3
+ let url = require("url");
3
4
  let path = require("path");
4
5
  path = require_Action.__toESM(path);
5
6
  let crypto = require("crypto");
6
7
  let child_process = require("child_process");
7
8
  child_process = require_Action.__toESM(child_process);
8
- let url = require("url");
9
9
  let process$1 = require("process");
10
10
  process$1 = require_Action.__toESM(process$1);
11
11
 
package/dist/core.js CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- require('./Broker-DRFgFvXI.js');
3
- const require_expose_rpc = require('./expose-rpc-CQq6zYK-.js');
4
- const require_consumeTypes = require('./consumeTypes-DxGMNavh.js');
2
+ require('./Broker-CaenCqdn.js');
3
+ const require_expose_rpc = require('./expose-rpc-XLxmAXIW.js');
4
+ const require_consumeTypes = require('./consumeTypes-FbF0o6AJ.js');
5
5
 
6
6
  exports.DTSManager = require_expose_rpc.DTSManager;
7
7
  exports.DtsWorker = require_consumeTypes.DtsWorker;
@@ -1,4 +1,4 @@
1
- import { CreateScriptHookReturn, GlobalModuleInfo, Manifest, Module, ModuleInfo, RemoteEntryType, RemoteWithEntry, RemoteWithVersion, TreeShakingStatus } from "@module-federation/sdk";
1
+ import { CreateLinkHookReturnDom, CreateScriptHookReturn, GlobalModuleInfo, Manifest, Module, ModuleInfo, RemoteEntryType, RemoteWithEntry, RemoteWithVersion, TreeShakingStatus } from "@module-federation/sdk";
2
2
 
3
3
  //#region ../runtime-core/dist/utils/hooks/syncHook.d.ts
4
4
  //#region src/utils/hooks/syncHook.d.ts
@@ -24,7 +24,7 @@ declare class AsyncHook<T, ExternalEmitReturnType = CallbackReturnType$1> extend
24
24
  //#endregion
25
25
  //#region ../runtime-core/dist/utils/hooks/syncWaterfallHook.d.ts
26
26
  //#region src/utils/hooks/syncWaterfallHook.d.ts
27
- declare class SyncWaterfallHook<T extends Record<string, any>> extends SyncHook<[T], T> {
27
+ declare class SyncWaterfallHook<T extends Record<string, any>> extends SyncHook<[T], T | void> {
28
28
  onerror: (errMsg: string | Error | unknown) => void;
29
29
  constructor(type: string);
30
30
  emit(data: T): T;
@@ -32,8 +32,8 @@ declare class SyncWaterfallHook<T extends Record<string, any>> extends SyncHook<
32
32
  //#endregion
33
33
  //#region ../runtime-core/dist/utils/hooks/asyncWaterfallHooks.d.ts
34
34
  //#region src/utils/hooks/asyncWaterfallHooks.d.ts
35
- type CallbackReturnType<T> = T | Promise<T>;
36
- declare class AsyncWaterfallHook<T extends Record<string, any>> extends SyncHook<[T], CallbackReturnType<T>> {
35
+ type CallbackReturnType<T> = T | void | Promise<T | void>;
36
+ declare class AsyncWaterfallHook<T extends object> extends SyncHook<[T], CallbackReturnType<T>> {
37
37
  onerror: (errMsg: string | Error | unknown) => void;
38
38
  constructor(type: string);
39
39
  emit(data: T): Promise<T>;
@@ -183,6 +183,30 @@ type PreloadOptions = Array<{
183
183
  remote: Remote;
184
184
  preloadConfig: PreloadConfig;
185
185
  }>;
186
+ type ResourceLoadInitiator = 'loadRemote' | 'preloadRemote';
187
+ type ResourceLoadType = 'manifest' | 'remoteEntry' | 'js' | 'css';
188
+ interface ResourceLoadContext {
189
+ initiator: ResourceLoadInitiator;
190
+ id: string;
191
+ resourceType: ResourceLoadType;
192
+ url?: string;
193
+ }
194
+ type PreloadAssetStatus = 'success' | 'error' | 'timeout' | 'cached';
195
+ interface PreloadAssetResult {
196
+ url: string;
197
+ status: PreloadAssetStatus;
198
+ resourceType: ResourceLoadType;
199
+ initiator: ResourceLoadInitiator;
200
+ id: string;
201
+ error?: unknown;
202
+ }
203
+ interface PreloadRemoteResult {
204
+ remote: Remote;
205
+ remoteInfo: RemoteInfo;
206
+ preloadConfig: PreloadConfig;
207
+ id: string;
208
+ results: PreloadAssetResult[];
209
+ }
186
210
  type EntryAssets = {
187
211
  name: string;
188
212
  url: string;
@@ -226,6 +250,15 @@ declare class RemoteHandler {
226
250
  options: Options;
227
251
  origin: ModuleFederation;
228
252
  }>;
253
+ afterMatchRemote: AsyncHook<[{
254
+ id: string;
255
+ options: Options;
256
+ remote?: Remote;
257
+ expose?: string;
258
+ remoteInfo?: RemoteInfo;
259
+ error?: unknown;
260
+ origin: ModuleFederation;
261
+ }], void>;
229
262
  onLoad: AsyncHook<[{
230
263
  id: string;
231
264
  expose: string;
@@ -236,6 +269,18 @@ declare class RemoteHandler {
236
269
  exposeModule: any;
237
270
  exposeModuleFactory: any;
238
271
  moduleInstance: Module$1;
272
+ }], unknown>;
273
+ afterLoadRemote: AsyncHook<[{
274
+ id: string;
275
+ expose?: string;
276
+ remote?: RemoteInfo;
277
+ options?: {
278
+ loadFactory?: boolean;
279
+ from?: CallFrom;
280
+ };
281
+ error?: unknown;
282
+ recovered?: boolean;
283
+ origin: ModuleFederation;
239
284
  }], void>;
240
285
  handlePreloadModule: SyncHook<[{
241
286
  id: string;
@@ -251,6 +296,8 @@ declare class RemoteHandler {
251
296
  options?: any;
252
297
  from: CallFrom;
253
298
  lifecycle: "beforeRequest" | "beforeLoadShare" | "afterResolve" | "onLoad";
299
+ remote?: RemoteInfo;
300
+ expose?: string;
254
301
  origin: ModuleFederation;
255
302
  }], unknown>;
256
303
  beforePreloadRemote: AsyncHook<[{
@@ -266,16 +313,19 @@ declare class RemoteHandler {
266
313
  remoteSnapshot: ModuleInfo;
267
314
  globalSnapshot: GlobalModuleInfo;
268
315
  }], Promise<PreloadAssets>>;
269
- afterPreloadRemote: AsyncHook<{
316
+ afterPreloadRemote: AsyncHook<[{
270
317
  preloadOps: Array<PreloadRemoteArgs>;
271
318
  options: Options;
272
319
  origin: ModuleFederation;
273
- }, false | void | Promise<false | void>>;
320
+ results: PreloadRemoteResult[];
321
+ error?: unknown;
322
+ }], false | void | Promise<false | void>>;
274
323
  loadEntry: AsyncHook<[{
324
+ origin: ModuleFederation;
275
325
  loaderHook: ModuleFederation["loaderHook"];
276
326
  remoteInfo: RemoteInfo;
277
327
  remoteEntryExports?: RemoteEntryExports;
278
- }], Promise<RemoteEntryExports>>;
328
+ }], void | RemoteEntryExports | Promise<void | RemoteEntryExports>>;
279
329
  }>;
280
330
  constructor(host: ModuleFederation);
281
331
  formatAndRegisterRemote(globalOptions: Options, userOptions: UserOptions): Remote[];
@@ -320,6 +370,25 @@ declare class SharedHandler {
320
370
  origin: ModuleFederation;
321
371
  }>;
322
372
  loadShare: AsyncHook<[ModuleFederation, string, ShareInfos], false | void | Promise<false | void>>;
373
+ afterLoadShare: SyncHook<[{
374
+ pkgName: string;
375
+ shareInfo?: Partial<Shared>;
376
+ selectedShared?: Partial<Shared>;
377
+ shared: Options["shared"];
378
+ shareScopeMap: ShareScopeMap;
379
+ lifecycle: "loadShare" | "loadShareSync";
380
+ origin: ModuleFederation;
381
+ }], void>;
382
+ errorLoadShare: SyncHook<[{
383
+ pkgName: string;
384
+ shareInfo?: Partial<Shared>;
385
+ shared: Options["shared"];
386
+ shareScopeMap: ShareScopeMap;
387
+ lifecycle: "loadShare" | "loadShareSync";
388
+ origin: ModuleFederation;
389
+ error?: unknown;
390
+ recovered?: boolean;
391
+ }], void>;
323
392
  resolveShare: SyncWaterfallHook<{
324
393
  shareScopeMap: ShareScopeMap;
325
394
  scope: string;
@@ -342,6 +411,8 @@ declare class SharedHandler {
342
411
  }>;
343
412
  initTokens: InitTokens;
344
413
  constructor(host: ModuleFederation);
414
+ private emitAfterLoadShare;
415
+ private emitErrorLoadShare;
345
416
  registerShared(globalOptions: Options, userOptions: UserOptions): {
346
417
  newShareInfos: ShareInfos;
347
418
  allShareInfos: {
@@ -421,6 +492,7 @@ declare class SnapshotHandler {
421
492
  beforeLoadRemoteSnapshot: AsyncHook<[{
422
493
  options: Options;
423
494
  moduleInfo: Remote;
495
+ origin: ModuleFederation;
424
496
  }], void>;
425
497
  loadSnapshot: AsyncWaterfallHook<{
426
498
  options: Options;
@@ -451,11 +523,11 @@ declare class SnapshotHandler {
451
523
  loadRemoteSnapshotInfo({
452
524
  moduleInfo,
453
525
  id,
454
- expose
526
+ initiator
455
527
  }: {
456
528
  moduleInfo: Remote;
457
529
  id?: string;
458
- expose?: string;
530
+ initiator?: ResourceLoadInitiator;
459
531
  }): Promise<{
460
532
  remoteSnapshot: ModuleInfo;
461
533
  globalSnapshot: GlobalModuleInfo;
@@ -466,6 +538,7 @@ declare class SnapshotHandler {
466
538
  remoteSnapshot: GlobalModuleInfo[string] | undefined;
467
539
  };
468
540
  private getManifestJson;
541
+ private loadManifestSnapshot;
469
542
  } //#endregion
470
543
  //#endregion
471
544
  //#region ../runtime-core/dist/utils/load.d.ts
@@ -476,6 +549,7 @@ declare function getRemoteEntry(params: {
476
549
  remoteEntryExports?: RemoteEntryExports | undefined;
477
550
  getEntryUrl?: (url: string) => string;
478
551
  _inErrorHandling?: boolean;
552
+ resourceContext?: ResourceLoadContext;
479
553
  }): Promise<RemoteEntryExports | false | void>;
480
554
  //#endregion
481
555
  //#region ../runtime-core/dist/core.d.ts
@@ -538,6 +612,7 @@ declare class ModuleFederation {
538
612
  * (e.g. preloadRemote / loading remoteEntry).
539
613
  */
540
614
  remoteInfo?: RemoteInfo;
615
+ resourceContext?: ResourceLoadContext;
541
616
  }], CreateScriptHookReturn>;
542
617
  createLink: SyncHook<[{
543
618
  url: string;
@@ -548,8 +623,9 @@ declare class ModuleFederation {
548
623
  * (e.g. preloadRemote / loading remoteEntry).
549
624
  */
550
625
  remoteInfo?: RemoteInfo;
551
- }], void | HTMLLinkElement>;
552
- fetch: AsyncHook<[string, RequestInit, (RemoteInfo | undefined)?], false | void | Promise<Response>>;
626
+ resourceContext?: ResourceLoadContext;
627
+ }], CreateLinkHookReturnDom>;
628
+ fetch: AsyncHook<[string, RequestInit, (RemoteInfo | undefined)?, (ResourceLoadContext | undefined)?], false | void | Promise<Response>>;
553
629
  loadEntryError: AsyncHook<[{
554
630
  getRemoteEntry: typeof getRemoteEntry;
555
631
  origin: ModuleFederation;
@@ -558,11 +634,65 @@ declare class ModuleFederation {
558
634
  globalLoading: Record<string, Promise<void | RemoteEntryExports> | undefined>;
559
635
  uniqueKey: string;
560
636
  }], Promise<Promise<RemoteEntryExports | undefined> | undefined>>;
637
+ afterLoadEntry: AsyncHook<[{
638
+ origin: ModuleFederation;
639
+ remoteInfo: RemoteInfo;
640
+ remoteEntryExports?: false | void | RemoteEntryExports | undefined;
641
+ error?: unknown;
642
+ recovered?: boolean;
643
+ }], void>;
644
+ beforeInitRemote: AsyncHook<[{
645
+ id?: string;
646
+ remoteInfo: RemoteInfo;
647
+ remoteSnapshot?: ModuleInfo;
648
+ origin: ModuleFederation;
649
+ }], void>;
650
+ afterInitRemote: AsyncHook<[{
651
+ id?: string;
652
+ remoteInfo: RemoteInfo;
653
+ remoteSnapshot?: ModuleInfo;
654
+ remoteEntryExports?: RemoteEntryExports;
655
+ error?: unknown;
656
+ cached?: boolean;
657
+ origin: ModuleFederation;
658
+ }], void>;
659
+ beforeGetExpose: AsyncHook<[{
660
+ id: string;
661
+ expose: string;
662
+ moduleInfo: RemoteInfo;
663
+ remoteEntryExports: RemoteEntryExports;
664
+ origin: ModuleFederation;
665
+ }], void>;
666
+ afterGetExpose: AsyncHook<[{
667
+ id: string;
668
+ expose: string;
669
+ moduleInfo: RemoteInfo;
670
+ remoteEntryExports: RemoteEntryExports;
671
+ moduleFactory?: RemoteModuleFactory;
672
+ error?: unknown;
673
+ origin: ModuleFederation;
674
+ }], void>;
675
+ beforeExecuteFactory: AsyncHook<[{
676
+ id: string;
677
+ expose: string;
678
+ moduleInfo: RemoteInfo;
679
+ loadFactory: boolean;
680
+ origin: ModuleFederation;
681
+ }], void>;
682
+ afterExecuteFactory: AsyncHook<[{
683
+ id: string;
684
+ expose: string;
685
+ moduleInfo: RemoteInfo;
686
+ loadFactory: boolean;
687
+ exposeModule?: unknown;
688
+ error?: unknown;
689
+ origin: ModuleFederation;
690
+ }], void>;
561
691
  getModuleFactory: AsyncHook<[{
562
692
  remoteEntryExports: RemoteEntryExports;
563
693
  expose: string;
564
694
  moduleInfo: RemoteInfo;
565
- }], Promise<(() => Promise<Module$1>) | undefined>>;
695
+ }], RemoteModuleFactory | Promise<RemoteModuleFactory | undefined> | undefined>;
566
696
  }>;
567
697
  bridgeHook: PluginSystem<{
568
698
  beforeBridgeRender: SyncHook<[Record<string, any>], void | Record<string, any>>;
@@ -607,6 +737,7 @@ declare class ModuleFederation {
607
737
  //#region ../runtime-core/dist/module/index.d.ts
608
738
  //#region src/module/index.d.ts
609
739
  type ModuleOptions = ConstructorParameters<typeof Module$1>[0];
740
+ type RemoteModuleFactory = () => unknown | Promise<unknown>;
610
741
  declare class Module$1 {
611
742
  remoteInfo: RemoteInfo;
612
743
  inited: boolean;
@@ -622,11 +753,11 @@ declare class Module$1 {
622
753
  remoteInfo: RemoteInfo;
623
754
  host: ModuleFederation;
624
755
  });
625
- getEntry(): Promise<RemoteEntryExports>;
626
- init(id?: string, remoteSnapshot?: ModuleInfo, rawInitScope?: InitScope): Promise<RemoteEntryExports>;
756
+ getEntry(expose?: string): Promise<RemoteEntryExports>;
757
+ init(id?: string, remoteSnapshot?: ModuleInfo, rawInitScope?: InitScope, expose?: string): Promise<RemoteEntryExports>;
627
758
  get(id: string, expose: string, options?: {
628
759
  loadFactory?: boolean;
629
- }, remoteSnapshot?: ModuleInfo): Promise<any>;
760
+ }, remoteSnapshot?: ModuleInfo): Promise<unknown>;
630
761
  private wraperFactory;
631
762
  } //#endregion
632
763
  //#endregion
@@ -1,5 +1,6 @@
1
1
  import { a as MF_SERVER_IDENTIFIER, c as WEB_SOCKET_CONNECT_MAGIC_ID, i as DEFAULT_WEB_SOCKET_PORT, l as Message, n as ActionKind, o as UpdateMode } from "./Action-DNNg2YDh.mjs";
2
2
  import * as fs$1 from "fs";
3
+ import { parse } from "url";
3
4
  import * as path$1 from "path";
4
5
  import { SEPARATOR, createLogger } from "@module-federation/sdk";
5
6
  import net from "net";
@@ -7,7 +8,6 @@ import os from "os";
7
8
  import WebSocket from "isomorphic-ws";
8
9
  import { createServer } from "http";
9
10
  import schedule from "node-schedule";
10
- import { parse } from "url";
11
11
 
12
12
  //#region src/server/message/API/API.ts
13
13
  let APIKind = /* @__PURE__ */ function(APIKind) {
@@ -1,8 +1,8 @@
1
- import { a as cloneDeepOptions, n as RpcGMCallTypes, o as getDTSManagerConstructor, s as isDebugMode, t as exposeRpc, x as __exportAll } from "./expose-rpc-B-zm7DmJ.mjs";
1
+ import { a as cloneDeepOptions, n as RpcGMCallTypes, o as getDTSManagerConstructor, s as isDebugMode, t as exposeRpc, x as __exportAll } from "./expose-rpc-ZWQxpg0y.mjs";
2
+ import { fileURLToPath } from "url";
2
3
  import path from "path";
3
4
  import { randomUUID } from "crypto";
4
5
  import * as child_process from "child_process";
5
- import { fileURLToPath } from "url";
6
6
  import * as process$2 from "process";
7
7
 
8
8
  //#region src/core/rpc/rpc-error.ts
package/dist/esm/core.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { _ as retrieveMfTypesPath, c as isTSProject, d as DTSManager, f as HOST_API_TYPES_FILE_NAME, g as retrieveTypesZipPath, h as retrieveHostConfig, i as retrieveRemoteConfig, l as retrieveTypesAssetsInfo, m as REMOTE_API_TYPES_FILE_NAME, o as getDTSManagerConstructor, p as REMOTE_ALIAS_IDENTIFIER, r as generateTypes, u as validateOptions, v as retrieveOriginalOutDir } from "./expose-rpc-B-zm7DmJ.mjs";
2
- import "./Broker-z82OgzMe.mjs";
3
- import { i as rpc_exports, n as generateTypesInChildProcess, r as DtsWorker, t as consumeTypes } from "./consumeTypes-DYgYpZMQ.mjs";
1
+ import { _ as retrieveMfTypesPath, c as isTSProject, d as DTSManager, f as HOST_API_TYPES_FILE_NAME, g as retrieveTypesZipPath, h as retrieveHostConfig, i as retrieveRemoteConfig, l as retrieveTypesAssetsInfo, m as REMOTE_API_TYPES_FILE_NAME, o as getDTSManagerConstructor, p as REMOTE_ALIAS_IDENTIFIER, r as generateTypes, u as validateOptions, v as retrieveOriginalOutDir } from "./expose-rpc-ZWQxpg0y.mjs";
2
+ import "./Broker-Cmbh_XVO.mjs";
3
+ import { i as rpc_exports, n as generateTypesInChildProcess, r as DtsWorker, t as consumeTypes } from "./consumeTypes-COIltElB.mjs";
4
4
 
5
5
  export { DTSManager, DtsWorker, HOST_API_TYPES_FILE_NAME, REMOTE_ALIAS_IDENTIFIER, REMOTE_API_TYPES_FILE_NAME, consumeTypes, generateTypes, generateTypesInChildProcess, getDTSManagerConstructor, isTSProject, retrieveHostConfig, retrieveMfTypesPath, retrieveOriginalOutDir, retrieveRemoteConfig, retrieveTypesAssetsInfo, retrieveTypesZipPath, rpc_exports as rpc, validateOptions };
@@ -1,7 +1,8 @@
1
1
  import { a as MF_SERVER_IDENTIFIER, n as ActionKind, o as UpdateMode, r as DEFAULT_TAR_NAME, t as Action } from "./Action-DNNg2YDh.mjs";
2
- import { a as getIdentifier, c as logger$1, i as getFreePort, l as LogKind, n as UpdateKind, o as getIPV4, r as fib, s as fileLog, t as Broker, u as APIKind } from "./Broker-z82OgzMe.mjs";
2
+ import { a as getIdentifier, c as logger$1, i as getFreePort, l as LogKind, n as UpdateKind, o as getIPV4, r as fib, s as fileLog, t as Broker, u as APIKind } from "./Broker-Cmbh_XVO.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import fs, { existsSync, mkdirSync, writeFileSync } from "fs";
5
+ import { fileURLToPath } from "url";
5
6
  import path, { dirname, extname, isAbsolute, join, normalize, relative, resolve, sep } from "path";
6
7
  import { cp, mkdir, readFile, readdir, rm, stat, writeFile } from "fs/promises";
7
8
  import { utils } from "@module-federation/managers";
@@ -87,6 +88,8 @@ var UpdatePublisherAction = class extends Action {
87
88
 
88
89
  //#endregion
89
90
  //#region src/server/broker/createBroker.ts
91
+ const __filename = fileURLToPath(import.meta.url);
92
+ const __dirname = path.dirname(__filename);
90
93
  function createBroker() {
91
94
  const sub = fork(path.resolve(__dirname, "./start-broker.js"), [], {
92
95
  detached: true,
@@ -667,7 +670,7 @@ const defaultOptions$1 = {
667
670
  remoteTypeUrls: {},
668
671
  timeout: 6e4,
669
672
  typesOnBuild: false,
670
- family: 4
673
+ family: 0
671
674
  };
672
675
  const buildZipUrl = (hostOptions, url) => {
673
676
  const remoteUrl = new URL(url, "file:");
@@ -688,12 +691,14 @@ const retrieveRemoteInfo = (options) => {
688
691
  let zipUrl = "";
689
692
  let apiTypeUrl = "";
690
693
  const name = parsedInfo.name || remoteAlias;
691
- if (typeof remoteTypeUrls === "object" && remoteTypeUrls[name]) {
692
- zipUrl = remoteTypeUrls[name].zip;
693
- apiTypeUrl = remoteTypeUrls[name].api;
694
+ const remoteTypeUrl = typeof remoteTypeUrls === "object" && remoteTypeUrls[name];
695
+ if (remoteTypeUrl) {
696
+ zipUrl = remoteTypeUrl.zip;
697
+ apiTypeUrl = remoteTypeUrl.api;
694
698
  }
695
- if (!zipUrl && url) zipUrl = buildZipUrl(hostOptions, url);
696
- if (!apiTypeUrl && zipUrl) apiTypeUrl = buildApiTypeUrl(zipUrl);
699
+ const shouldResolveTypeUrlsByConvention = Boolean(url && !url.includes(MANIFEST_EXT));
700
+ if (!zipUrl && shouldResolveTypeUrlsByConvention) zipUrl = buildZipUrl(hostOptions, url);
701
+ if (!apiTypeUrl && zipUrl && (remoteTypeUrl || shouldResolveTypeUrlsByConvention)) apiTypeUrl = buildApiTypeUrl(zipUrl);
697
702
  return {
698
703
  name,
699
704
  url,
@@ -879,13 +884,14 @@ var DTSManager = class {
879
884
  else publicPath = getPublicPath();
880
885
  }
881
886
  if (publicPath === "auto") publicPath = inferAutoPublicPath(remoteInfo.url);
882
- remoteInfo.zipUrl = new URL(path.join(addProtocol(publicPath), manifestJson.metaData.types.zip)).href;
887
+ const normalizedPublicPath = addProtocol(publicPath).endsWith("/") ? addProtocol(publicPath) : `${addProtocol(publicPath)}/`;
888
+ remoteInfo.zipUrl = new URL(manifestJson.metaData.types.zip, normalizedPublicPath).href;
883
889
  if (!manifestJson.metaData.types.api) {
884
890
  console.warn(`Can not get ${remoteInfo.name}'s api types url!`);
885
891
  remoteInfo.apiTypeUrl = "";
886
892
  return remoteInfo;
887
893
  }
888
- remoteInfo.apiTypeUrl = new URL(path.join(addProtocol(publicPath), manifestJson.metaData.types.api)).href;
894
+ remoteInfo.apiTypeUrl = new URL(manifestJson.metaData.types.api, normalizedPublicPath).href;
889
895
  return remoteInfo;
890
896
  } catch (_err) {
891
897
  fileLog(`fetch manifest failed, ${_err}, ${remoteInfo.name} will be ignored`, "requestRemoteManifest", "error");
@@ -1,7 +1,7 @@
1
- import { _ as retrieveMfTypesPath, b as ModuleFederationDevServer, g as retrieveTypesZipPath, h as retrieveHostConfig, i as retrieveRemoteConfig, n as RpcGMCallTypes, o as getDTSManagerConstructor, t as exposeRpc, y as createHttpServer } from "./expose-rpc-B-zm7DmJ.mjs";
1
+ import { _ as retrieveMfTypesPath, b as ModuleFederationDevServer, g as retrieveTypesZipPath, h as retrieveHostConfig, i as retrieveRemoteConfig, n as RpcGMCallTypes, o as getDTSManagerConstructor, t as exposeRpc, y as createHttpServer } from "./expose-rpc-ZWQxpg0y.mjs";
2
2
  import { o as UpdateMode, r as DEFAULT_TAR_NAME } from "./Action-DNNg2YDh.mjs";
3
- import { n as UpdateKind, o as getIPV4, s as fileLog } from "./Broker-z82OgzMe.mjs";
4
- import "./consumeTypes-DYgYpZMQ.mjs";
3
+ import { n as UpdateKind, o as getIPV4, s as fileLog } from "./Broker-Cmbh_XVO.mjs";
4
+ import "./consumeTypes-COIltElB.mjs";
5
5
  import "./core.mjs";
6
6
  import { t as getIpFromEntry } from "./utils-CkPvDGOy.mjs";
7
7
  import { decodeName } from "@module-federation/sdk";
@@ -1,5 +1,5 @@
1
- import { n as RpcGMCallTypes, r as generateTypes, t as exposeRpc } from "./expose-rpc-B-zm7DmJ.mjs";
2
- import "./Broker-z82OgzMe.mjs";
1
+ import { n as RpcGMCallTypes, r as generateTypes, t as exposeRpc } from "./expose-rpc-ZWQxpg0y.mjs";
2
+ import "./Broker-Cmbh_XVO.mjs";
3
3
 
4
4
  //#region src/core/lib/forkGenerateDts.ts
5
5
  async function forkGenerateDts(options) {
@@ -1,20 +1,23 @@
1
- import { a as cloneDeepOptions, c as isTSProject, l as retrieveTypesAssetsInfo, n as RpcGMCallTypes, r as generateTypes, u as validateOptions } from "./expose-rpc-B-zm7DmJ.mjs";
1
+ import { a as cloneDeepOptions, c as isTSProject, l as retrieveTypesAssetsInfo, n as RpcGMCallTypes, r as generateTypes, u as validateOptions } from "./expose-rpc-ZWQxpg0y.mjs";
2
2
  import { s as WEB_CLIENT_OPTIONS_IDENTIFIER } from "./Action-DNNg2YDh.mjs";
3
- import { c as logger$1, o as getIPV4 } from "./Broker-z82OgzMe.mjs";
4
- import { a as createRpcWorker, n as generateTypesInChildProcess, t as consumeTypes } from "./consumeTypes-DYgYpZMQ.mjs";
3
+ import { c as logger$1, o as getIPV4 } from "./Broker-Cmbh_XVO.mjs";
4
+ import { a as createRpcWorker, n as generateTypesInChildProcess, t as consumeTypes } from "./consumeTypes-COIltElB.mjs";
5
5
  import "./core.mjs";
6
6
  import fs from "fs";
7
+ import { fileURLToPath } from "url";
7
8
  import * as path$1 from "path";
8
9
  import path from "path";
9
10
  import { rm } from "fs/promises";
10
11
  import { TEMP_DIR, infrastructureLogger, logger, normalizeOptions } from "@module-federation/sdk";
11
12
 
12
13
  //#region src/dev-worker/DevWorker.ts
14
+ const __filename$1 = fileURLToPath(import.meta.url);
15
+ const __dirname$1 = path.dirname(__filename$1);
13
16
  var DevWorker = class {
14
17
  constructor(options) {
15
18
  this._options = cloneDeepOptions(options);
16
19
  this.removeUnSerializationOptions();
17
- this._rpcWorker = createRpcWorker(path.resolve(__dirname, "./fork-dev-worker.js"), {}, void 0, false);
20
+ this._rpcWorker = createRpcWorker(path.resolve(__dirname$1, "./fork-dev-worker.js"), {}, void 0, false);
18
21
  this._res = this._rpcWorker.connect(this._options);
19
22
  }
20
23
  removeUnSerializationOptions() {
@@ -71,6 +74,8 @@ function getCompilerOutputDir(compiler) {
71
74
 
72
75
  //#endregion
73
76
  //#region src/plugins/DevPlugin.ts
77
+ const __filename = fileURLToPath(import.meta.url);
78
+ const __dirname = path.dirname(__filename);
74
79
  var PROCESS_EXIT_CODE = /* @__PURE__ */ function(PROCESS_EXIT_CODE) {
75
80
  PROCESS_EXIT_CODE[PROCESS_EXIT_CODE["SUCCESS"] = 0] = "SUCCESS";
76
81
  PROCESS_EXIT_CODE[PROCESS_EXIT_CODE["FAILURE"] = 1] = "FAILURE";
@@ -1,4 +1,4 @@
1
- import { s as fileLog, t as Broker } from "./Broker-z82OgzMe.mjs";
1
+ import { s as fileLog, t as Broker } from "./Broker-Cmbh_XVO.mjs";
2
2
 
3
3
  //#region src/server/broker/startBroker.ts
4
4
  let broker;
@@ -1,7 +1,8 @@
1
1
  const require_Action = require('./Action-CzhPMw2i.js');
2
- const require_Broker = require('./Broker-DRFgFvXI.js');
2
+ const require_Broker = require('./Broker-CaenCqdn.js');
3
3
  let fs = require("fs");
4
4
  fs = require_Action.__toESM(fs);
5
+ let url = require("url");
5
6
  let path = require("path");
6
7
  path = require_Action.__toESM(path);
7
8
  let fs_promises = require("fs/promises");
@@ -78,8 +79,10 @@ var UpdatePublisherAction = class extends require_Action.Action {
78
79
 
79
80
  //#endregion
80
81
  //#region src/server/broker/createBroker.ts
82
+ const __filename$1 = (0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
83
+ const __dirname$1 = path.default.dirname(__filename$1);
81
84
  function createBroker() {
82
- const sub = (0, child_process.fork)(path.default.resolve(__dirname, "./start-broker.js"), [], {
85
+ const sub = (0, child_process.fork)(path.default.resolve(__dirname$1, "./start-broker.js"), [], {
83
86
  detached: true,
84
87
  stdio: "ignore",
85
88
  env: process.env
@@ -658,7 +661,7 @@ const defaultOptions$1 = {
658
661
  remoteTypeUrls: {},
659
662
  timeout: 6e4,
660
663
  typesOnBuild: false,
661
- family: 4
664
+ family: 0
662
665
  };
663
666
  const buildZipUrl = (hostOptions, url) => {
664
667
  const remoteUrl = new URL(url, "file:");
@@ -679,12 +682,14 @@ const retrieveRemoteInfo = (options) => {
679
682
  let zipUrl = "";
680
683
  let apiTypeUrl = "";
681
684
  const name = parsedInfo.name || remoteAlias;
682
- if (typeof remoteTypeUrls === "object" && remoteTypeUrls[name]) {
683
- zipUrl = remoteTypeUrls[name].zip;
684
- apiTypeUrl = remoteTypeUrls[name].api;
685
+ const remoteTypeUrl = typeof remoteTypeUrls === "object" && remoteTypeUrls[name];
686
+ if (remoteTypeUrl) {
687
+ zipUrl = remoteTypeUrl.zip;
688
+ apiTypeUrl = remoteTypeUrl.api;
685
689
  }
686
- if (!zipUrl && url) zipUrl = buildZipUrl(hostOptions, url);
687
- if (!apiTypeUrl && zipUrl) apiTypeUrl = buildApiTypeUrl(zipUrl);
690
+ const shouldResolveTypeUrlsByConvention = Boolean(url && !url.includes(_module_federation_sdk.MANIFEST_EXT));
691
+ if (!zipUrl && shouldResolveTypeUrlsByConvention) zipUrl = buildZipUrl(hostOptions, url);
692
+ if (!apiTypeUrl && zipUrl && (remoteTypeUrl || shouldResolveTypeUrlsByConvention)) apiTypeUrl = buildApiTypeUrl(zipUrl);
688
693
  return {
689
694
  name,
690
695
  url,
@@ -870,13 +875,14 @@ var DTSManager = class {
870
875
  else publicPath = getPublicPath();
871
876
  }
872
877
  if (publicPath === "auto") publicPath = (0, _module_federation_sdk.inferAutoPublicPath)(remoteInfo.url);
873
- remoteInfo.zipUrl = new URL(path.default.join(addProtocol(publicPath), manifestJson.metaData.types.zip)).href;
878
+ const normalizedPublicPath = addProtocol(publicPath).endsWith("/") ? addProtocol(publicPath) : `${addProtocol(publicPath)}/`;
879
+ remoteInfo.zipUrl = new URL(manifestJson.metaData.types.zip, normalizedPublicPath).href;
874
880
  if (!manifestJson.metaData.types.api) {
875
881
  console.warn(`Can not get ${remoteInfo.name}'s api types url!`);
876
882
  remoteInfo.apiTypeUrl = "";
877
883
  return remoteInfo;
878
884
  }
879
- remoteInfo.apiTypeUrl = new URL(path.default.join(addProtocol(publicPath), manifestJson.metaData.types.api)).href;
885
+ remoteInfo.apiTypeUrl = new URL(manifestJson.metaData.types.api, normalizedPublicPath).href;
880
886
  return remoteInfo;
881
887
  } catch (_err) {
882
888
  require_Broker.fileLog(`fetch manifest failed, ${_err}, ${remoteInfo.name} will be ignored`, "requestRemoteManifest", "error");
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_Action = require('./Action-CzhPMw2i.js');
3
- const require_Broker = require('./Broker-DRFgFvXI.js');
4
- const require_expose_rpc = require('./expose-rpc-CQq6zYK-.js');
5
- require('./consumeTypes-DxGMNavh.js');
3
+ const require_Broker = require('./Broker-CaenCqdn.js');
4
+ const require_expose_rpc = require('./expose-rpc-XLxmAXIW.js');
5
+ require('./consumeTypes-FbF0o6AJ.js');
6
6
  require('./core.js');
7
7
  const require_utils = require('./utils-7KqCZHbb.js');
8
8
  let _module_federation_sdk = require("@module-federation/sdk");
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- require('./Broker-DRFgFvXI.js');
3
- const require_expose_rpc = require('./expose-rpc-CQq6zYK-.js');
2
+ require('./Broker-CaenCqdn.js');
3
+ const require_expose_rpc = require('./expose-rpc-XLxmAXIW.js');
4
4
 
5
5
  //#region src/core/lib/forkGenerateDts.ts
6
6
  async function forkGenerateDts(options) {
@@ -56,7 +56,7 @@
56
56
  }({});
57
57
 
58
58
  //#endregion
59
- //#region ../../node_modules/.pnpm/isomorphic-ws@5.0.0_ws@8.18.0/node_modules/isomorphic-ws/browser.js
59
+ //#region ../../node_modules/.pnpm/isomorphic-ws@5.0.0_ws@8.21.0/node_modules/isomorphic-ws/browser.js
60
60
  var ws = null;
61
61
  if (typeof WebSocket !== "undefined") ws = WebSocket;
62
62
  else if (typeof MozWebSocket !== "undefined") ws = MozWebSocket;
package/dist/index.d.ts CHANGED
@@ -35,7 +35,7 @@ declare const normalizeConsumeTypesOptions: ({
35
35
  runtimePkgs?: string[];
36
36
  remoteTypeUrls?: (() => Promise<moduleFederationPlugin.RemoteTypeUrls>) | moduleFederationPlugin.RemoteTypeUrls;
37
37
  timeout?: number;
38
- family?: 4 | 6;
38
+ family?: 0 | 4 | 6;
39
39
  typesOnBuild?: boolean;
40
40
  implementation: string;
41
41
  context: string;
package/dist/index.js CHANGED
@@ -1,22 +1,25 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_Action = require('./Action-CzhPMw2i.js');
3
- const require_Broker = require('./Broker-DRFgFvXI.js');
4
- const require_expose_rpc = require('./expose-rpc-CQq6zYK-.js');
5
- const require_consumeTypes = require('./consumeTypes-DxGMNavh.js');
3
+ const require_Broker = require('./Broker-CaenCqdn.js');
4
+ const require_expose_rpc = require('./expose-rpc-XLxmAXIW.js');
5
+ const require_consumeTypes = require('./consumeTypes-FbF0o6AJ.js');
6
6
  require('./core.js');
7
7
  let fs = require("fs");
8
8
  fs = require_Action.__toESM(fs);
9
+ let url = require("url");
9
10
  let path = require("path");
10
11
  path = require_Action.__toESM(path);
11
12
  let fs_promises = require("fs/promises");
12
13
  let _module_federation_sdk = require("@module-federation/sdk");
13
14
 
14
15
  //#region src/dev-worker/DevWorker.ts
16
+ const __filename$2 = (0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
17
+ const __dirname$2 = path.default.dirname(__filename$2);
15
18
  var DevWorker = class {
16
19
  constructor(options) {
17
20
  this._options = require_expose_rpc.cloneDeepOptions(options);
18
21
  this.removeUnSerializationOptions();
19
- this._rpcWorker = require_consumeTypes.createRpcWorker(path.default.resolve(__dirname, "./fork-dev-worker.js"), {}, void 0, false);
22
+ this._rpcWorker = require_consumeTypes.createRpcWorker(path.default.resolve(__dirname$2, "./fork-dev-worker.js"), {}, void 0, false);
20
23
  this._res = this._rpcWorker.connect(this._options);
21
24
  }
22
25
  removeUnSerializationOptions() {
@@ -73,6 +76,8 @@ function getCompilerOutputDir(compiler) {
73
76
 
74
77
  //#endregion
75
78
  //#region src/plugins/DevPlugin.ts
79
+ const __filename$1 = (0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
80
+ const __dirname$1 = path.default.dirname(__filename$1);
76
81
  var PROCESS_EXIT_CODE = /* @__PURE__ */ function(PROCESS_EXIT_CODE) {
77
82
  PROCESS_EXIT_CODE[PROCESS_EXIT_CODE["SUCCESS"] = 0] = "SUCCESS";
78
83
  PROCESS_EXIT_CODE[PROCESS_EXIT_CODE["FAILURE"] = 1] = "FAILURE";
@@ -94,7 +99,7 @@ var DevPlugin = class DevPlugin {
94
99
  }
95
100
  static ensureLiveReloadEntry(options, filePath) {
96
101
  ensureTempDir(filePath);
97
- const liveReloadEntryWithOptions = fs.default.readFileSync(path.default.join(__dirname, "./iife/launch-web-client.iife.js")).toString("utf-8").replace(require_Action.WEB_CLIENT_OPTIONS_IDENTIFIER, JSON.stringify(options));
102
+ const liveReloadEntryWithOptions = fs.default.readFileSync(path.default.join(__dirname$1, "./iife/launch-web-client.iife.js")).toString("utf-8").replace(require_Action.WEB_CLIENT_OPTIONS_IDENTIFIER, JSON.stringify(options));
98
103
  fs.default.writeFileSync(filePath, liveReloadEntryWithOptions);
99
104
  }
100
105
  _stopWhenSIGTERMOrSIGINT() {
@@ -139,7 +144,7 @@ var DevPlugin = class DevPlugin {
139
144
  if (!name) throw new Error("name is required if you want to enable dev server!");
140
145
  if (!normalizedDev.disableDynamicRemoteTypeHints) {
141
146
  if (!this._options.runtimePlugins) this._options.runtimePlugins = [];
142
- this._options.runtimePlugins.push(path.default.resolve(__dirname, "dynamic-remote-type-hints-plugin.js"));
147
+ this._options.runtimePlugins.push(path.default.resolve(__dirname$1, "dynamic-remote-type-hints-plugin.js"));
143
148
  }
144
149
  if (!normalizedDev.disableLiveReload) {
145
150
  const TEMP_DIR = path.default.join(`${process.cwd()}/node_modules`, _module_federation_sdk.TEMP_DIR);
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_Broker = require('./Broker-DRFgFvXI.js');
2
+ const require_Broker = require('./Broker-CaenCqdn.js');
3
3
 
4
4
  //#region src/server/broker/startBroker.ts
5
5
  let broker;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/dts-plugin",
3
- "version": "2.4.0",
3
+ "version": "2.5.1",
4
4
  "author": "hanric <hanric.zhang@gmail.com>",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -70,11 +70,11 @@
70
70
  "isomorphic-ws": "5.0.0",
71
71
  "undici": "7.24.7",
72
72
  "node-schedule": "2.1.1",
73
- "ws": "8.18.0",
74
- "@module-federation/error-codes": "2.4.0",
75
- "@module-federation/sdk": "2.4.0",
76
- "@module-federation/managers": "2.4.0",
77
- "@module-federation/third-party-dts-extractor": "2.4.0"
73
+ "ws": "8.21.0",
74
+ "@module-federation/error-codes": "2.5.1",
75
+ "@module-federation/managers": "2.5.1",
76
+ "@module-federation/sdk": "2.5.1",
77
+ "@module-federation/third-party-dts-extractor": "2.5.1"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@types/node-schedule": "2.1.7",
@@ -86,7 +86,7 @@
86
86
  "directory-tree": "3.5.2",
87
87
  "vitest": "1.6.0",
88
88
  "webpack": "^5.104.1",
89
- "@module-federation/runtime": "2.4.0"
89
+ "@module-federation/runtime": "2.5.1"
90
90
  },
91
91
  "peerDependencies": {
92
92
  "typescript": "^4.9.0 || ^5.0.0",