@module-federation/dts-plugin 0.21.4 → 0.21.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -133,7 +133,7 @@ var import_path2 = require("path");
133
133
  var import_promises2 = require("fs/promises");
134
134
 
135
135
  // src/core/lib/typeScriptCompiler.ts
136
- var import_fs_extra = require("fs-extra");
136
+ var import_fs_extra2 = require("fs-extra");
137
137
  var import_crypto = __toESM(require("crypto"));
138
138
  var import_promises = require("fs/promises");
139
139
  var import_path = require("path");
@@ -141,150 +141,7 @@ var import_error_codes = require("@module-federation/error-codes");
141
141
  var import_third_party_dts_extractor = require("@module-federation/third-party-dts-extractor");
142
142
  var import_child_process = require("child_process");
143
143
  var import_util = __toESM(require("util"));
144
- var import_sdk = require("@module-federation/sdk");
145
- var STARTS_WITH_SLASH = /^\//;
146
- var DEFINITION_FILE_EXTENSION = ".d.ts";
147
- var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
148
- var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
149
- var retrieveMfAPITypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.join)(retrieveOriginalOutDir(tsConfig, remoteOptions), `${remoteOptions.typesFolder}.d.ts`), "retrieveMfAPITypesPath");
150
- function writeTempTsConfig(tsConfig, context, name, cwd) {
151
- const createHash = /* @__PURE__ */ __name((contents) => {
152
- return import_crypto.default.createHash("md5").update(contents).digest("hex");
153
- }, "createHash");
154
- const hash = createHash(`${JSON.stringify(tsConfig)}${name}${Date.now()}`);
155
- const tempTsConfigJsonPath = (0, import_path.resolve)(cwd != null ? cwd : context, "node_modules", import_sdk.TEMP_DIR, `tsconfig.${hash}.json`);
156
- (0, import_fs_extra.ensureDirSync)((0, import_path.dirname)(tempTsConfigJsonPath));
157
- (0, import_fs_extra.writeFileSync)(tempTsConfigJsonPath, JSON.stringify(tsConfig, null, 2));
158
- return tempTsConfigJsonPath;
159
- }
160
- __name(writeTempTsConfig, "writeTempTsConfig");
161
- var removeExt = /* @__PURE__ */ __name((f) => {
162
- const vueExt = ".vue";
163
- const ext = (0, import_path.extname)(f);
164
- if (ext === vueExt) {
165
- return f;
166
- }
167
- const regexPattern = new RegExp(`\\${ext}$`);
168
- return f.replace(regexPattern, "");
169
- }, "removeExt");
170
- function getExposeKey(options) {
171
- const { filePath, rootDir, outDir, mapExposeToEntry } = options;
172
- const relativeFilePath = (0, import_path.relative)(outDir, filePath.replace(new RegExp(`\\.d.ts$`), ""));
173
- return mapExposeToEntry[relativeFilePath];
174
- }
175
- __name(getExposeKey, "getExposeKey");
176
- var processTypesFile = /* @__PURE__ */ __name((options) => __async(void 0, null, function* () {
177
- const { outDir, filePath, rootDir, cb, mapExposeToEntry, mfTypePath } = options;
178
- if (!(0, import_fs_extra.existsSync)(filePath)) {
179
- return;
180
- }
181
- const stats = yield (0, import_promises.stat)(filePath);
182
- if (stats.isDirectory()) {
183
- const files = yield (0, import_promises.readdir)(filePath);
184
- yield Promise.all(files.map((file) => processTypesFile(__spreadProps(__spreadValues({}, options), {
185
- filePath: (0, import_path.join)(filePath, file)
186
- }))));
187
- } else if (filePath.endsWith(".d.ts")) {
188
- const exposeKey = getExposeKey({
189
- filePath,
190
- rootDir,
191
- outDir,
192
- mapExposeToEntry
193
- });
194
- if (exposeKey) {
195
- const sourceEntry = exposeKey === "." ? "index" : exposeKey;
196
- const mfeTypeEntry = (0, import_path.join)(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
197
- const mfeTypeEntryDirectory = (0, import_path.dirname)(mfeTypeEntry);
198
- const relativePathToOutput = (0, import_path.relative)(mfeTypeEntryDirectory, filePath).replace(DEFINITION_FILE_EXTENSION, "").replace(STARTS_WITH_SLASH, "").split(import_path.sep).join("/");
199
- (0, import_fs_extra.ensureDirSync)(mfeTypeEntryDirectory);
200
- yield (0, import_promises.writeFile)(mfeTypeEntry, `export * from './${relativePathToOutput}';
201
- export { default } from './${relativePathToOutput}';`);
202
- }
203
- const content = yield (0, import_promises.readFile)(filePath, "utf8");
204
- cb(content);
205
- }
206
- }), "processTypesFile");
207
- var getPMFromUserAgent = /* @__PURE__ */ __name(() => {
208
- const userAgent = process.env["npm_config_user_agent"];
209
- if (userAgent == null) {
210
- return "null";
211
- }
212
- const name = userAgent.split("/")[0];
213
- return name;
214
- }, "getPMFromUserAgent");
215
- var resolvePackageManagerExecutable = /* @__PURE__ */ __name(() => {
216
- const pm = getPMFromUserAgent();
217
- switch (pm) {
218
- case "yarn":
219
- return "yarn";
220
- case "npm":
221
- case "pnpm":
222
- default:
223
- return "npx";
224
- }
225
- }, "resolvePackageManagerExecutable");
226
- var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
227
- var _a3, _b, _c, _d;
228
- if (!Object.keys(mapComponentsToExpose).length) {
229
- return;
230
- }
231
- const { compilerOptions } = tsConfig;
232
- const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf", typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_b = (_a3 = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _a3.cwd) != null ? _b : void 0 : void 0);
233
- try {
234
- const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
235
- const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
236
- destDir: (0, import_path.resolve)(mfTypePath, "node_modules"),
237
- context: remoteOptions.context,
238
- exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
239
- });
240
- const execPromise = import_util.default.promisify(import_child_process.exec);
241
- const pmExecutable = resolvePackageManagerExecutable();
242
- const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
243
- try {
244
- yield execPromise(cmd, {
245
- cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
246
- });
247
- } catch (err) {
248
- if (compilerOptions.tsBuildInfoFile) {
249
- try {
250
- yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
251
- } catch (e) {
252
- }
253
- }
254
- throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
255
- cmd
256
- }));
257
- }
258
- const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
259
- const normalizedFileName = (0, import_path.normalize)(filename);
260
- let relativeFileName = "";
261
- if ((0, import_path.isAbsolute)(normalizedFileName)) {
262
- relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, normalizedFileName);
263
- } else {
264
- relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, (0, import_path.resolve)(remoteOptions.context, normalizedFileName));
265
- }
266
- return [
267
- removeExt(relativeFileName),
268
- exposed
269
- ];
270
- }));
271
- const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
272
- yield processTypesFile({
273
- outDir: compilerOptions.outDir,
274
- filePath: compilerOptions.outDir,
275
- rootDir: compilerOptions.rootDir,
276
- mfTypePath,
277
- cb,
278
- mapExposeToEntry
279
- });
280
- if (remoteOptions.extractThirdParty) {
281
- yield thirdPartyExtractor.copyDts();
282
- }
283
- yield (0, import_promises.rm)(tempTsConfigJsonPath);
284
- } catch (err) {
285
- throw err;
286
- }
287
- }), "compileTs");
144
+ var import_sdk3 = require("@module-federation/sdk");
288
145
 
289
146
  // src/server/message/Message.ts
290
147
  var _Message = class _Message {
@@ -357,7 +214,7 @@ __name(_FetchTypesAPI, "FetchTypesAPI");
357
214
  var FetchTypesAPI = _FetchTypesAPI;
358
215
 
359
216
  // src/server/utils/index.ts
360
- var import_sdk3 = require("@module-federation/sdk");
217
+ var import_sdk2 = require("@module-federation/sdk");
361
218
 
362
219
  // src/server/utils/logTransform.ts
363
220
  var import_chalk = __toESM(require("chalk"));
@@ -396,7 +253,7 @@ __name(_BrokerExitLog, "BrokerExitLog");
396
253
  var BrokerExitLog = _BrokerExitLog;
397
254
 
398
255
  // src/server/utils/log.ts
399
- var import_sdk2 = require("@module-federation/sdk");
256
+ var import_sdk = require("@module-federation/sdk");
400
257
  var log4js = __toESM(require("log4js"));
401
258
 
402
259
  // src/server/constant.ts
@@ -411,7 +268,7 @@ var UpdateMode;
411
268
  })(UpdateMode || (UpdateMode = {}));
412
269
 
413
270
  // src/server/utils/log.ts
414
- var logger = (0, import_sdk2.createLogger)(`[ ${MF_SERVER_IDENTIFIER} ]`);
271
+ var logger = (0, import_sdk.createLogger)(`[ ${MF_SERVER_IDENTIFIER} ]`);
415
272
  function fileLog(msg, module2, level) {
416
273
  var _a3, _b;
417
274
  if (!((_a3 = process == null ? void 0 : process.env) == null ? void 0 : _a3["FEDERATION_DEBUG"])) {
@@ -486,7 +343,7 @@ var getIPV4 = /* @__PURE__ */ __name(() => {
486
343
  // src/server/utils/index.ts
487
344
  function getIdentifier(options) {
488
345
  const { ip, name } = options;
489
- return `mf ${import_sdk3.SEPARATOR}${name}${ip ? `${import_sdk3.SEPARATOR}${ip}` : ""}`;
346
+ return `mf ${import_sdk2.SEPARATOR}${name}${ip ? `${import_sdk2.SEPARATOR}${ip}` : ""}`;
490
347
  }
491
348
  __name(getIdentifier, "getIdentifier");
492
349
 
@@ -1188,9 +1045,157 @@ __publicField(_Broker, "DEFAULT_WAITING_TIME", 1.5 * 60 * 60 * 1e3);
1188
1045
  var Broker = _Broker;
1189
1046
 
1190
1047
  // src/server/createKoaServer.ts
1191
- var import_fs_extra2 = __toESM(require("fs-extra"));
1048
+ var import_fs_extra = __toESM(require("fs-extra"));
1192
1049
  var import_koa = __toESM(require("koa"));
1193
1050
 
1051
+ // src/core/lib/typeScriptCompiler.ts
1052
+ var STARTS_WITH_SLASH = /^\//;
1053
+ var DEFINITION_FILE_EXTENSION = ".d.ts";
1054
+ var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
1055
+ var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
1056
+ var retrieveMfAPITypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.join)(retrieveOriginalOutDir(tsConfig, remoteOptions), `${remoteOptions.typesFolder}.d.ts`), "retrieveMfAPITypesPath");
1057
+ function writeTempTsConfig(tsConfig, context, name, cwd) {
1058
+ const createHash = /* @__PURE__ */ __name((contents) => {
1059
+ return import_crypto.default.createHash("md5").update(contents).digest("hex");
1060
+ }, "createHash");
1061
+ const hash = createHash(`${JSON.stringify(tsConfig)}${name}${Date.now()}`);
1062
+ const tempTsConfigJsonPath = (0, import_path.resolve)(cwd != null ? cwd : context, "node_modules", import_sdk3.TEMP_DIR, `tsconfig.${hash}.json`);
1063
+ (0, import_fs_extra2.ensureDirSync)((0, import_path.dirname)(tempTsConfigJsonPath));
1064
+ (0, import_fs_extra2.writeFileSync)(tempTsConfigJsonPath, JSON.stringify(tsConfig, null, 2));
1065
+ return tempTsConfigJsonPath;
1066
+ }
1067
+ __name(writeTempTsConfig, "writeTempTsConfig");
1068
+ var removeExt = /* @__PURE__ */ __name((f) => {
1069
+ const vueExt = ".vue";
1070
+ const ext = (0, import_path.extname)(f);
1071
+ if (ext === vueExt) {
1072
+ return f;
1073
+ }
1074
+ const regexPattern = new RegExp(`\\${ext}$`);
1075
+ return f.replace(regexPattern, "");
1076
+ }, "removeExt");
1077
+ function getExposeKey(options) {
1078
+ const { filePath, rootDir, outDir, mapExposeToEntry } = options;
1079
+ const relativeFilePath = (0, import_path.relative)(outDir, filePath.replace(new RegExp(`\\.d.ts$`), ""));
1080
+ return mapExposeToEntry[relativeFilePath];
1081
+ }
1082
+ __name(getExposeKey, "getExposeKey");
1083
+ var processTypesFile = /* @__PURE__ */ __name((options) => __async(void 0, null, function* () {
1084
+ const { outDir, filePath, rootDir, cb, mapExposeToEntry, mfTypePath } = options;
1085
+ if (!(0, import_fs_extra2.existsSync)(filePath)) {
1086
+ return;
1087
+ }
1088
+ const stats = yield (0, import_promises.stat)(filePath);
1089
+ if (stats.isDirectory()) {
1090
+ const files = yield (0, import_promises.readdir)(filePath);
1091
+ yield Promise.all(files.map((file) => processTypesFile(__spreadProps(__spreadValues({}, options), {
1092
+ filePath: (0, import_path.join)(filePath, file)
1093
+ }))));
1094
+ } else if (filePath.endsWith(".d.ts")) {
1095
+ const exposeKey = getExposeKey({
1096
+ filePath,
1097
+ rootDir,
1098
+ outDir,
1099
+ mapExposeToEntry
1100
+ });
1101
+ if (exposeKey) {
1102
+ const sourceEntry = exposeKey === "." ? "index" : exposeKey;
1103
+ const mfeTypeEntry = (0, import_path.join)(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
1104
+ const mfeTypeEntryDirectory = (0, import_path.dirname)(mfeTypeEntry);
1105
+ const relativePathToOutput = (0, import_path.relative)(mfeTypeEntryDirectory, filePath).replace(DEFINITION_FILE_EXTENSION, "").replace(STARTS_WITH_SLASH, "").split(import_path.sep).join("/");
1106
+ (0, import_fs_extra2.ensureDirSync)(mfeTypeEntryDirectory);
1107
+ yield (0, import_promises.writeFile)(mfeTypeEntry, `export * from './${relativePathToOutput}';
1108
+ export { default } from './${relativePathToOutput}';`);
1109
+ }
1110
+ const content = yield (0, import_promises.readFile)(filePath, "utf8");
1111
+ cb(content);
1112
+ }
1113
+ }), "processTypesFile");
1114
+ var getPMFromUserAgent = /* @__PURE__ */ __name(() => {
1115
+ const userAgent = process.env["npm_config_user_agent"];
1116
+ if (userAgent == null) {
1117
+ return "null";
1118
+ }
1119
+ const name = userAgent.split("/")[0];
1120
+ return name;
1121
+ }, "getPMFromUserAgent");
1122
+ var resolvePackageManagerExecutable = /* @__PURE__ */ __name(() => {
1123
+ const pm = getPMFromUserAgent();
1124
+ switch (pm) {
1125
+ case "yarn":
1126
+ return "yarn";
1127
+ case "npm":
1128
+ case "pnpm":
1129
+ default:
1130
+ return "npx";
1131
+ }
1132
+ }, "resolvePackageManagerExecutable");
1133
+ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
1134
+ var _a3, _b, _c, _d;
1135
+ if (!Object.keys(mapComponentsToExpose).length) {
1136
+ return;
1137
+ }
1138
+ const { compilerOptions } = tsConfig;
1139
+ const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf", typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_b = (_a3 = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _a3.cwd) != null ? _b : void 0 : void 0);
1140
+ logger.debug(`tempTsConfigJsonPath: ${tempTsConfigJsonPath}`);
1141
+ try {
1142
+ const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
1143
+ const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
1144
+ destDir: (0, import_path.resolve)(mfTypePath, "node_modules"),
1145
+ context: remoteOptions.context,
1146
+ exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
1147
+ });
1148
+ const execPromise = import_util.default.promisify(import_child_process.exec);
1149
+ const pmExecutable = resolvePackageManagerExecutable();
1150
+ const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
1151
+ try {
1152
+ yield execPromise(cmd, {
1153
+ cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
1154
+ });
1155
+ } catch (err) {
1156
+ if (compilerOptions.tsBuildInfoFile) {
1157
+ try {
1158
+ yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
1159
+ } catch (e) {
1160
+ }
1161
+ }
1162
+ throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
1163
+ cmd
1164
+ }));
1165
+ }
1166
+ const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
1167
+ const normalizedFileName = (0, import_path.normalize)(filename);
1168
+ let relativeFileName = "";
1169
+ if ((0, import_path.isAbsolute)(normalizedFileName)) {
1170
+ relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, normalizedFileName);
1171
+ } else {
1172
+ relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, (0, import_path.resolve)(remoteOptions.context, normalizedFileName));
1173
+ }
1174
+ return [
1175
+ removeExt(relativeFileName),
1176
+ exposed
1177
+ ];
1178
+ }));
1179
+ const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
1180
+ yield processTypesFile({
1181
+ outDir: compilerOptions.outDir,
1182
+ filePath: compilerOptions.outDir,
1183
+ rootDir: compilerOptions.rootDir,
1184
+ mfTypePath,
1185
+ cb,
1186
+ mapExposeToEntry
1187
+ });
1188
+ if (remoteOptions.extractThirdParty) {
1189
+ yield thirdPartyExtractor.copyDts();
1190
+ }
1191
+ if (remoteOptions.deleteTsConfig) {
1192
+ yield (0, import_promises.rm)(tempTsConfigJsonPath);
1193
+ }
1194
+ } catch (err) {
1195
+ throw err;
1196
+ }
1197
+ }), "compileTs");
1198
+
1194
1199
  // src/core/lib/archiveHandler.ts
1195
1200
  var retrieveTypesZipPath = /* @__PURE__ */ __name((mfTypesPath, remoteOptions) => (0, import_path2.join)(mfTypesPath.replace(remoteOptions.typesFolder, ""), `${remoteOptions.typesFolder}.zip`), "retrieveTypesZipPath");
1196
1201
  var createTypesArchive = /* @__PURE__ */ __name((tsConfig, remoteOptions) => __async(void 0, null, function* () {
@@ -1804,15 +1809,12 @@ var validateOptions = /* @__PURE__ */ __name((options) => {
1804
1809
  }
1805
1810
  }, "validateOptions");
1806
1811
  function retrieveTypesAssetsInfo(options) {
1807
- const { moduleFederationConfig } = options;
1808
1812
  let apiTypesPath = "";
1809
1813
  let zipTypesPath = "";
1810
- let zipPrefix = "";
1811
1814
  try {
1812
1815
  const { tsConfig, remoteOptions, mapComponentsToExpose } = retrieveRemoteConfig(options);
1813
1816
  if (!Object.keys(mapComponentsToExpose).length || !tsConfig.files.length) {
1814
1817
  return {
1815
- zipPrefix,
1816
1818
  apiTypesPath,
1817
1819
  zipTypesPath,
1818
1820
  zipName: "",
@@ -1824,15 +1826,7 @@ function retrieveTypesAssetsInfo(options) {
1824
1826
  if (remoteOptions.generateAPITypes) {
1825
1827
  apiTypesPath = retrieveMfAPITypesPath(tsConfig, remoteOptions);
1826
1828
  }
1827
- if (typeof moduleFederationConfig.manifest === "object" && moduleFederationConfig.manifest.filePath) {
1828
- zipPrefix = moduleFederationConfig.manifest.filePath;
1829
- } else if (typeof moduleFederationConfig.manifest === "object" && moduleFederationConfig.manifest.fileName) {
1830
- zipPrefix = import_path4.default.dirname(moduleFederationConfig.manifest.fileName);
1831
- } else if (moduleFederationConfig.filename) {
1832
- zipPrefix = import_path4.default.dirname(moduleFederationConfig.filename);
1833
- }
1834
1829
  return {
1835
- zipPrefix,
1836
1830
  apiTypesPath,
1837
1831
  zipTypesPath,
1838
1832
  zipName: import_path4.default.basename(zipTypesPath),
@@ -1841,7 +1835,6 @@ function retrieveTypesAssetsInfo(options) {
1841
1835
  } catch (err) {
1842
1836
  console.error(import_ansi_colors.default.red(`Unable to compile federated types, ${err}`));
1843
1837
  return {
1844
- zipPrefix,
1845
1838
  apiTypesPath: "",
1846
1839
  zipTypesPath: "",
1847
1840
  zipName: "",
@@ -1934,7 +1927,8 @@ var defaultOptions2 = {
1934
1927
  abortOnError: true,
1935
1928
  extractRemoteTypes: false,
1936
1929
  extractThirdParty: false,
1937
- outputDir: ""
1930
+ outputDir: "",
1931
+ deleteTsConfig: true
1938
1932
  };
1939
1933
  function getEffectiveRootDir(parsedCommandLine) {
1940
1934
  const compilerOptions = parsedCommandLine.options;
@@ -2004,6 +1998,9 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
2004
1998
  rawTsConfigJson.exclude = [];
2005
1999
  "references" in rawTsConfigJson && delete rawTsConfigJson.references;
2006
2000
  rawTsConfigJson.extends = resolvedTsConfigPath;
2001
+ if (rawTsConfigJson.compilerOptions.declarationDir) {
2002
+ delete rawTsConfigJson.compilerOptions.declarationDir;
2003
+ }
2007
2004
  return rawTsConfigJson;
2008
2005
  }, "readTsConfig");
2009
2006
  var TS_EXTENSIONS = [
@@ -2812,23 +2809,12 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
2812
2809
  dtsManagerOptions
2813
2810
  });
2814
2811
  import_sdk10.logger.debug("generate types success!");
2815
- const config = dtsManagerOptions.remote.moduleFederationConfig;
2816
- let zipPrefix = "";
2817
- if (typeof config.manifest === "object" && config.manifest.filePath) {
2818
- zipPrefix = config.manifest.filePath;
2819
- } else if (typeof config.manifest === "object" && config.manifest.fileName) {
2820
- zipPrefix = import_path10.default.dirname(config.manifest.fileName);
2821
- } else if (config.filename) {
2822
- zipPrefix = import_path10.default.dirname(config.filename);
2823
- }
2824
2812
  if (isProd) {
2825
- const zipAssetName = import_path10.default.join(zipPrefix, zipName);
2826
- const apiAssetName = import_path10.default.join(zipPrefix, apiFileName);
2827
- if (zipTypesPath && !compilation.getAsset(zipAssetName) && import_fs4.default.existsSync(zipTypesPath)) {
2828
- compilation.emitAsset(zipAssetName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(zipTypesPath), false));
2813
+ if (zipTypesPath && !compilation.getAsset(zipName) && import_fs4.default.existsSync(zipTypesPath)) {
2814
+ compilation.emitAsset(zipName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(zipTypesPath), false));
2829
2815
  }
2830
- if (apiTypesPath && !compilation.getAsset(apiAssetName) && import_fs4.default.existsSync(apiTypesPath)) {
2831
- compilation.emitAsset(apiAssetName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(apiTypesPath), false));
2816
+ if (apiTypesPath && !compilation.getAsset(apiFileName) && import_fs4.default.existsSync(apiTypesPath)) {
2817
+ compilation.emitAsset(apiFileName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(apiTypesPath), false));
2832
2818
  }
2833
2819
  callback();
2834
2820
  } else {
@@ -2837,7 +2823,7 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
2837
2823
  }, "isEEXIST");
2838
2824
  if (zipTypesPath && import_fs4.default.existsSync(zipTypesPath)) {
2839
2825
  const zipContent = import_fs4.default.readFileSync(zipTypesPath);
2840
- const zipOutputPath = import_path10.default.join(compiler.outputPath, zipPrefix, zipName);
2826
+ const zipOutputPath = import_path10.default.join(compiler.outputPath, zipName);
2841
2827
  yield new Promise((resolve5, reject) => {
2842
2828
  compiler.outputFileSystem.mkdir(
2843
2829
  import_path10.default.dirname(zipOutputPath),
@@ -2868,7 +2854,7 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
2868
2854
  }
2869
2855
  if (apiTypesPath && import_fs4.default.existsSync(apiTypesPath)) {
2870
2856
  const apiContent = import_fs4.default.readFileSync(apiTypesPath);
2871
- const apiOutputPath = import_path10.default.join(compiler.outputPath, zipPrefix, apiFileName);
2857
+ const apiOutputPath = import_path10.default.join(compiler.outputPath, apiFileName);
2872
2858
  yield new Promise((resolve5, reject) => {
2873
2859
  compiler.outputFileSystem.mkdir(
2874
2860
  import_path10.default.dirname(apiOutputPath),
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/dts-plugin",
3
- "version": "0.21.4",
3
+ "version": "0.21.5",
4
4
  "author": "hanric <hanric.zhang@gmail.com>",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -5,7 +5,6 @@ import { D as DTSManager } from './DTSManager-b15Gfat3.js';
5
5
  declare function getDTSManagerConstructor(implementation?: string): typeof DTSManager;
6
6
  declare const validateOptions: (options: HostOptions) => void;
7
7
  declare function retrieveTypesAssetsInfo(options: RemoteOptions): {
8
- zipPrefix: string;
9
8
  apiTypesPath: string;
10
9
  zipTypesPath: string;
11
10
  zipName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/dts-plugin",
3
- "version": "0.21.4",
3
+ "version": "0.21.5",
4
4
  "author": "hanric <hanric.zhang@gmail.com>",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -60,10 +60,10 @@
60
60
  "log4js": "6.9.1",
61
61
  "node-schedule": "2.1.1",
62
62
  "ws": "8.18.0",
63
- "@module-federation/sdk": "0.21.4",
64
- "@module-federation/third-party-dts-extractor": "0.21.4",
65
- "@module-federation/error-codes": "0.21.4",
66
- "@module-federation/managers": "0.21.4"
63
+ "@module-federation/sdk": "0.21.5",
64
+ "@module-federation/managers": "0.21.5",
65
+ "@module-federation/third-party-dts-extractor": "0.21.5",
66
+ "@module-federation/error-codes": "0.21.5"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/ws": "8.5.12",
@@ -73,7 +73,7 @@
73
73
  "@vue/tsconfig": "^0.7.0",
74
74
  "vue-tsc": "^2.2.10",
75
75
  "rimraf": "~6.0.1",
76
- "@module-federation/runtime": "0.21.4"
76
+ "@module-federation/runtime": "0.21.5"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "typescript": "^4.9.0 || ^5.0.0",