@module-federation/dts-plugin 2.2.3 → 2.3.0

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,11 +1,13 @@
1
1
  const require_Action = require('./Action-CzhPMw2i.js');
2
+ let path = require("path");
3
+ path = require_Action.__toESM(path);
4
+ let fs = require("fs");
5
+ fs = require_Action.__toESM(fs);
2
6
  let http = require("http");
3
7
  let _module_federation_sdk = require("@module-federation/sdk");
4
8
  let net = require("net");
5
9
  net = require_Action.__toESM(net);
6
10
  require("chalk");
7
- let log4js = require("log4js");
8
- log4js = require_Action.__toESM(log4js);
9
11
  let os = require("os");
10
12
  os = require_Action.__toESM(os);
11
13
  let isomorphic_ws = require("isomorphic-ws");
@@ -98,31 +100,13 @@ var BrokerExitLog = class extends Log {
98
100
  const logger = (0, _module_federation_sdk.createLogger)(`[ ${require_Action.MF_SERVER_IDENTIFIER} ]`);
99
101
  function fileLog(msg, module, level) {
100
102
  if (!process?.env?.["FEDERATION_DEBUG"]) return;
101
- log4js.configure({
102
- appenders: {
103
- [module]: {
104
- type: "file",
105
- filename: ".mf/typesGenerate.log"
106
- },
107
- default: {
108
- type: "file",
109
- filename: ".mf/typesGenerate.log"
110
- }
111
- },
112
- categories: {
113
- [module]: {
114
- appenders: [module],
115
- level: "error"
116
- },
117
- default: {
118
- appenders: ["default"],
119
- level: "trace"
120
- }
121
- }
122
- });
123
- const logger4 = log4js.getLogger(module);
124
- logger4.level = "debug";
125
- logger4[level]?.(msg);
103
+ try {
104
+ const logDir = ".mf";
105
+ const logFile = path.join(logDir, "typesGenerate.log");
106
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
107
+ if (!fs.existsSync(logDir)) fs.mkdirSync(logDir, { recursive: true });
108
+ fs.appendFileSync(logFile, `[${timestamp}] [${level.toUpperCase()}] ${module} - ${msg}\n`);
109
+ } catch {}
126
110
  }
127
111
  function error(error, action, from) {
128
112
  const err = error instanceof Error ? error : /* @__PURE__ */ new Error(`${action} error`);
package/dist/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # @module-federation/dts-plugin
2
2
 
3
+ ## 2.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - eb26065: feat(dts-plugin): add `dts.generateTypes.afterGenerate` callback
8
+
9
+ Allows users to hook into the type generation lifecycle from
10
+ `dts.generateTypes`. The callback runs after each successful type generation in
11
+ both dev and prod modes, making it possible to do follow-up work with the
12
+ generated files.
13
+
14
+ ```ts
15
+ new ModuleFederationPlugin({
16
+ dts: {
17
+ generateTypes: {
18
+ afterGenerate: async ({ zipTypesPath, apiTypesPath }) => {
19
+ await analyzeTypesAndGenerateJson({
20
+ zipTypesPath,
21
+ apiTypesPath,
22
+ });
23
+ },
24
+ },
25
+ },
26
+ });
27
+ ```
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies [eb26065]
32
+ - Updated dependencies [f1d79b2]
33
+ - Updated dependencies [8f2ec9b]
34
+ - @module-federation/sdk@2.3.0
35
+ - @module-federation/error-codes@2.3.0
36
+ - @module-federation/managers@2.3.0
37
+ - @module-federation/third-party-dts-extractor@2.3.0
38
+
3
39
  ## 2.2.3
4
40
 
5
41
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  const require_Action = require('./Action-CzhPMw2i.js');
2
- const require_expose_rpc = require('./expose-rpc-BAS_80E1.js');
2
+ const require_expose_rpc = require('./expose-rpc-xfJEPIyY.js');
3
3
  let path = require("path");
4
4
  path = require_Action.__toESM(path);
5
5
  let crypto = require("crypto");
package/dist/core.js CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- require('./Broker-DRlzScTT.js');
3
- const require_expose_rpc = require('./expose-rpc-BAS_80E1.js');
4
- const require_consumeTypes = require('./consumeTypes-DHKw9PGQ.js');
2
+ require('./Broker-BGm-heAJ.js');
3
+ const require_expose_rpc = require('./expose-rpc-xfJEPIyY.js');
4
+ const require_consumeTypes = require('./consumeTypes-ClKC4akt.js');
5
5
 
6
6
  exports.DTSManager = require_expose_rpc.DTSManager;
7
7
  exports.DtsWorker = require_consumeTypes.DtsWorker;
@@ -1,9 +1,10 @@
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
+ import * as path$1 from "path";
3
+ import * as fs$1 from "fs";
2
4
  import { createServer } from "http";
3
5
  import { SEPARATOR, createLogger } from "@module-federation/sdk";
4
6
  import net from "net";
5
7
  import "chalk";
6
- import * as log4js from "log4js";
7
8
  import os from "os";
8
9
  import WebSocket from "isomorphic-ws";
9
10
  import schedule from "node-schedule";
@@ -93,31 +94,13 @@ var BrokerExitLog = class extends Log {
93
94
  const logger$1 = createLogger(`[ ${MF_SERVER_IDENTIFIER} ]`);
94
95
  function fileLog(msg, module, level) {
95
96
  if (!process?.env?.["FEDERATION_DEBUG"]) return;
96
- log4js.configure({
97
- appenders: {
98
- [module]: {
99
- type: "file",
100
- filename: ".mf/typesGenerate.log"
101
- },
102
- default: {
103
- type: "file",
104
- filename: ".mf/typesGenerate.log"
105
- }
106
- },
107
- categories: {
108
- [module]: {
109
- appenders: [module],
110
- level: "error"
111
- },
112
- default: {
113
- appenders: ["default"],
114
- level: "trace"
115
- }
116
- }
117
- });
118
- const logger4 = log4js.getLogger(module);
119
- logger4.level = "debug";
120
- logger4[level]?.(msg);
97
+ try {
98
+ const logDir = ".mf";
99
+ const logFile = path$1.join(logDir, "typesGenerate.log");
100
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
101
+ if (!fs$1.existsSync(logDir)) fs$1.mkdirSync(logDir, { recursive: true });
102
+ fs$1.appendFileSync(logFile, `[${timestamp}] [${level.toUpperCase()}] ${module} - ${msg}\n`);
103
+ } catch {}
121
104
  }
122
105
  function error(error, action, from) {
123
106
  const err = error instanceof Error ? error : /* @__PURE__ */ new Error(`${action} error`);
@@ -1,4 +1,4 @@
1
- import { a as cloneDeepOptions, n as RpcGMCallTypes, o as getDTSManagerConstructor, s as isDebugMode, t as exposeRpc, x as __exportAll } from "./expose-rpc-CyOKS7gM.mjs";
1
+ import { a as cloneDeepOptions, n as RpcGMCallTypes, o as getDTSManagerConstructor, s as isDebugMode, t as exposeRpc, x as __exportAll } from "./expose-rpc-Pg59hZO8.mjs";
2
2
  import path from "path";
3
3
  import { randomUUID } from "crypto";
4
4
  import * as child_process from "child_process";
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-CyOKS7gM.mjs";
2
- import "./Broker-BU4gToNr.mjs";
3
- import { i as rpc_exports, n as generateTypesInChildProcess, r as DtsWorker, t as consumeTypes } from "./consumeTypes-CirXBJjN.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-Pg59hZO8.mjs";
2
+ import "./Broker-CtU3X_nw.mjs";
3
+ import { i as rpc_exports, n as generateTypesInChildProcess, r as DtsWorker, t as consumeTypes } from "./consumeTypes-DnucwjbD.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,5 +1,5 @@
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-BU4gToNr.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-CtU3X_nw.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import fse from "fs-extra";
5
5
  import path, { dirname, extname, isAbsolute, join, normalize, relative, resolve, sep } from "path";
@@ -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-CyOKS7gM.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-Pg59hZO8.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-BU4gToNr.mjs";
4
- import "./consumeTypes-CirXBJjN.mjs";
3
+ import { n as UpdateKind, o as getIPV4, s as fileLog } from "./Broker-CtU3X_nw.mjs";
4
+ import "./consumeTypes-DnucwjbD.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-CyOKS7gM.mjs";
2
- import "./Broker-BU4gToNr.mjs";
1
+ import { n as RpcGMCallTypes, r as generateTypes, t as exposeRpc } from "./expose-rpc-Pg59hZO8.mjs";
2
+ import "./Broker-CtU3X_nw.mjs";
3
3
 
4
4
  //#region src/core/lib/forkGenerateDts.ts
5
5
  async function forkGenerateDts(options) {
@@ -1,7 +1,7 @@
1
- import { a as cloneDeepOptions, c as isTSProject, l as retrieveTypesAssetsInfo, n as RpcGMCallTypes, r as generateTypes, u as validateOptions } from "./expose-rpc-CyOKS7gM.mjs";
1
+ import { a as cloneDeepOptions, c as isTSProject, l as retrieveTypesAssetsInfo, n as RpcGMCallTypes, r as generateTypes, u as validateOptions } from "./expose-rpc-Pg59hZO8.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-BU4gToNr.mjs";
4
- import { a as createRpcWorker, n as generateTypesInChildProcess, t as consumeTypes } from "./consumeTypes-CirXBJjN.mjs";
3
+ import { c as logger$1, o as getIPV4 } from "./Broker-CtU3X_nw.mjs";
4
+ import { a as createRpcWorker, n as generateTypesInChildProcess, t as consumeTypes } from "./consumeTypes-DnucwjbD.mjs";
5
5
  import "./core.mjs";
6
6
  import * as fse$1 from "fs-extra";
7
7
  import fse from "fs-extra";
@@ -312,7 +312,25 @@ const getGenerateTypesFn = (dtsManagerOptions) => {
312
312
  return fn;
313
313
  };
314
314
  const generateTypesAPI = ({ dtsManagerOptions }) => {
315
- return getGenerateTypesFn(dtsManagerOptions)(dtsManagerOptions);
315
+ return getGenerateTypesFn(dtsManagerOptions)(dtsManagerOptions).then(async () => {
316
+ await callAfterGenerateHook({
317
+ dtsManagerOptions,
318
+ generatedTypes: retrieveTypesAssetsInfo(dtsManagerOptions.remote)
319
+ });
320
+ });
321
+ };
322
+ const callAfterGenerateHook = async ({ dtsManagerOptions, generatedTypes }) => {
323
+ const afterGenerate = dtsManagerOptions.remote.afterGenerate;
324
+ if (!afterGenerate) return;
325
+ try {
326
+ await afterGenerate(generatedTypes);
327
+ } catch (error) {
328
+ if (dtsManagerOptions.remote.abortOnError === false) {
329
+ if (dtsManagerOptions.displayErrorInTerminal) logger.error(error);
330
+ return;
331
+ }
332
+ throw error;
333
+ }
316
334
  };
317
335
  const WINDOWS_ABSOLUTE_PATH_REGEXP = /^[a-zA-Z]:[\\/]/;
318
336
  const isSafeRelativePath = (relativePath) => {
@@ -1,4 +1,4 @@
1
- import { s as fileLog, t as Broker } from "./Broker-BU4gToNr.mjs";
1
+ import { s as fileLog, t as Broker } from "./Broker-CtU3X_nw.mjs";
2
2
 
3
3
  //#region src/server/broker/startBroker.ts
4
4
  let broker;
@@ -1,5 +1,5 @@
1
1
  const require_Action = require('./Action-CzhPMw2i.js');
2
- const require_Broker = require('./Broker-DRlzScTT.js');
2
+ const require_Broker = require('./Broker-BGm-heAJ.js');
3
3
  let fs_extra = require("fs-extra");
4
4
  fs_extra = require_Action.__toESM(fs_extra);
5
5
  let path = require("path");
@@ -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-DRlzScTT.js');
4
- const require_expose_rpc = require('./expose-rpc-BAS_80E1.js');
5
- require('./consumeTypes-DHKw9PGQ.js');
3
+ const require_Broker = require('./Broker-BGm-heAJ.js');
4
+ const require_expose_rpc = require('./expose-rpc-xfJEPIyY.js');
5
+ require('./consumeTypes-ClKC4akt.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-DRlzScTT.js');
3
- const require_expose_rpc = require('./expose-rpc-BAS_80E1.js');
2
+ require('./Broker-BGm-heAJ.js');
3
+ const require_expose_rpc = require('./expose-rpc-xfJEPIyY.js');
4
4
 
5
5
  //#region src/core/lib/forkGenerateDts.ts
6
6
  async function forkGenerateDts(options) {
package/dist/index.js CHANGED
@@ -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-DRlzScTT.js');
4
- const require_expose_rpc = require('./expose-rpc-BAS_80E1.js');
5
- const require_consumeTypes = require('./consumeTypes-DHKw9PGQ.js');
3
+ const require_Broker = require('./Broker-BGm-heAJ.js');
4
+ const require_expose_rpc = require('./expose-rpc-xfJEPIyY.js');
5
+ const require_consumeTypes = require('./consumeTypes-ClKC4akt.js');
6
6
  require('./core.js');
7
7
  let fs_extra = require("fs-extra");
8
8
  fs_extra = require_Action.__toESM(fs_extra);
@@ -314,7 +314,25 @@ const getGenerateTypesFn = (dtsManagerOptions) => {
314
314
  return fn;
315
315
  };
316
316
  const generateTypesAPI = ({ dtsManagerOptions }) => {
317
- return getGenerateTypesFn(dtsManagerOptions)(dtsManagerOptions);
317
+ return getGenerateTypesFn(dtsManagerOptions)(dtsManagerOptions).then(async () => {
318
+ await callAfterGenerateHook({
319
+ dtsManagerOptions,
320
+ generatedTypes: require_expose_rpc.retrieveTypesAssetsInfo(dtsManagerOptions.remote)
321
+ });
322
+ });
323
+ };
324
+ const callAfterGenerateHook = async ({ dtsManagerOptions, generatedTypes }) => {
325
+ const afterGenerate = dtsManagerOptions.remote.afterGenerate;
326
+ if (!afterGenerate) return;
327
+ try {
328
+ await afterGenerate(generatedTypes);
329
+ } catch (error) {
330
+ if (dtsManagerOptions.remote.abortOnError === false) {
331
+ if (dtsManagerOptions.displayErrorInTerminal) _module_federation_sdk.logger.error(error);
332
+ return;
333
+ }
334
+ throw error;
335
+ }
318
336
  };
319
337
  const WINDOWS_ABSOLUTE_PATH_REGEXP = /^[a-zA-Z]:[\\/]/;
320
338
  const isSafeRelativePath = (relativePath) => {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/dts-plugin",
3
- "version": "2.2.3",
3
+ "version": "2.3.0",
4
4
  "author": "hanric <hanric.zhang@gmail.com>",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -76,7 +76,6 @@
76
76
  "fs-extra": "9.1.0",
77
77
  "isomorphic-ws": "5.0.0",
78
78
  "lodash.clonedeepwith": "4.5.0",
79
- "log4js": "6.9.1",
80
79
  "node-schedule": "2.1.1",
81
80
  "rambda": "^9.1.0",
82
81
  "ws": "8.18.0"
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_Broker = require('./Broker-DRlzScTT.js');
2
+ const require_Broker = require('./Broker-BGm-heAJ.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.2.3",
3
+ "version": "2.3.0",
4
4
  "author": "hanric <hanric.zhang@gmail.com>",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -72,14 +72,13 @@
72
72
  "fs-extra": "9.1.0",
73
73
  "isomorphic-ws": "5.0.0",
74
74
  "lodash.clonedeepwith": "4.5.0",
75
- "log4js": "6.9.1",
76
75
  "node-schedule": "2.1.1",
77
76
  "rambda": "^9.1.0",
78
77
  "ws": "8.18.0",
79
- "@module-federation/error-codes": "2.2.3",
80
- "@module-federation/third-party-dts-extractor": "2.2.3",
81
- "@module-federation/managers": "2.2.3",
82
- "@module-federation/sdk": "2.2.3"
78
+ "@module-federation/error-codes": "2.3.0",
79
+ "@module-federation/managers": "2.3.0",
80
+ "@module-federation/sdk": "2.3.0",
81
+ "@module-federation/third-party-dts-extractor": "2.3.0"
83
82
  },
84
83
  "devDependencies": {
85
84
  "@types/node-schedule": "2.1.7",
@@ -91,7 +90,7 @@
91
90
  "directory-tree": "3.5.2",
92
91
  "vitest": "1.6.0",
93
92
  "webpack": "^5.104.1",
94
- "@module-federation/runtime": "2.2.3"
93
+ "@module-federation/runtime": "2.3.0"
95
94
  },
96
95
  "peerDependencies": {
97
96
  "typescript": "^4.9.0 || ^5.0.0",