@module-federation/dts-plugin 0.21.3 → 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.
@@ -29,140 +29,6 @@ import {
29
29
  __spreadValues
30
30
  } from "./chunk-647HGGGS.js";
31
31
 
32
- // src/core/lib/typeScriptCompiler.ts
33
- import { ensureDirSync, writeFileSync, existsSync } from "fs-extra";
34
- import crypto from "crypto";
35
- import { stat, readdir, writeFile, rm, readFile } from "fs/promises";
36
- import { dirname, join, normalize, relative, resolve, sep, extname, isAbsolute } from "path";
37
- import { getShortErrorMsg, TYPE_001, typeDescMap } from "@module-federation/error-codes";
38
- import { ThirdPartyExtractor } from "@module-federation/third-party-dts-extractor";
39
- import { exec } from "child_process";
40
- import util from "util";
41
- import { TEMP_DIR } from "@module-federation/sdk";
42
- var STARTS_WITH_SLASH = /^\//;
43
- var DEFINITION_FILE_EXTENSION = ".d.ts";
44
- var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => normalize(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
45
- var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => normalize(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
46
- var retrieveMfAPITypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => join(retrieveOriginalOutDir(tsConfig, remoteOptions), `${remoteOptions.typesFolder}.d.ts`), "retrieveMfAPITypesPath");
47
- function writeTempTsConfig(tsConfig, context, name, cwd) {
48
- const createHash = /* @__PURE__ */ __name((contents) => {
49
- return crypto.createHash("md5").update(contents).digest("hex");
50
- }, "createHash");
51
- const hash = createHash(`${JSON.stringify(tsConfig)}${name}${Date.now()}`);
52
- const tempTsConfigJsonPath = resolve(cwd != null ? cwd : context, "node_modules", TEMP_DIR, `tsconfig.${hash}.json`);
53
- ensureDirSync(dirname(tempTsConfigJsonPath));
54
- writeFileSync(tempTsConfigJsonPath, JSON.stringify(tsConfig, null, 2));
55
- return tempTsConfigJsonPath;
56
- }
57
- __name(writeTempTsConfig, "writeTempTsConfig");
58
- var removeExt = /* @__PURE__ */ __name((f) => {
59
- const vueExt = ".vue";
60
- const ext = extname(f);
61
- if (ext === vueExt) {
62
- return f;
63
- }
64
- const regexPattern = new RegExp(`\\${ext}$`);
65
- return f.replace(regexPattern, "");
66
- }, "removeExt");
67
- function getExposeKey(options) {
68
- const { filePath, rootDir, outDir, mapExposeToEntry } = options;
69
- const relativeFilePath = relative(outDir, filePath.replace(new RegExp(`\\.d.ts$`), ""));
70
- return mapExposeToEntry[relativeFilePath];
71
- }
72
- __name(getExposeKey, "getExposeKey");
73
- var processTypesFile = /* @__PURE__ */ __name((options) => __async(void 0, null, function* () {
74
- const { outDir, filePath, rootDir, cb, mapExposeToEntry, mfTypePath } = options;
75
- if (!existsSync(filePath)) {
76
- return;
77
- }
78
- const stats = yield stat(filePath);
79
- if (stats.isDirectory()) {
80
- const files = yield readdir(filePath);
81
- yield Promise.all(files.map((file) => processTypesFile(__spreadProps(__spreadValues({}, options), {
82
- filePath: join(filePath, file)
83
- }))));
84
- } else if (filePath.endsWith(".d.ts")) {
85
- const exposeKey = getExposeKey({
86
- filePath,
87
- rootDir,
88
- outDir,
89
- mapExposeToEntry
90
- });
91
- if (exposeKey) {
92
- const sourceEntry = exposeKey === "." ? "index" : exposeKey;
93
- const mfeTypeEntry = join(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
94
- const mfeTypeEntryDirectory = dirname(mfeTypeEntry);
95
- const relativePathToOutput = relative(mfeTypeEntryDirectory, filePath).replace(DEFINITION_FILE_EXTENSION, "").replace(STARTS_WITH_SLASH, "").split(sep).join("/");
96
- ensureDirSync(mfeTypeEntryDirectory);
97
- yield writeFile(mfeTypeEntry, `export * from './${relativePathToOutput}';
98
- export { default } from './${relativePathToOutput}';`);
99
- }
100
- const content = yield readFile(filePath, "utf8");
101
- cb(content);
102
- }
103
- }), "processTypesFile");
104
- var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
105
- var _a2, _b, _c, _d;
106
- if (!Object.keys(mapComponentsToExpose).length) {
107
- return;
108
- }
109
- const { compilerOptions } = tsConfig;
110
- const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf", typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_b = (_a2 = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _a2.cwd) != null ? _b : void 0 : void 0);
111
- try {
112
- const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
113
- const thirdPartyExtractor = new ThirdPartyExtractor({
114
- destDir: resolve(mfTypePath, "node_modules"),
115
- context: remoteOptions.context,
116
- exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
117
- });
118
- const execPromise = util.promisify(exec);
119
- const cmd = `npx ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
120
- try {
121
- yield execPromise(cmd, {
122
- cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
123
- });
124
- } catch (err) {
125
- if (compilerOptions.tsBuildInfoFile) {
126
- try {
127
- yield rm(compilerOptions.tsBuildInfoFile);
128
- } catch (e) {
129
- }
130
- }
131
- throw new Error(getShortErrorMsg(TYPE_001, typeDescMap, {
132
- cmd
133
- }));
134
- }
135
- const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
136
- const normalizedFileName = normalize(filename);
137
- let relativeFileName = "";
138
- if (isAbsolute(normalizedFileName)) {
139
- relativeFileName = relative(tsConfig.compilerOptions.rootDir, normalizedFileName);
140
- } else {
141
- relativeFileName = relative(tsConfig.compilerOptions.rootDir, resolve(remoteOptions.context, normalizedFileName));
142
- }
143
- return [
144
- removeExt(relativeFileName),
145
- exposed
146
- ];
147
- }));
148
- const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
149
- yield processTypesFile({
150
- outDir: compilerOptions.outDir,
151
- filePath: compilerOptions.outDir,
152
- rootDir: compilerOptions.rootDir,
153
- mfTypePath,
154
- cb,
155
- mapExposeToEntry
156
- });
157
- if (remoteOptions.extractThirdParty) {
158
- yield thirdPartyExtractor.copyDts();
159
- }
160
- yield rm(tempTsConfigJsonPath);
161
- } catch (err) {
162
- throw err;
163
- }
164
- }), "compileTs");
165
-
166
32
  // src/server/DevServer.ts
167
33
  import WebSocket from "isomorphic-ws";
168
34
 
@@ -575,6 +441,163 @@ function createKoaServer(options) {
575
441
  }
576
442
  __name(createKoaServer, "createKoaServer");
577
443
 
444
+ // src/core/lib/typeScriptCompiler.ts
445
+ import { ensureDirSync, writeFileSync, existsSync } from "fs-extra";
446
+ import crypto from "crypto";
447
+ import { stat, readdir, writeFile, rm, readFile } from "fs/promises";
448
+ import { dirname, join, normalize, relative, resolve, sep, extname, isAbsolute } from "path";
449
+ import { getShortErrorMsg, TYPE_001, typeDescMap } from "@module-federation/error-codes";
450
+ import { ThirdPartyExtractor } from "@module-federation/third-party-dts-extractor";
451
+ import { exec } from "child_process";
452
+ import util from "util";
453
+ import { TEMP_DIR } from "@module-federation/sdk";
454
+ var STARTS_WITH_SLASH = /^\//;
455
+ var DEFINITION_FILE_EXTENSION = ".d.ts";
456
+ var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => normalize(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
457
+ var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => normalize(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
458
+ var retrieveMfAPITypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => join(retrieveOriginalOutDir(tsConfig, remoteOptions), `${remoteOptions.typesFolder}.d.ts`), "retrieveMfAPITypesPath");
459
+ function writeTempTsConfig(tsConfig, context, name, cwd) {
460
+ const createHash = /* @__PURE__ */ __name((contents) => {
461
+ return crypto.createHash("md5").update(contents).digest("hex");
462
+ }, "createHash");
463
+ const hash = createHash(`${JSON.stringify(tsConfig)}${name}${Date.now()}`);
464
+ const tempTsConfigJsonPath = resolve(cwd != null ? cwd : context, "node_modules", TEMP_DIR, `tsconfig.${hash}.json`);
465
+ ensureDirSync(dirname(tempTsConfigJsonPath));
466
+ writeFileSync(tempTsConfigJsonPath, JSON.stringify(tsConfig, null, 2));
467
+ return tempTsConfigJsonPath;
468
+ }
469
+ __name(writeTempTsConfig, "writeTempTsConfig");
470
+ var removeExt = /* @__PURE__ */ __name((f) => {
471
+ const vueExt = ".vue";
472
+ const ext = extname(f);
473
+ if (ext === vueExt) {
474
+ return f;
475
+ }
476
+ const regexPattern = new RegExp(`\\${ext}$`);
477
+ return f.replace(regexPattern, "");
478
+ }, "removeExt");
479
+ function getExposeKey(options) {
480
+ const { filePath, rootDir, outDir, mapExposeToEntry } = options;
481
+ const relativeFilePath = relative(outDir, filePath.replace(new RegExp(`\\.d.ts$`), ""));
482
+ return mapExposeToEntry[relativeFilePath];
483
+ }
484
+ __name(getExposeKey, "getExposeKey");
485
+ var processTypesFile = /* @__PURE__ */ __name((options) => __async(void 0, null, function* () {
486
+ const { outDir, filePath, rootDir, cb, mapExposeToEntry, mfTypePath } = options;
487
+ if (!existsSync(filePath)) {
488
+ return;
489
+ }
490
+ const stats = yield stat(filePath);
491
+ if (stats.isDirectory()) {
492
+ const files = yield readdir(filePath);
493
+ yield Promise.all(files.map((file) => processTypesFile(__spreadProps(__spreadValues({}, options), {
494
+ filePath: join(filePath, file)
495
+ }))));
496
+ } else if (filePath.endsWith(".d.ts")) {
497
+ const exposeKey = getExposeKey({
498
+ filePath,
499
+ rootDir,
500
+ outDir,
501
+ mapExposeToEntry
502
+ });
503
+ if (exposeKey) {
504
+ const sourceEntry = exposeKey === "." ? "index" : exposeKey;
505
+ const mfeTypeEntry = join(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
506
+ const mfeTypeEntryDirectory = dirname(mfeTypeEntry);
507
+ const relativePathToOutput = relative(mfeTypeEntryDirectory, filePath).replace(DEFINITION_FILE_EXTENSION, "").replace(STARTS_WITH_SLASH, "").split(sep).join("/");
508
+ ensureDirSync(mfeTypeEntryDirectory);
509
+ yield writeFile(mfeTypeEntry, `export * from './${relativePathToOutput}';
510
+ export { default } from './${relativePathToOutput}';`);
511
+ }
512
+ const content = yield readFile(filePath, "utf8");
513
+ cb(content);
514
+ }
515
+ }), "processTypesFile");
516
+ var getPMFromUserAgent = /* @__PURE__ */ __name(() => {
517
+ const userAgent = process.env["npm_config_user_agent"];
518
+ if (userAgent == null) {
519
+ return "null";
520
+ }
521
+ const name = userAgent.split("/")[0];
522
+ return name;
523
+ }, "getPMFromUserAgent");
524
+ var resolvePackageManagerExecutable = /* @__PURE__ */ __name(() => {
525
+ const pm = getPMFromUserAgent();
526
+ switch (pm) {
527
+ case "yarn":
528
+ return "yarn";
529
+ case "npm":
530
+ case "pnpm":
531
+ default:
532
+ return "npx";
533
+ }
534
+ }, "resolvePackageManagerExecutable");
535
+ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
536
+ var _a2, _b, _c, _d;
537
+ if (!Object.keys(mapComponentsToExpose).length) {
538
+ return;
539
+ }
540
+ const { compilerOptions } = tsConfig;
541
+ const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf", typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_b = (_a2 = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _a2.cwd) != null ? _b : void 0 : void 0);
542
+ logger.debug(`tempTsConfigJsonPath: ${tempTsConfigJsonPath}`);
543
+ try {
544
+ const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
545
+ const thirdPartyExtractor = new ThirdPartyExtractor({
546
+ destDir: resolve(mfTypePath, "node_modules"),
547
+ context: remoteOptions.context,
548
+ exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
549
+ });
550
+ const execPromise = util.promisify(exec);
551
+ const pmExecutable = resolvePackageManagerExecutable();
552
+ const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
553
+ try {
554
+ yield execPromise(cmd, {
555
+ cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
556
+ });
557
+ } catch (err) {
558
+ if (compilerOptions.tsBuildInfoFile) {
559
+ try {
560
+ yield rm(compilerOptions.tsBuildInfoFile);
561
+ } catch (e) {
562
+ }
563
+ }
564
+ throw new Error(getShortErrorMsg(TYPE_001, typeDescMap, {
565
+ cmd
566
+ }));
567
+ }
568
+ const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
569
+ const normalizedFileName = normalize(filename);
570
+ let relativeFileName = "";
571
+ if (isAbsolute(normalizedFileName)) {
572
+ relativeFileName = relative(tsConfig.compilerOptions.rootDir, normalizedFileName);
573
+ } else {
574
+ relativeFileName = relative(tsConfig.compilerOptions.rootDir, resolve(remoteOptions.context, normalizedFileName));
575
+ }
576
+ return [
577
+ removeExt(relativeFileName),
578
+ exposed
579
+ ];
580
+ }));
581
+ const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
582
+ yield processTypesFile({
583
+ outDir: compilerOptions.outDir,
584
+ filePath: compilerOptions.outDir,
585
+ rootDir: compilerOptions.rootDir,
586
+ mfTypePath,
587
+ cb,
588
+ mapExposeToEntry
589
+ });
590
+ if (remoteOptions.extractThirdParty) {
591
+ yield thirdPartyExtractor.copyDts();
592
+ }
593
+ if (remoteOptions.deleteTsConfig) {
594
+ yield rm(tempTsConfigJsonPath);
595
+ }
596
+ } catch (err) {
597
+ throw err;
598
+ }
599
+ }), "compileTs");
600
+
578
601
  // src/core/lib/archiveHandler.ts
579
602
  import AdmZip from "adm-zip";
580
603
  import { resolve as resolve3, join as join3 } from "path";
@@ -609,7 +632,8 @@ var defaultOptions = {
609
632
  abortOnError: true,
610
633
  extractRemoteTypes: false,
611
634
  extractThirdParty: false,
612
- outputDir: ""
635
+ outputDir: "",
636
+ deleteTsConfig: true
613
637
  };
614
638
  function getEffectiveRootDir(parsedCommandLine) {
615
639
  const compilerOptions = parsedCommandLine.options;
@@ -679,6 +703,9 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
679
703
  rawTsConfigJson.exclude = [];
680
704
  "references" in rawTsConfigJson && delete rawTsConfigJson.references;
681
705
  rawTsConfigJson.extends = resolvedTsConfigPath;
706
+ if (rawTsConfigJson.compilerOptions.declarationDir) {
707
+ delete rawTsConfigJson.compilerOptions.declarationDir;
708
+ }
682
709
  return rawTsConfigJson;
683
710
  }, "readTsConfig");
684
711
  var TS_EXTENSIONS = [
@@ -1286,15 +1313,12 @@ var validateOptions = /* @__PURE__ */ __name((options) => {
1286
1313
  }
1287
1314
  }, "validateOptions");
1288
1315
  function retrieveTypesAssetsInfo(options) {
1289
- const { moduleFederationConfig } = options;
1290
1316
  let apiTypesPath = "";
1291
1317
  let zipTypesPath = "";
1292
- let zipPrefix = "";
1293
1318
  try {
1294
1319
  const { tsConfig, remoteOptions, mapComponentsToExpose } = retrieveRemoteConfig(options);
1295
1320
  if (!Object.keys(mapComponentsToExpose).length || !tsConfig.files.length) {
1296
1321
  return {
1297
- zipPrefix,
1298
1322
  apiTypesPath,
1299
1323
  zipTypesPath,
1300
1324
  zipName: "",
@@ -1306,15 +1330,7 @@ function retrieveTypesAssetsInfo(options) {
1306
1330
  if (remoteOptions.generateAPITypes) {
1307
1331
  apiTypesPath = retrieveMfAPITypesPath(tsConfig, remoteOptions);
1308
1332
  }
1309
- if (typeof moduleFederationConfig.manifest === "object" && moduleFederationConfig.manifest.filePath) {
1310
- zipPrefix = moduleFederationConfig.manifest.filePath;
1311
- } else if (typeof moduleFederationConfig.manifest === "object" && moduleFederationConfig.manifest.fileName) {
1312
- zipPrefix = path3.dirname(moduleFederationConfig.manifest.fileName);
1313
- } else if (moduleFederationConfig.filename) {
1314
- zipPrefix = path3.dirname(moduleFederationConfig.filename);
1315
- }
1316
1333
  return {
1317
- zipPrefix,
1318
1334
  apiTypesPath,
1319
1335
  zipTypesPath,
1320
1336
  zipName: path3.basename(zipTypesPath),
@@ -1323,7 +1339,6 @@ function retrieveTypesAssetsInfo(options) {
1323
1339
  } catch (err) {
1324
1340
  console.error(ansiColors.red(`Unable to compile federated types, ${err}`));
1325
1341
  return {
1326
- zipPrefix,
1327
1342
  apiTypesPath: "",
1328
1343
  zipTypesPath: "",
1329
1344
  zipName: "",
@@ -1541,10 +1556,10 @@ function exposeRpc(fn) {
1541
1556
  __name(exposeRpc, "exposeRpc");
1542
1557
 
1543
1558
  export {
1544
- retrieveMfTypesPath,
1545
- retrieveOriginalOutDir,
1546
1559
  ModuleFederationDevServer,
1547
1560
  createKoaServer,
1561
+ retrieveMfTypesPath,
1562
+ retrieveOriginalOutDir,
1548
1563
  retrieveTypesZipPath,
1549
1564
  retrieveHostConfig,
1550
1565
  REMOTE_ALIAS_IDENTIFIER,
package/dist/esm/core.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  consumeTypes,
4
4
  generateTypesInChildProcess,
5
5
  rpc_exports
6
- } from "./chunk-2GDMDG2O.js";
6
+ } from "./chunk-N7GTIQUA.js";
7
7
  import {
8
8
  DTSManager,
9
9
  HOST_API_TYPES_FILE_NAME,
@@ -19,7 +19,7 @@ import {
19
19
  retrieveTypesAssetsInfo,
20
20
  retrieveTypesZipPath,
21
21
  validateOptions
22
- } from "./chunk-ETMHGGQH.js";
22
+ } from "./chunk-RWXNVNFM.js";
23
23
  import "./chunk-WWV5RWOP.js";
24
24
  import "./chunk-647HGGGS.js";
25
25
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  rpc_exports
3
- } from "./chunk-2GDMDG2O.js";
3
+ } from "./chunk-N7GTIQUA.js";
4
4
  import {
5
5
  ModuleFederationDevServer,
6
6
  createKoaServer,
@@ -9,7 +9,7 @@ import {
9
9
  retrieveMfTypesPath,
10
10
  retrieveRemoteConfig,
11
11
  retrieveTypesZipPath
12
- } from "./chunk-ETMHGGQH.js";
12
+ } from "./chunk-RWXNVNFM.js";
13
13
  import {
14
14
  fileLog,
15
15
  getIPV4
@@ -2,7 +2,7 @@ import {
2
2
  RpcGMCallTypes,
3
3
  exposeRpc,
4
4
  generateTypes
5
- } from "./chunk-ETMHGGQH.js";
5
+ } from "./chunk-RWXNVNFM.js";
6
6
  import "./chunk-WWV5RWOP.js";
7
7
  import {
8
8
  __async,
package/dist/esm/index.js CHANGED
@@ -2,14 +2,14 @@ import {
2
2
  consumeTypes,
3
3
  generateTypesInChildProcess,
4
4
  rpc_exports
5
- } from "./chunk-2GDMDG2O.js";
5
+ } from "./chunk-N7GTIQUA.js";
6
6
  import {
7
7
  cloneDeepOptions,
8
8
  generateTypes,
9
9
  isTSProject,
10
10
  retrieveTypesAssetsInfo,
11
11
  validateOptions
12
- } from "./chunk-ETMHGGQH.js";
12
+ } from "./chunk-RWXNVNFM.js";
13
13
  import {
14
14
  getIPV4,
15
15
  logger
@@ -452,23 +452,12 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
452
452
  dtsManagerOptions
453
453
  });
454
454
  logger3.debug("generate types success!");
455
- const config = dtsManagerOptions.remote.moduleFederationConfig;
456
- let zipPrefix = "";
457
- if (typeof config.manifest === "object" && config.manifest.filePath) {
458
- zipPrefix = config.manifest.filePath;
459
- } else if (typeof config.manifest === "object" && config.manifest.fileName) {
460
- zipPrefix = path5.dirname(config.manifest.fileName);
461
- } else if (config.filename) {
462
- zipPrefix = path5.dirname(config.filename);
463
- }
464
455
  if (isProd) {
465
- const zipAssetName = path5.join(zipPrefix, zipName);
466
- const apiAssetName = path5.join(zipPrefix, apiFileName);
467
- if (zipTypesPath && !compilation.getAsset(zipAssetName) && fs2.existsSync(zipTypesPath)) {
468
- compilation.emitAsset(zipAssetName, new compiler.webpack.sources.RawSource(fs2.readFileSync(zipTypesPath), false));
456
+ if (zipTypesPath && !compilation.getAsset(zipName) && fs2.existsSync(zipTypesPath)) {
457
+ compilation.emitAsset(zipName, new compiler.webpack.sources.RawSource(fs2.readFileSync(zipTypesPath), false));
469
458
  }
470
- if (apiTypesPath && !compilation.getAsset(apiAssetName) && fs2.existsSync(apiTypesPath)) {
471
- compilation.emitAsset(apiAssetName, new compiler.webpack.sources.RawSource(fs2.readFileSync(apiTypesPath), false));
459
+ if (apiTypesPath && !compilation.getAsset(apiFileName) && fs2.existsSync(apiTypesPath)) {
460
+ compilation.emitAsset(apiFileName, new compiler.webpack.sources.RawSource(fs2.readFileSync(apiTypesPath), false));
472
461
  }
473
462
  callback();
474
463
  } else {
@@ -477,7 +466,7 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
477
466
  }, "isEEXIST");
478
467
  if (zipTypesPath && fs2.existsSync(zipTypesPath)) {
479
468
  const zipContent = fs2.readFileSync(zipTypesPath);
480
- const zipOutputPath = path5.join(compiler.outputPath, zipPrefix, zipName);
469
+ const zipOutputPath = path5.join(compiler.outputPath, zipName);
481
470
  yield new Promise((resolve2, reject) => {
482
471
  compiler.outputFileSystem.mkdir(
483
472
  path5.dirname(zipOutputPath),
@@ -508,7 +497,7 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
508
497
  }
509
498
  if (apiTypesPath && fs2.existsSync(apiTypesPath)) {
510
499
  const apiContent = fs2.readFileSync(apiTypesPath);
511
- const apiOutputPath = path5.join(compiler.outputPath, zipPrefix, apiFileName);
500
+ const apiOutputPath = path5.join(compiler.outputPath, apiFileName);
512
501
  yield new Promise((resolve2, reject) => {
513
502
  compiler.outputFileSystem.mkdir(
514
503
  path5.dirname(apiOutputPath),