@module-federation/dts-plugin 0.2.0 → 0.2.2

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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @module-federation/dts-plugin
2
2
 
3
+ ## 0.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 7d09ed8: Emit DTS relative to remote entry location
8
+ - @module-federation/sdk@0.2.2
9
+ - @module-federation/managers@0.2.2
10
+ - @module-federation/third-party-dts-extractor@0.2.2
11
+
12
+ ## 0.2.1
13
+
14
+ ### Patch Changes
15
+
16
+ - 88445e7: Support getPublicPath in compiler plugins
17
+ - Updated dependencies [88445e7]
18
+ - @module-federation/sdk@0.2.1
19
+ - @module-federation/managers@0.2.1
20
+ - @module-federation/third-party-dts-extractor@0.2.1
21
+
3
22
  ## 0.2.0
4
23
 
5
24
  ### Patch Changes
package/dist/core.js CHANGED
@@ -1339,7 +1339,17 @@ var DTSManager = (_a = class {
1339
1339
  }
1340
1340
  return u;
1341
1341
  }, "addProtocol");
1342
- let publicPath = "publicPath" in manifestJson.metaData ? manifestJson.metaData.publicPath : new Function(manifestJson.metaData.getPublicPath)();
1342
+ let publicPath;
1343
+ if ("publicPath" in manifestJson.metaData) {
1344
+ publicPath = manifestJson.metaData.publicPath;
1345
+ } else {
1346
+ const getPublicPath = new Function(manifestJson.metaData.getPublicPath);
1347
+ if (manifestJson.metaData.getPublicPath.startsWith("function")) {
1348
+ publicPath = getPublicPath()();
1349
+ } else {
1350
+ publicPath = getPublicPath();
1351
+ }
1352
+ }
1343
1353
  if (publicPath === "auto") {
1344
1354
  publicPath = (0, import_sdk4.inferAutoPublicPath)(remoteInfo.url);
1345
1355
  }
@@ -1668,7 +1668,17 @@ var DTSManager = (_a = class {
1668
1668
  }
1669
1669
  return u;
1670
1670
  }, "addProtocol");
1671
- let publicPath = "publicPath" in manifestJson.metaData ? manifestJson.metaData.publicPath : new Function(manifestJson.metaData.getPublicPath)();
1671
+ let publicPath;
1672
+ if ("publicPath" in manifestJson.metaData) {
1673
+ publicPath = manifestJson.metaData.publicPath;
1674
+ } else {
1675
+ const getPublicPath = new Function(manifestJson.metaData.getPublicPath);
1676
+ if (manifestJson.metaData.getPublicPath.startsWith("function")) {
1677
+ publicPath = getPublicPath()();
1678
+ } else {
1679
+ publicPath = getPublicPath();
1680
+ }
1681
+ }
1672
1682
  if (publicPath === "auto") {
1673
1683
  publicPath = inferAutoPublicPath(remoteInfo.url);
1674
1684
  }
package/dist/esm/core.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  retrieveTypesZipPath,
15
15
  rpc_exports,
16
16
  validateOptions
17
- } from "./chunk-DQ2CDTSN.js";
17
+ } from "./chunk-CRKFI32N.js";
18
18
  import {
19
19
  HOST_API_TYPES_FILE_NAME,
20
20
  REMOTE_ALIAS_IDENTIFIER,
@@ -9,7 +9,7 @@ import {
9
9
  retrieveRemoteConfig,
10
10
  retrieveTypesZipPath,
11
11
  rpc_exports
12
- } from "./chunk-DQ2CDTSN.js";
12
+ } from "./chunk-CRKFI32N.js";
13
13
  import {
14
14
  getIpFromEntry
15
15
  } from "./chunk-G7ONFBMA.js";
@@ -2,7 +2,7 @@ import {
2
2
  RpcGMCallTypes,
3
3
  exposeRpc,
4
4
  generateTypes
5
- } from "./chunk-DQ2CDTSN.js";
5
+ } from "./chunk-CRKFI32N.js";
6
6
  import {
7
7
  __async,
8
8
  __name
package/dist/esm/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  retrieveTypesAssetsInfo,
8
8
  rpc_exports,
9
9
  validateOptions
10
- } from "./chunk-DQ2CDTSN.js";
10
+ } from "./chunk-CRKFI32N.js";
11
11
  import {
12
12
  WEB_CLIENT_OPTIONS_IDENTIFIER,
13
13
  __async,
@@ -283,6 +283,7 @@ var ConsumeTypesPlugin = _ConsumeTypesPlugin;
283
283
  // packages/dts-plugin/src/plugins/GenerateTypesPlugin.ts
284
284
  import fs2 from "fs";
285
285
  import { normalizeOptions as normalizeOptions3 } from "@module-federation/sdk";
286
+ import path4 from "path";
286
287
  var _GenerateTypesPlugin = class _GenerateTypesPlugin {
287
288
  constructor(pluginOptions, dtsOptions, defaultOptions) {
288
289
  __publicField(this, "pluginOptions");
@@ -338,11 +339,21 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
338
339
  return;
339
340
  }
340
341
  yield generateTypesFn(finalOptions);
342
+ const config = finalOptions.remote.moduleFederationConfig;
343
+ let zipPrefix = "";
344
+ const isManifestObject = typeof config.manifest === "object";
345
+ if (isManifestObject && config.manifest.filePath) {
346
+ zipPrefix = config.manifest.filePath;
347
+ } else if (isManifestObject && config.manifest.fileName) {
348
+ zipPrefix = path4.dirname(config.manifest.fileName);
349
+ } else if (config.filename) {
350
+ zipPrefix = path4.dirname(config.filename);
351
+ }
341
352
  if (zipTypesPath) {
342
- compilation.emitAsset(zipName, new compiler.webpack.sources.RawSource(fs2.readFileSync(zipTypesPath), false));
353
+ compilation.emitAsset(path4.join(zipPrefix, zipName), new compiler.webpack.sources.RawSource(fs2.readFileSync(zipTypesPath), false));
343
354
  }
344
355
  if (apiTypesPath) {
345
- compilation.emitAsset(apiFileName, new compiler.webpack.sources.RawSource(fs2.readFileSync(apiTypesPath), false));
356
+ compilation.emitAsset(path4.join(zipPrefix, apiFileName), new compiler.webpack.sources.RawSource(fs2.readFileSync(apiTypesPath), false));
346
357
  }
347
358
  } catch (err) {
348
359
  console.error(err);
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Broker,
3
3
  fileLog
4
- } from "./chunk-DQ2CDTSN.js";
4
+ } from "./chunk-CRKFI32N.js";
5
5
  import {
6
6
  __async,
7
7
  __name
@@ -1848,7 +1848,17 @@ var DTSManager = (_a = class {
1848
1848
  }
1849
1849
  return u;
1850
1850
  }, "addProtocol");
1851
- let publicPath = "publicPath" in manifestJson.metaData ? manifestJson.metaData.publicPath : new Function(manifestJson.metaData.getPublicPath)();
1851
+ let publicPath;
1852
+ if ("publicPath" in manifestJson.metaData) {
1853
+ publicPath = manifestJson.metaData.publicPath;
1854
+ } else {
1855
+ const getPublicPath = new Function(manifestJson.metaData.getPublicPath);
1856
+ if (manifestJson.metaData.getPublicPath.startsWith("function")) {
1857
+ publicPath = getPublicPath()();
1858
+ } else {
1859
+ publicPath = getPublicPath();
1860
+ }
1861
+ }
1852
1862
  if (publicPath === "auto") {
1853
1863
  publicPath = (0, import_sdk4.inferAutoPublicPath)(remoteInfo.url);
1854
1864
  }
@@ -1630,7 +1630,17 @@ var DTSManager = (_a2 = class {
1630
1630
  }
1631
1631
  return u;
1632
1632
  }, "addProtocol");
1633
- let publicPath = "publicPath" in manifestJson.metaData ? manifestJson.metaData.publicPath : new Function(manifestJson.metaData.getPublicPath)();
1633
+ let publicPath;
1634
+ if ("publicPath" in manifestJson.metaData) {
1635
+ publicPath = manifestJson.metaData.publicPath;
1636
+ } else {
1637
+ const getPublicPath = new Function(manifestJson.metaData.getPublicPath);
1638
+ if (manifestJson.metaData.getPublicPath.startsWith("function")) {
1639
+ publicPath = getPublicPath()();
1640
+ } else {
1641
+ publicPath = getPublicPath();
1642
+ }
1643
+ }
1634
1644
  if (publicPath === "auto") {
1635
1645
  publicPath = (0, import_sdk4.inferAutoPublicPath)(remoteInfo.url);
1636
1646
  }
package/dist/index.js CHANGED
@@ -1362,7 +1362,17 @@ var DTSManager = (_a = class {
1362
1362
  }
1363
1363
  return u;
1364
1364
  }, "addProtocol");
1365
- let publicPath = "publicPath" in manifestJson.metaData ? manifestJson.metaData.publicPath : new Function(manifestJson.metaData.getPublicPath)();
1365
+ let publicPath;
1366
+ if ("publicPath" in manifestJson.metaData) {
1367
+ publicPath = manifestJson.metaData.publicPath;
1368
+ } else {
1369
+ const getPublicPath = new Function(manifestJson.metaData.getPublicPath);
1370
+ if (manifestJson.metaData.getPublicPath.startsWith("function")) {
1371
+ publicPath = getPublicPath()();
1372
+ } else {
1373
+ publicPath = getPublicPath();
1374
+ }
1375
+ }
1366
1376
  if (publicPath === "auto") {
1367
1377
  publicPath = (0, import_sdk4.inferAutoPublicPath)(remoteInfo.url);
1368
1378
  }
@@ -2319,6 +2329,7 @@ var ConsumeTypesPlugin = _ConsumeTypesPlugin;
2319
2329
  // packages/dts-plugin/src/plugins/GenerateTypesPlugin.ts
2320
2330
  var import_fs4 = __toESM(require("fs"));
2321
2331
  var import_sdk7 = require("@module-federation/sdk");
2332
+ var import_path9 = __toESM(require("path"));
2322
2333
  var _GenerateTypesPlugin = class _GenerateTypesPlugin {
2323
2334
  constructor(pluginOptions, dtsOptions, defaultOptions3) {
2324
2335
  __publicField(this, "pluginOptions");
@@ -2374,11 +2385,21 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
2374
2385
  return;
2375
2386
  }
2376
2387
  yield generateTypesFn(finalOptions);
2388
+ const config = finalOptions.remote.moduleFederationConfig;
2389
+ let zipPrefix = "";
2390
+ const isManifestObject = typeof config.manifest === "object";
2391
+ if (isManifestObject && config.manifest.filePath) {
2392
+ zipPrefix = config.manifest.filePath;
2393
+ } else if (isManifestObject && config.manifest.fileName) {
2394
+ zipPrefix = import_path9.default.dirname(config.manifest.fileName);
2395
+ } else if (config.filename) {
2396
+ zipPrefix = import_path9.default.dirname(config.filename);
2397
+ }
2377
2398
  if (zipTypesPath) {
2378
- compilation.emitAsset(zipName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(zipTypesPath), false));
2399
+ compilation.emitAsset(import_path9.default.join(zipPrefix, zipName), new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(zipTypesPath), false));
2379
2400
  }
2380
2401
  if (apiTypesPath) {
2381
- compilation.emitAsset(apiFileName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(apiTypesPath), false));
2402
+ compilation.emitAsset(import_path9.default.join(zipPrefix, apiFileName), new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(apiTypesPath), false));
2382
2403
  }
2383
2404
  } catch (err) {
2384
2405
  console.error(err);
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/dts-plugin",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "author": "hanric <hanric.zhang@gmail.com>",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/dts-plugin",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "author": "hanric <hanric.zhang@gmail.com>",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -55,15 +55,15 @@
55
55
  "log4js": "6.9.1",
56
56
  "node-schedule": "2.1.1",
57
57
  "ws": "8.17.1",
58
- "@module-federation/sdk": "0.2.0",
59
- "@module-federation/managers": "0.2.0",
60
- "@module-federation/third-party-dts-extractor": "0.2.0"
58
+ "@module-federation/sdk": "0.2.2",
59
+ "@module-federation/managers": "0.2.2",
60
+ "@module-federation/third-party-dts-extractor": "0.2.2"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/ws": "8.5.10",
64
64
  "@types/koa": "2.11.2",
65
65
  "@types/node-schedule": "2.1.7",
66
- "@module-federation/runtime": "0.2.0"
66
+ "@module-federation/runtime": "0.2.2"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "typescript": "^4.9.0 || ^5.0.0",