@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.
- package/dist/CHANGELOG.md +24 -0
- package/dist/core.d.mts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +160 -143
- package/dist/esm/{chunk-2GDMDG2O.js → chunk-N7GTIQUA.js} +1 -1
- package/dist/esm/{chunk-ETMHGGQH.js → chunk-RWXNVNFM.js} +164 -149
- package/dist/esm/core.js +2 -2
- package/dist/esm/fork-dev-worker.js +2 -2
- package/dist/esm/fork-generate-dts.js +1 -1
- package/dist/esm/index.js +8 -19
- package/dist/fork-dev-worker.js +167 -138
- package/dist/fork-generate-dts.js +160 -131
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +166 -160
- package/dist/package.json +1 -1
- package/dist/{utils-BjKKtOcx.d.ts → utils-DxGrqb9N.d.ts} +0 -1
- package/package.json +6 -6
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @module-federation/dts-plugin
|
|
2
2
|
|
|
3
|
+
## 0.21.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f8ff0d8: fix(dts-plugin): api type file should not related with manifest config
|
|
8
|
+
- 9dfcbb3: fix(dts-plugin): delete compilerOptions.declarationDir
|
|
9
|
+
- 2fc4050: feat(dts-plugin): add dts.generateTypes.deleteTsConfig field
|
|
10
|
+
- Updated dependencies [94d8868]
|
|
11
|
+
- @module-federation/sdk@0.21.5
|
|
12
|
+
- @module-federation/managers@0.21.5
|
|
13
|
+
- @module-federation/third-party-dts-extractor@0.21.5
|
|
14
|
+
- @module-federation/error-codes@0.21.5
|
|
15
|
+
|
|
16
|
+
## 0.21.4
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- d729167: Support type generation for yarn pnp enviornments
|
|
21
|
+
- Updated dependencies [a50e068]
|
|
22
|
+
- @module-federation/sdk@0.21.4
|
|
23
|
+
- @module-federation/managers@0.21.4
|
|
24
|
+
- @module-federation/third-party-dts-extractor@0.21.4
|
|
25
|
+
- @module-federation/error-codes@0.21.4
|
|
26
|
+
|
|
3
27
|
## 0.21.3
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/core.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { T as TsConfigJson } from './DTSManager-b15Gfat3.js';
|
|
2
2
|
export { D as DTSManager, r as retrieveRemoteConfig } from './DTSManager-b15Gfat3.js';
|
|
3
3
|
import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-QVchWb0x.js';
|
|
4
|
-
export { g as getDTSManagerConstructor, i as isTSProject, r as retrieveTypesAssetsInfo, v as validateOptions } from './utils-
|
|
4
|
+
export { g as getDTSManagerConstructor, i as isTSProject, r as retrieveTypesAssetsInfo, v as validateOptions } from './utils-DxGrqb9N.js';
|
|
5
5
|
import { R as RpcRemoteMethod, a as RpcCallMessage, b as RpcGMCallTypes, c as RpcMessage, d as RpcMethod, e as RpcRejectMessage, f as RpcResolveMessage, g as RpcWorker, h as createRpcWorker, i as getRpcWorkerData } from './DtsWorker-BrHsGz8C.js';
|
|
6
6
|
export { D as DtsWorker } from './DtsWorker-BrHsGz8C.js';
|
|
7
7
|
import { ChildProcess } from 'child_process';
|
package/dist/core.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { T as TsConfigJson } from './DTSManager-b15Gfat3.js';
|
|
2
2
|
export { D as DTSManager, r as retrieveRemoteConfig } from './DTSManager-b15Gfat3.js';
|
|
3
3
|
import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-QVchWb0x.js';
|
|
4
|
-
export { g as getDTSManagerConstructor, i as isTSProject, r as retrieveTypesAssetsInfo, v as validateOptions } from './utils-
|
|
4
|
+
export { g as getDTSManagerConstructor, i as isTSProject, r as retrieveTypesAssetsInfo, v as validateOptions } from './utils-DxGrqb9N.js';
|
|
5
5
|
import { R as RpcRemoteMethod, a as RpcCallMessage, b as RpcGMCallTypes, c as RpcMessage, d as RpcMethod, e as RpcRejectMessage, f as RpcResolveMessage, g as RpcWorker, h as createRpcWorker, i as getRpcWorkerData } from './DtsWorker-BrHsGz8C.js';
|
|
6
6
|
export { D as DtsWorker } from './DtsWorker-BrHsGz8C.js';
|
|
7
7
|
import { ChildProcess } from 'child_process';
|
package/dist/core.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
|
|
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,130 +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
|
|
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 compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
208
|
-
var _a3, _b, _c, _d;
|
|
209
|
-
if (!Object.keys(mapComponentsToExpose).length) {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
const { compilerOptions } = tsConfig;
|
|
213
|
-
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);
|
|
214
|
-
try {
|
|
215
|
-
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
216
|
-
const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
|
|
217
|
-
destDir: (0, import_path.resolve)(mfTypePath, "node_modules"),
|
|
218
|
-
context: remoteOptions.context,
|
|
219
|
-
exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
|
|
220
|
-
});
|
|
221
|
-
const execPromise = import_util.default.promisify(import_child_process.exec);
|
|
222
|
-
const cmd = `npx ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
|
|
223
|
-
try {
|
|
224
|
-
yield execPromise(cmd, {
|
|
225
|
-
cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
|
|
226
|
-
});
|
|
227
|
-
} catch (err) {
|
|
228
|
-
if (compilerOptions.tsBuildInfoFile) {
|
|
229
|
-
try {
|
|
230
|
-
yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
|
|
231
|
-
} catch (e) {
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
|
|
235
|
-
cmd
|
|
236
|
-
}));
|
|
237
|
-
}
|
|
238
|
-
const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
|
|
239
|
-
const normalizedFileName = (0, import_path.normalize)(filename);
|
|
240
|
-
let relativeFileName = "";
|
|
241
|
-
if ((0, import_path.isAbsolute)(normalizedFileName)) {
|
|
242
|
-
relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, normalizedFileName);
|
|
243
|
-
} else {
|
|
244
|
-
relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, (0, import_path.resolve)(remoteOptions.context, normalizedFileName));
|
|
245
|
-
}
|
|
246
|
-
return [
|
|
247
|
-
removeExt(relativeFileName),
|
|
248
|
-
exposed
|
|
249
|
-
];
|
|
250
|
-
}));
|
|
251
|
-
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
252
|
-
yield processTypesFile({
|
|
253
|
-
outDir: compilerOptions.outDir,
|
|
254
|
-
filePath: compilerOptions.outDir,
|
|
255
|
-
rootDir: compilerOptions.rootDir,
|
|
256
|
-
mfTypePath,
|
|
257
|
-
cb,
|
|
258
|
-
mapExposeToEntry
|
|
259
|
-
});
|
|
260
|
-
if (remoteOptions.extractThirdParty) {
|
|
261
|
-
yield thirdPartyExtractor.copyDts();
|
|
262
|
-
}
|
|
263
|
-
yield (0, import_promises.rm)(tempTsConfigJsonPath);
|
|
264
|
-
} catch (err) {
|
|
265
|
-
throw err;
|
|
266
|
-
}
|
|
267
|
-
}), "compileTs");
|
|
144
|
+
var import_sdk3 = require("@module-federation/sdk");
|
|
268
145
|
|
|
269
146
|
// src/server/message/Message.ts
|
|
270
147
|
var _Message = class _Message {
|
|
@@ -337,7 +214,7 @@ __name(_FetchTypesAPI, "FetchTypesAPI");
|
|
|
337
214
|
var FetchTypesAPI = _FetchTypesAPI;
|
|
338
215
|
|
|
339
216
|
// src/server/utils/index.ts
|
|
340
|
-
var
|
|
217
|
+
var import_sdk2 = require("@module-federation/sdk");
|
|
341
218
|
|
|
342
219
|
// src/server/utils/logTransform.ts
|
|
343
220
|
var import_chalk = __toESM(require("chalk"));
|
|
@@ -376,7 +253,7 @@ __name(_BrokerExitLog, "BrokerExitLog");
|
|
|
376
253
|
var BrokerExitLog = _BrokerExitLog;
|
|
377
254
|
|
|
378
255
|
// src/server/utils/log.ts
|
|
379
|
-
var
|
|
256
|
+
var import_sdk = require("@module-federation/sdk");
|
|
380
257
|
var log4js = __toESM(require("log4js"));
|
|
381
258
|
|
|
382
259
|
// src/server/constant.ts
|
|
@@ -390,7 +267,7 @@ var UpdateMode;
|
|
|
390
267
|
})(UpdateMode || (UpdateMode = {}));
|
|
391
268
|
|
|
392
269
|
// src/server/utils/log.ts
|
|
393
|
-
var logger = (0,
|
|
270
|
+
var logger = (0, import_sdk.createLogger)(`[ ${MF_SERVER_IDENTIFIER} ]`);
|
|
394
271
|
function fileLog(msg, module2, level) {
|
|
395
272
|
var _a3, _b;
|
|
396
273
|
if (!((_a3 = process == null ? void 0 : process.env) == null ? void 0 : _a3["FEDERATION_DEBUG"])) {
|
|
@@ -437,7 +314,7 @@ __name(error, "error");
|
|
|
437
314
|
// src/server/utils/index.ts
|
|
438
315
|
function getIdentifier(options) {
|
|
439
316
|
const { ip, name } = options;
|
|
440
|
-
return `mf ${
|
|
317
|
+
return `mf ${import_sdk2.SEPARATOR}${name}${ip ? `${import_sdk2.SEPARATOR}${ip}` : ""}`;
|
|
441
318
|
}
|
|
442
319
|
__name(getIdentifier, "getIdentifier");
|
|
443
320
|
|
|
@@ -1139,9 +1016,157 @@ __publicField(_Broker, "DEFAULT_WAITING_TIME", 1.5 * 60 * 60 * 1e3);
|
|
|
1139
1016
|
var Broker = _Broker;
|
|
1140
1017
|
|
|
1141
1018
|
// src/server/createKoaServer.ts
|
|
1142
|
-
var
|
|
1019
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
1143
1020
|
var import_koa = __toESM(require("koa"));
|
|
1144
1021
|
|
|
1022
|
+
// src/core/lib/typeScriptCompiler.ts
|
|
1023
|
+
var STARTS_WITH_SLASH = /^\//;
|
|
1024
|
+
var DEFINITION_FILE_EXTENSION = ".d.ts";
|
|
1025
|
+
var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
|
|
1026
|
+
var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
|
|
1027
|
+
var retrieveMfAPITypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path.join)(retrieveOriginalOutDir(tsConfig, remoteOptions), `${remoteOptions.typesFolder}.d.ts`), "retrieveMfAPITypesPath");
|
|
1028
|
+
function writeTempTsConfig(tsConfig, context, name, cwd) {
|
|
1029
|
+
const createHash = /* @__PURE__ */ __name((contents) => {
|
|
1030
|
+
return import_crypto.default.createHash("md5").update(contents).digest("hex");
|
|
1031
|
+
}, "createHash");
|
|
1032
|
+
const hash = createHash(`${JSON.stringify(tsConfig)}${name}${Date.now()}`);
|
|
1033
|
+
const tempTsConfigJsonPath = (0, import_path.resolve)(cwd != null ? cwd : context, "node_modules", import_sdk3.TEMP_DIR, `tsconfig.${hash}.json`);
|
|
1034
|
+
(0, import_fs_extra2.ensureDirSync)((0, import_path.dirname)(tempTsConfigJsonPath));
|
|
1035
|
+
(0, import_fs_extra2.writeFileSync)(tempTsConfigJsonPath, JSON.stringify(tsConfig, null, 2));
|
|
1036
|
+
return tempTsConfigJsonPath;
|
|
1037
|
+
}
|
|
1038
|
+
__name(writeTempTsConfig, "writeTempTsConfig");
|
|
1039
|
+
var removeExt = /* @__PURE__ */ __name((f) => {
|
|
1040
|
+
const vueExt = ".vue";
|
|
1041
|
+
const ext = (0, import_path.extname)(f);
|
|
1042
|
+
if (ext === vueExt) {
|
|
1043
|
+
return f;
|
|
1044
|
+
}
|
|
1045
|
+
const regexPattern = new RegExp(`\\${ext}$`);
|
|
1046
|
+
return f.replace(regexPattern, "");
|
|
1047
|
+
}, "removeExt");
|
|
1048
|
+
function getExposeKey(options) {
|
|
1049
|
+
const { filePath, rootDir, outDir, mapExposeToEntry } = options;
|
|
1050
|
+
const relativeFilePath = (0, import_path.relative)(outDir, filePath.replace(new RegExp(`\\.d.ts$`), ""));
|
|
1051
|
+
return mapExposeToEntry[relativeFilePath];
|
|
1052
|
+
}
|
|
1053
|
+
__name(getExposeKey, "getExposeKey");
|
|
1054
|
+
var processTypesFile = /* @__PURE__ */ __name((options) => __async(void 0, null, function* () {
|
|
1055
|
+
const { outDir, filePath, rootDir, cb, mapExposeToEntry, mfTypePath } = options;
|
|
1056
|
+
if (!(0, import_fs_extra2.existsSync)(filePath)) {
|
|
1057
|
+
return;
|
|
1058
|
+
}
|
|
1059
|
+
const stats = yield (0, import_promises.stat)(filePath);
|
|
1060
|
+
if (stats.isDirectory()) {
|
|
1061
|
+
const files = yield (0, import_promises.readdir)(filePath);
|
|
1062
|
+
yield Promise.all(files.map((file) => processTypesFile(__spreadProps(__spreadValues({}, options), {
|
|
1063
|
+
filePath: (0, import_path.join)(filePath, file)
|
|
1064
|
+
}))));
|
|
1065
|
+
} else if (filePath.endsWith(".d.ts")) {
|
|
1066
|
+
const exposeKey = getExposeKey({
|
|
1067
|
+
filePath,
|
|
1068
|
+
rootDir,
|
|
1069
|
+
outDir,
|
|
1070
|
+
mapExposeToEntry
|
|
1071
|
+
});
|
|
1072
|
+
if (exposeKey) {
|
|
1073
|
+
const sourceEntry = exposeKey === "." ? "index" : exposeKey;
|
|
1074
|
+
const mfeTypeEntry = (0, import_path.join)(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
|
|
1075
|
+
const mfeTypeEntryDirectory = (0, import_path.dirname)(mfeTypeEntry);
|
|
1076
|
+
const relativePathToOutput = (0, import_path.relative)(mfeTypeEntryDirectory, filePath).replace(DEFINITION_FILE_EXTENSION, "").replace(STARTS_WITH_SLASH, "").split(import_path.sep).join("/");
|
|
1077
|
+
(0, import_fs_extra2.ensureDirSync)(mfeTypeEntryDirectory);
|
|
1078
|
+
yield (0, import_promises.writeFile)(mfeTypeEntry, `export * from './${relativePathToOutput}';
|
|
1079
|
+
export { default } from './${relativePathToOutput}';`);
|
|
1080
|
+
}
|
|
1081
|
+
const content = yield (0, import_promises.readFile)(filePath, "utf8");
|
|
1082
|
+
cb(content);
|
|
1083
|
+
}
|
|
1084
|
+
}), "processTypesFile");
|
|
1085
|
+
var getPMFromUserAgent = /* @__PURE__ */ __name(() => {
|
|
1086
|
+
const userAgent = process.env["npm_config_user_agent"];
|
|
1087
|
+
if (userAgent == null) {
|
|
1088
|
+
return "null";
|
|
1089
|
+
}
|
|
1090
|
+
const name = userAgent.split("/")[0];
|
|
1091
|
+
return name;
|
|
1092
|
+
}, "getPMFromUserAgent");
|
|
1093
|
+
var resolvePackageManagerExecutable = /* @__PURE__ */ __name(() => {
|
|
1094
|
+
const pm = getPMFromUserAgent();
|
|
1095
|
+
switch (pm) {
|
|
1096
|
+
case "yarn":
|
|
1097
|
+
return "yarn";
|
|
1098
|
+
case "npm":
|
|
1099
|
+
case "pnpm":
|
|
1100
|
+
default:
|
|
1101
|
+
return "npx";
|
|
1102
|
+
}
|
|
1103
|
+
}, "resolvePackageManagerExecutable");
|
|
1104
|
+
var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
1105
|
+
var _a3, _b, _c, _d;
|
|
1106
|
+
if (!Object.keys(mapComponentsToExpose).length) {
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
const { compilerOptions } = tsConfig;
|
|
1110
|
+
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);
|
|
1111
|
+
logger.debug(`tempTsConfigJsonPath: ${tempTsConfigJsonPath}`);
|
|
1112
|
+
try {
|
|
1113
|
+
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
1114
|
+
const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
|
|
1115
|
+
destDir: (0, import_path.resolve)(mfTypePath, "node_modules"),
|
|
1116
|
+
context: remoteOptions.context,
|
|
1117
|
+
exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
|
|
1118
|
+
});
|
|
1119
|
+
const execPromise = import_util.default.promisify(import_child_process.exec);
|
|
1120
|
+
const pmExecutable = resolvePackageManagerExecutable();
|
|
1121
|
+
const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
|
|
1122
|
+
try {
|
|
1123
|
+
yield execPromise(cmd, {
|
|
1124
|
+
cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
|
|
1125
|
+
});
|
|
1126
|
+
} catch (err) {
|
|
1127
|
+
if (compilerOptions.tsBuildInfoFile) {
|
|
1128
|
+
try {
|
|
1129
|
+
yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
|
|
1130
|
+
} catch (e) {
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
|
|
1134
|
+
cmd
|
|
1135
|
+
}));
|
|
1136
|
+
}
|
|
1137
|
+
const mapExposeToEntry = Object.fromEntries(Object.entries(mapComponentsToExpose).map(([exposed, filename]) => {
|
|
1138
|
+
const normalizedFileName = (0, import_path.normalize)(filename);
|
|
1139
|
+
let relativeFileName = "";
|
|
1140
|
+
if ((0, import_path.isAbsolute)(normalizedFileName)) {
|
|
1141
|
+
relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, normalizedFileName);
|
|
1142
|
+
} else {
|
|
1143
|
+
relativeFileName = (0, import_path.relative)(tsConfig.compilerOptions.rootDir, (0, import_path.resolve)(remoteOptions.context, normalizedFileName));
|
|
1144
|
+
}
|
|
1145
|
+
return [
|
|
1146
|
+
removeExt(relativeFileName),
|
|
1147
|
+
exposed
|
|
1148
|
+
];
|
|
1149
|
+
}));
|
|
1150
|
+
const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
|
|
1151
|
+
yield processTypesFile({
|
|
1152
|
+
outDir: compilerOptions.outDir,
|
|
1153
|
+
filePath: compilerOptions.outDir,
|
|
1154
|
+
rootDir: compilerOptions.rootDir,
|
|
1155
|
+
mfTypePath,
|
|
1156
|
+
cb,
|
|
1157
|
+
mapExposeToEntry
|
|
1158
|
+
});
|
|
1159
|
+
if (remoteOptions.extractThirdParty) {
|
|
1160
|
+
yield thirdPartyExtractor.copyDts();
|
|
1161
|
+
}
|
|
1162
|
+
if (remoteOptions.deleteTsConfig) {
|
|
1163
|
+
yield (0, import_promises.rm)(tempTsConfigJsonPath);
|
|
1164
|
+
}
|
|
1165
|
+
} catch (err) {
|
|
1166
|
+
throw err;
|
|
1167
|
+
}
|
|
1168
|
+
}), "compileTs");
|
|
1169
|
+
|
|
1145
1170
|
// src/core/lib/archiveHandler.ts
|
|
1146
1171
|
var retrieveTypesZipPath = /* @__PURE__ */ __name((mfTypesPath, remoteOptions) => (0, import_path2.join)(mfTypesPath.replace(remoteOptions.typesFolder, ""), `${remoteOptions.typesFolder}.zip`), "retrieveTypesZipPath");
|
|
1147
1172
|
var createTypesArchive = /* @__PURE__ */ __name((tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
@@ -1755,15 +1780,12 @@ var validateOptions = /* @__PURE__ */ __name((options) => {
|
|
|
1755
1780
|
}
|
|
1756
1781
|
}, "validateOptions");
|
|
1757
1782
|
function retrieveTypesAssetsInfo(options) {
|
|
1758
|
-
const { moduleFederationConfig } = options;
|
|
1759
1783
|
let apiTypesPath = "";
|
|
1760
1784
|
let zipTypesPath = "";
|
|
1761
|
-
let zipPrefix = "";
|
|
1762
1785
|
try {
|
|
1763
1786
|
const { tsConfig, remoteOptions, mapComponentsToExpose } = retrieveRemoteConfig(options);
|
|
1764
1787
|
if (!Object.keys(mapComponentsToExpose).length || !tsConfig.files.length) {
|
|
1765
1788
|
return {
|
|
1766
|
-
zipPrefix,
|
|
1767
1789
|
apiTypesPath,
|
|
1768
1790
|
zipTypesPath,
|
|
1769
1791
|
zipName: "",
|
|
@@ -1775,15 +1797,7 @@ function retrieveTypesAssetsInfo(options) {
|
|
|
1775
1797
|
if (remoteOptions.generateAPITypes) {
|
|
1776
1798
|
apiTypesPath = retrieveMfAPITypesPath(tsConfig, remoteOptions);
|
|
1777
1799
|
}
|
|
1778
|
-
if (typeof moduleFederationConfig.manifest === "object" && moduleFederationConfig.manifest.filePath) {
|
|
1779
|
-
zipPrefix = moduleFederationConfig.manifest.filePath;
|
|
1780
|
-
} else if (typeof moduleFederationConfig.manifest === "object" && moduleFederationConfig.manifest.fileName) {
|
|
1781
|
-
zipPrefix = import_path4.default.dirname(moduleFederationConfig.manifest.fileName);
|
|
1782
|
-
} else if (moduleFederationConfig.filename) {
|
|
1783
|
-
zipPrefix = import_path4.default.dirname(moduleFederationConfig.filename);
|
|
1784
|
-
}
|
|
1785
1800
|
return {
|
|
1786
|
-
zipPrefix,
|
|
1787
1801
|
apiTypesPath,
|
|
1788
1802
|
zipTypesPath,
|
|
1789
1803
|
zipName: import_path4.default.basename(zipTypesPath),
|
|
@@ -1792,7 +1806,6 @@ function retrieveTypesAssetsInfo(options) {
|
|
|
1792
1806
|
} catch (err) {
|
|
1793
1807
|
console.error(import_ansi_colors.default.red(`Unable to compile federated types, ${err}`));
|
|
1794
1808
|
return {
|
|
1795
|
-
zipPrefix,
|
|
1796
1809
|
apiTypesPath: "",
|
|
1797
1810
|
zipTypesPath: "",
|
|
1798
1811
|
zipName: "",
|
|
@@ -1885,7 +1898,8 @@ var defaultOptions2 = {
|
|
|
1885
1898
|
abortOnError: true,
|
|
1886
1899
|
extractRemoteTypes: false,
|
|
1887
1900
|
extractThirdParty: false,
|
|
1888
|
-
outputDir: ""
|
|
1901
|
+
outputDir: "",
|
|
1902
|
+
deleteTsConfig: true
|
|
1889
1903
|
};
|
|
1890
1904
|
function getEffectiveRootDir(parsedCommandLine) {
|
|
1891
1905
|
const compilerOptions = parsedCommandLine.options;
|
|
@@ -1955,6 +1969,9 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
|
|
|
1955
1969
|
rawTsConfigJson.exclude = [];
|
|
1956
1970
|
"references" in rawTsConfigJson && delete rawTsConfigJson.references;
|
|
1957
1971
|
rawTsConfigJson.extends = resolvedTsConfigPath;
|
|
1972
|
+
if (rawTsConfigJson.compilerOptions.declarationDir) {
|
|
1973
|
+
delete rawTsConfigJson.compilerOptions.declarationDir;
|
|
1974
|
+
}
|
|
1958
1975
|
return rawTsConfigJson;
|
|
1959
1976
|
}, "readTsConfig");
|
|
1960
1977
|
var TS_EXTENSIONS = [
|