@softarc/native-federation 3.5.1 → 4.0.0-RC1

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.
Files changed (187) hide show
  1. package/package.json +33 -5
  2. package/src/config.d.ts +5 -1
  3. package/src/config.d.ts.map +1 -0
  4. package/src/config.js +4 -6
  5. package/src/domain.d.ts +3 -0
  6. package/src/domain.d.ts.map +1 -0
  7. package/src/domain.js +2 -0
  8. package/src/index.d.ts +9 -1
  9. package/src/index.d.ts.map +1 -0
  10. package/src/index.js +8 -5
  11. package/src/internal.d.ts +12 -0
  12. package/src/internal.d.ts.map +1 -0
  13. package/src/internal.js +8 -0
  14. package/src/lib/config/configuration-context.d.ts +1 -0
  15. package/src/lib/config/configuration-context.d.ts.map +1 -0
  16. package/src/lib/config/configuration-context.js +3 -9
  17. package/src/lib/config/default-skip-list.d.ts +5 -0
  18. package/src/lib/config/default-skip-list.d.ts.map +1 -0
  19. package/src/lib/{core → config}/default-skip-list.js +10 -16
  20. package/src/lib/config/share-utils.d.ts +7 -17
  21. package/src/lib/config/share-utils.d.ts.map +1 -0
  22. package/src/lib/config/share-utils.js +50 -123
  23. package/src/lib/config/with-native-federation.d.ts +2 -1
  24. package/src/lib/config/with-native-federation.d.ts.map +1 -0
  25. package/src/lib/config/with-native-federation.js +16 -20
  26. package/src/lib/core/build-adapter.d.ts +4 -28
  27. package/src/lib/core/build-adapter.d.ts.map +1 -0
  28. package/src/lib/core/build-adapter.js +4 -9
  29. package/src/lib/core/build-for-federation.d.ts +5 -8
  30. package/src/lib/core/build-for-federation.d.ts.map +1 -0
  31. package/src/lib/core/build-for-federation.js +38 -45
  32. package/src/lib/core/bundle-exposed-and-mappings.d.ts +4 -7
  33. package/src/lib/core/bundle-exposed-and-mappings.d.ts.map +1 -0
  34. package/src/lib/core/bundle-exposed-and-mappings.js +32 -42
  35. package/src/lib/core/bundle-shared.d.ts +6 -4
  36. package/src/lib/core/bundle-shared.d.ts.map +1 -0
  37. package/src/lib/core/bundle-shared.js +57 -64
  38. package/src/lib/core/default-external-list.d.ts +1 -0
  39. package/src/lib/core/default-external-list.d.ts.map +1 -0
  40. package/src/lib/core/default-external-list.js +1 -5
  41. package/src/lib/core/default-server-deps-list.d.ts +1 -0
  42. package/src/lib/core/default-server-deps-list.d.ts.map +1 -0
  43. package/src/lib/core/default-server-deps-list.js +2 -6
  44. package/src/lib/core/federation-builder.d.ts +7 -6
  45. package/src/lib/core/federation-builder.d.ts.map +1 -0
  46. package/src/lib/core/federation-builder.js +14 -19
  47. package/src/lib/core/get-externals.d.ts +2 -1
  48. package/src/lib/core/get-externals.d.ts.map +1 -0
  49. package/src/lib/core/get-externals.js +2 -6
  50. package/src/lib/core/load-federation-config.d.ts +3 -2
  51. package/src/lib/core/load-federation-config.d.ts.map +1 -0
  52. package/src/lib/core/load-federation-config.js +6 -12
  53. package/src/lib/core/remove-unused-deps.d.ts +2 -1
  54. package/src/lib/core/remove-unused-deps.d.ts.map +1 -0
  55. package/src/lib/core/remove-unused-deps.js +21 -29
  56. package/src/lib/core/write-federation-info.d.ts +3 -2
  57. package/src/lib/core/write-federation-info.d.ts.map +1 -0
  58. package/src/lib/core/write-federation-info.js +3 -8
  59. package/src/lib/core/write-import-map.d.ts +3 -2
  60. package/src/lib/core/write-import-map.d.ts.map +1 -0
  61. package/src/lib/core/write-import-map.js +3 -8
  62. package/src/lib/domain/config/external-config.contract.d.ts +40 -0
  63. package/src/lib/domain/config/external-config.contract.d.ts.map +1 -0
  64. package/src/lib/domain/config/external-config.contract.js +1 -0
  65. package/src/lib/domain/config/federation-config.contract.d.ts +28 -0
  66. package/src/lib/domain/config/federation-config.contract.d.ts.map +1 -0
  67. package/src/lib/domain/config/federation-config.contract.js +1 -0
  68. package/src/lib/domain/config/index.d.ts +4 -0
  69. package/src/lib/domain/config/index.d.ts.map +1 -0
  70. package/src/lib/domain/config/index.js +1 -0
  71. package/src/lib/{core/default-skip-list.d.ts → domain/config/skip-list.contract.d.ts} +1 -3
  72. package/src/lib/domain/config/skip-list.contract.d.ts.map +1 -0
  73. package/src/lib/domain/config/skip-list.contract.js +1 -0
  74. package/src/lib/domain/core/build-adapter.contract.d.ts +28 -0
  75. package/src/lib/domain/core/build-adapter.contract.d.ts.map +1 -0
  76. package/src/lib/domain/core/build-adapter.contract.js +1 -0
  77. package/src/lib/domain/core/build-notification-options.contract.d.ts +10 -0
  78. package/src/lib/domain/core/build-notification-options.contract.d.ts.map +1 -0
  79. package/src/lib/domain/core/build-notification-options.contract.js +6 -0
  80. package/src/lib/domain/core/build-params.contract.d.ts +6 -0
  81. package/src/lib/domain/core/build-params.contract.d.ts.map +1 -0
  82. package/src/lib/domain/core/build-params.contract.js +1 -0
  83. package/src/lib/domain/core/federation-info.contract.d.ts +29 -0
  84. package/src/lib/domain/core/federation-info.contract.d.ts.map +1 -0
  85. package/src/lib/domain/core/federation-info.contract.js +1 -0
  86. package/src/lib/{core/federation-options.d.ts → domain/core/federation-options.contract.d.ts} +2 -1
  87. package/src/lib/domain/core/federation-options.contract.d.ts.map +1 -0
  88. package/src/lib/domain/core/federation-options.contract.js +1 -0
  89. package/src/lib/domain/core/index.d.ts +6 -0
  90. package/src/lib/domain/core/index.d.ts.map +1 -0
  91. package/src/lib/domain/core/index.js +1 -0
  92. package/src/lib/domain/utils/index.d.ts +3 -0
  93. package/src/lib/domain/utils/index.d.ts.map +1 -0
  94. package/src/lib/domain/utils/index.js +1 -0
  95. package/src/lib/domain/utils/keyvaluepair.contract.d.ts +5 -0
  96. package/src/lib/domain/utils/keyvaluepair.contract.d.ts.map +1 -0
  97. package/src/lib/domain/utils/keyvaluepair.contract.js +1 -0
  98. package/src/lib/domain/utils/mapped-path.contract.d.ts +5 -0
  99. package/src/lib/domain/utils/mapped-path.contract.d.ts.map +1 -0
  100. package/src/lib/domain/utils/mapped-path.contract.js +1 -0
  101. package/src/lib/utils/build-result-map.d.ts +3 -2
  102. package/src/lib/utils/build-result-map.d.ts.map +1 -0
  103. package/src/lib/utils/build-result-map.js +5 -11
  104. package/src/lib/utils/build-utils.d.ts +3 -2
  105. package/src/lib/utils/build-utils.d.ts.map +1 -0
  106. package/src/lib/utils/build-utils.js +3 -7
  107. package/src/lib/utils/bundle-caching.d.ts +4 -3
  108. package/src/lib/utils/bundle-caching.d.ts.map +1 -0
  109. package/src/lib/utils/bundle-caching.js +35 -47
  110. package/src/lib/utils/errors.d.ts +1 -0
  111. package/src/lib/utils/errors.d.ts.map +1 -0
  112. package/src/lib/utils/errors.js +1 -6
  113. package/src/lib/utils/get-external-imports.d.ts +1 -0
  114. package/src/lib/utils/get-external-imports.d.ts.map +1 -0
  115. package/src/lib/utils/get-external-imports.js +5 -10
  116. package/src/lib/utils/hash-file.d.ts +1 -0
  117. package/src/lib/utils/hash-file.d.ts.map +1 -0
  118. package/src/lib/utils/hash-file.js +3 -8
  119. package/src/lib/utils/logger.d.ts +1 -0
  120. package/src/lib/utils/logger.d.ts.map +1 -0
  121. package/src/lib/utils/logger.js +10 -16
  122. package/src/lib/utils/mapped-paths.d.ts +2 -4
  123. package/src/lib/utils/mapped-paths.d.ts.map +1 -0
  124. package/src/lib/utils/mapped-paths.js +4 -9
  125. package/src/lib/utils/normalize.d.ts +1 -0
  126. package/src/lib/utils/normalize.d.ts.map +1 -0
  127. package/src/lib/utils/normalize.js +2 -7
  128. package/src/lib/utils/package-info.d.ts +1 -0
  129. package/src/lib/utils/package-info.d.ts.map +1 -0
  130. package/src/lib/utils/package-info.js +36 -47
  131. package/src/lib/utils/rebuild-queue.d.ts +1 -0
  132. package/src/lib/utils/rebuild-queue.d.ts.map +1 -0
  133. package/src/lib/utils/rebuild-queue.js +5 -10
  134. package/src/lib/utils/resolve-glob.d.ts +1 -0
  135. package/src/lib/utils/resolve-glob.d.ts.map +1 -0
  136. package/src/lib/utils/resolve-glob.js +3 -8
  137. package/src/lib/utils/resolve-wildcard-keys.d.ts +2 -4
  138. package/src/lib/utils/resolve-wildcard-keys.d.ts.map +1 -0
  139. package/src/lib/utils/resolve-wildcard-keys.js +3 -8
  140. package/src/lib/utils/rewrite-chunk-imports.d.ts +1 -0
  141. package/src/lib/utils/rewrite-chunk-imports.d.ts.map +1 -0
  142. package/src/lib/utils/rewrite-chunk-imports.js +13 -22
  143. package/LICENSE +0 -8
  144. package/README.md +0 -509
  145. package/build.d.ts +0 -1
  146. package/build.js +0 -5
  147. package/build.js.map +0 -1
  148. package/src/build.d.ts +0 -19
  149. package/src/build.js +0 -38
  150. package/src/build.js.map +0 -1
  151. package/src/config.js.map +0 -1
  152. package/src/index.js.map +0 -1
  153. package/src/lib/config/configuration-context.js.map +0 -1
  154. package/src/lib/config/federation-config.d.ts +0 -55
  155. package/src/lib/config/federation-config.js +0 -3
  156. package/src/lib/config/federation-config.js.map +0 -1
  157. package/src/lib/config/share-utils.js.map +0 -1
  158. package/src/lib/config/with-native-federation.js.map +0 -1
  159. package/src/lib/core/build-adapter.js.map +0 -1
  160. package/src/lib/core/build-for-federation.js.map +0 -1
  161. package/src/lib/core/bundle-exposed-and-mappings.js.map +0 -1
  162. package/src/lib/core/bundle-shared.js.map +0 -1
  163. package/src/lib/core/default-external-list.js.map +0 -1
  164. package/src/lib/core/default-server-deps-list.js.map +0 -1
  165. package/src/lib/core/default-skip-list.js.map +0 -1
  166. package/src/lib/core/federation-builder.js.map +0 -1
  167. package/src/lib/core/federation-options.js +0 -3
  168. package/src/lib/core/federation-options.js.map +0 -1
  169. package/src/lib/core/get-externals.js.map +0 -1
  170. package/src/lib/core/load-federation-config.js.map +0 -1
  171. package/src/lib/core/remove-unused-deps.js.map +0 -1
  172. package/src/lib/core/write-federation-info.js.map +0 -1
  173. package/src/lib/core/write-import-map.js.map +0 -1
  174. package/src/lib/utils/build-result-map.js.map +0 -1
  175. package/src/lib/utils/build-utils.js.map +0 -1
  176. package/src/lib/utils/bundle-caching.js.map +0 -1
  177. package/src/lib/utils/errors.js.map +0 -1
  178. package/src/lib/utils/get-external-imports.js.map +0 -1
  179. package/src/lib/utils/hash-file.js.map +0 -1
  180. package/src/lib/utils/logger.js.map +0 -1
  181. package/src/lib/utils/mapped-paths.js.map +0 -1
  182. package/src/lib/utils/normalize.js.map +0 -1
  183. package/src/lib/utils/package-info.js.map +0 -1
  184. package/src/lib/utils/rebuild-queue.js.map +0 -1
  185. package/src/lib/utils/resolve-glob.js.map +0 -1
  186. package/src/lib/utils/resolve-wildcard-keys.js.map +0 -1
  187. package/src/lib/utils/rewrite-chunk-imports.js.map +0 -1
@@ -1,10 +1,8 @@
1
- export interface MappedPath {
2
- key: string;
3
- path: string;
4
- }
1
+ import type { MappedPath } from '../domain/utils/mapped-path.contract.js';
5
2
  export interface GetMappedPathsOptions {
6
3
  rootTsConfigPath: string;
7
4
  sharedMappings?: string[];
8
5
  rootPath?: string;
9
6
  }
10
7
  export declare function getMappedPaths({ rootTsConfigPath, sharedMappings, rootPath, }: GetMappedPathsOptions): Array<MappedPath>;
8
+ //# sourceMappingURL=mapped-paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapped-paths.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/mapped-paths.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAE1E,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,cAAc,CAAC,EAC7B,gBAAgB,EAChB,cAAc,EACd,QAAQ,GACT,EAAE,qBAAqB,GAAG,KAAK,CAAC,UAAU,CAAC,CAoC3C"}
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMappedPaths = getMappedPaths;
4
- const tslib_1 = require("tslib");
5
- const path = tslib_1.__importStar(require("path"));
6
- const fs = tslib_1.__importStar(require("fs"));
7
- const JSON5 = tslib_1.__importStar(require("json5"));
8
- function getMappedPaths({ rootTsConfigPath, sharedMappings, rootPath, }) {
1
+ import * as path from 'path';
2
+ import * as fs from 'fs';
3
+ import JSON5 from 'json5';
4
+ export function getMappedPaths({ rootTsConfigPath, sharedMappings, rootPath, }) {
9
5
  const result = [];
10
6
  if (!path.isAbsolute(rootTsConfigPath)) {
11
7
  throw new Error('SharedMappings.register: tsConfigPath needs to be an absolute path!');
@@ -33,4 +29,3 @@ function getMappedPaths({ rootTsConfigPath, sharedMappings, rootPath, }) {
33
29
  }
34
30
  return result;
35
31
  }
36
- //# sourceMappingURL=mapped-paths.js.map
@@ -1,2 +1,3 @@
1
1
  export declare function normalize(path: string, trailingSlash?: boolean): string;
2
2
  export declare function normalizePackageName(fileName: string): string;
3
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/normalize.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,CAgBvE;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,UAGpD"}
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalize = normalize;
4
- exports.normalizePackageName = normalizePackageName;
5
- function normalize(path, trailingSlash) {
1
+ export function normalize(path, trailingSlash) {
6
2
  let cand = path.replace(/\\/g, '/');
7
3
  if (typeof trailingSlash === 'undefined') {
8
4
  return cand;
@@ -15,8 +11,7 @@ function normalize(path, trailingSlash) {
15
11
  }
16
12
  return cand;
17
13
  }
18
- function normalizePackageName(fileName) {
14
+ export function normalizePackageName(fileName) {
19
15
  const sanitized = fileName.replace(/[^A-Za-z0-9]/g, '_');
20
16
  return sanitized.startsWith('_') ? sanitized.slice(1) : sanitized;
21
17
  }
22
- //# sourceMappingURL=normalize.js.map
@@ -28,3 +28,4 @@ export declare function getVersionMaps(project: string, workspace: string): Vers
28
28
  export declare function getPackageJsonFiles(project: string, workspace: string): PackageJsonInfo[];
29
29
  export declare function findDepPackageJson(packageName: string, projectRoot: string): string | null;
30
30
  export declare function _getPackageInfo(packageName: string, directory: string): PackageInfo | null;
31
+ //# sourceMappingURL=package-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-info.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/package-info.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,OAAO,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,GAAG,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,eAAe,GACvB,QAAQ,GACR,SAAS,GACT,MAAM,GACN,KAAK,GACL,KAAK,GACL,SAAS,GACT,OAAO,GACP,SAAS,GACT,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,eAAO,MAAM,WAAW,GAAI,GAAG,MAAM,KAAG,OAAO,GAAG,SAWjD,CAAC;AACF,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,SAAS,GACT;KAAG,GAAG,IAAI,eAAe,CAAC,CAAC,EAAE,WAAW;CAAE,GAC1C,WAAW,EAAE,CAAC;AAElB,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,WAAW,GAAG;IAAE,CAAC,IAAI,EAAE,IAAI,MAAM,EAAE,GAAG,WAAW,CAAA;CAAE,CAAC;AAI9F,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAIjF;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAsBrE;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAc7F;AAMD,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,CAI/E;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,eAAe,EAAE,CAqBzF;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA6B1F;AAiDD,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAoI1F"}
@@ -1,19 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isESMExport = void 0;
4
- exports.findPackageJsonFiles = findPackageJsonFiles;
5
- exports.expandFolders = expandFolders;
6
- exports.getPackageInfo = getPackageInfo;
7
- exports.getVersionMaps = getVersionMaps;
8
- exports.getPackageJsonFiles = getPackageJsonFiles;
9
- exports.findDepPackageJson = findDepPackageJson;
10
- exports._getPackageInfo = _getPackageInfo;
11
- const tslib_1 = require("tslib");
12
- const fs = tslib_1.__importStar(require("fs"));
13
- const path = tslib_1.__importStar(require("path"));
14
- const logger_1 = require("./logger");
15
- const normalize_1 = require("./normalize");
16
- const isESMExport = (e) => {
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { logger } from './logger.js';
4
+ import { normalize } from './normalize.js';
5
+ export const isESMExport = (e) => {
17
6
  if (e === 'import' || e === 'module-sync')
18
7
  return true;
19
8
  // Common ESM conventions
@@ -27,24 +16,23 @@ const isESMExport = (e) => {
27
16
  // Ambiguous
28
17
  return undefined;
29
18
  };
30
- exports.isESMExport = isESMExport;
31
19
  const packageCache = {};
32
- function findPackageJsonFiles(project, workspace) {
20
+ export function findPackageJsonFiles(project, workspace) {
33
21
  return expandFolders(project, workspace)
34
- .map((f) => path.join(f, 'package.json'))
35
- .filter((f) => fs.existsSync(f));
22
+ .map(f => path.join(f, 'package.json'))
23
+ .filter(f => fs.existsSync(f));
36
24
  }
37
- function expandFolders(child, parent) {
25
+ export function expandFolders(child, parent) {
38
26
  const result = [];
39
- parent = (0, normalize_1.normalize)(parent, true);
40
- child = (0, normalize_1.normalize)(child, true);
27
+ parent = normalize(parent, true);
28
+ child = normalize(child, true);
41
29
  if (!child.startsWith(parent)) {
42
30
  throw new Error(`Workspace folder ${path} needs to be a parent of the project folder ${child}`);
43
31
  }
44
32
  let current = child;
45
33
  while (current !== parent) {
46
34
  result.push(current);
47
- const cand = (0, normalize_1.normalize)(path.dirname(current), true);
35
+ const cand = normalize(path.dirname(current), true);
48
36
  if (cand === current) {
49
37
  break;
50
38
  }
@@ -53,8 +41,8 @@ function expandFolders(child, parent) {
53
41
  result.push(parent);
54
42
  return result;
55
43
  }
56
- function getPackageInfo(packageName, workspaceRoot) {
57
- workspaceRoot = (0, normalize_1.normalize)(workspaceRoot, true);
44
+ export function getPackageInfo(packageName, workspaceRoot) {
45
+ workspaceRoot = normalize(workspaceRoot, true);
58
46
  const packageJsonInfos = getPackageJsonFiles(workspaceRoot, workspaceRoot);
59
47
  for (const info of packageJsonInfos) {
60
48
  const cand = _getPackageInfo(packageName, info.directory);
@@ -62,26 +50,26 @@ function getPackageInfo(packageName, workspaceRoot) {
62
50
  return cand;
63
51
  }
64
52
  }
65
- logger_1.logger.warn('No meta data found for shared lib ' + packageName);
53
+ logger.warn('No meta data found for shared lib ' + packageName);
66
54
  return null;
67
55
  }
68
56
  function getVersionMapCacheKey(project, workspace) {
69
57
  return `${project}**${workspace}`;
70
58
  }
71
- function getVersionMaps(project, workspace) {
72
- return getPackageJsonFiles(project, workspace).map((json) => ({
59
+ export function getVersionMaps(project, workspace) {
60
+ return getPackageJsonFiles(project, workspace).map(json => ({
73
61
  ...json.content['dependencies'],
74
62
  }));
75
63
  }
76
- function getPackageJsonFiles(project, workspace) {
64
+ export function getPackageJsonFiles(project, workspace) {
77
65
  const cacheKey = getVersionMapCacheKey(project, workspace);
78
66
  let maps = packageCache[cacheKey];
79
67
  if (maps) {
80
68
  return maps;
81
69
  }
82
- maps = findPackageJsonFiles(project, workspace).map((f) => {
70
+ maps = findPackageJsonFiles(project, workspace).map(f => {
83
71
  const content = JSON.parse(fs.readFileSync(f, 'utf-8'));
84
- const directory = (0, normalize_1.normalize)(path.dirname(f), true);
72
+ const directory = normalize(path.dirname(f), true);
85
73
  const result = {
86
74
  content,
87
75
  directory,
@@ -91,8 +79,10 @@ function getPackageJsonFiles(project, workspace) {
91
79
  packageCache[cacheKey] = maps;
92
80
  return maps;
93
81
  }
94
- function findDepPackageJson(packageName, projectRoot) {
82
+ export function findDepPackageJson(packageName, projectRoot) {
95
83
  const mainPkgName = getPkgFolder(packageName);
84
+ if (!mainPkgName)
85
+ throw new Error(`Package.json "${packageName}" is missing`);
96
86
  let mainPkgPath = path.join(projectRoot, 'node_modules', mainPkgName);
97
87
  let mainPkgJsonPath = path.join(mainPkgPath, 'package.json');
98
88
  let directory = projectRoot;
@@ -100,14 +90,14 @@ function findDepPackageJson(packageName, projectRoot) {
100
90
  if (fs.existsSync(mainPkgJsonPath)) {
101
91
  break;
102
92
  }
103
- directory = (0, normalize_1.normalize)(path.dirname(directory), true);
93
+ directory = normalize(path.dirname(directory), true);
104
94
  mainPkgPath = path.join(directory, 'node_modules', mainPkgName);
105
95
  mainPkgJsonPath = path.join(mainPkgPath, 'package.json');
106
96
  }
107
97
  if (!fs.existsSync(mainPkgJsonPath)) {
108
98
  // TODO: Add logger
109
99
  // context.logger.warn('No package.json found for ' + packageName);
110
- logger_1.logger.verbose('No package.json found for ' + packageName + ' in ' + mainPkgPath);
100
+ logger.verbose('No package.json found for ' + packageName + ' in ' + mainPkgPath);
111
101
  return null;
112
102
  }
113
103
  return mainPkgJsonPath;
@@ -137,7 +127,7 @@ function findOptimalExport(target, info, isESM = undefined) {
137
127
  const exportTypes = Object.keys(target);
138
128
  // We prefer ESM exports for native support.
139
129
  if (typeof isESM === 'undefined') {
140
- const esmExport = exportTypes.find((e) => (0, exports.isESMExport)(e));
130
+ const esmExport = exportTypes.find(e => isESMExport(e));
141
131
  if (esmExport) {
142
132
  return findOptimalExport(target[esmExport], info, true);
143
133
  }
@@ -145,12 +135,14 @@ function findOptimalExport(target, info, isESM = undefined) {
145
135
  // Node.js looks at the exports object and uses the first key that matches the current environment.
146
136
  const secondBestEntry = 'default' in target && target['default']
147
137
  ? 'default'
148
- : exportTypes.filter((e) => e !== 'types')[0];
138
+ : exportTypes.filter(e => e !== 'types')[0];
149
139
  const secondBestExport = target[secondBestEntry];
150
- return findOptimalExport(secondBestExport, info, isESM ?? (0, exports.isESMExport)(secondBestEntry));
140
+ return findOptimalExport(secondBestExport, info, isESM ?? isESMExport(secondBestEntry));
151
141
  }
152
- function _getPackageInfo(packageName, directory) {
142
+ export function _getPackageInfo(packageName, directory) {
153
143
  const mainPkgName = getPkgFolder(packageName);
144
+ if (!mainPkgName)
145
+ throw new Error(`Could not resolve "${packageName}" in "${directory}`);
154
146
  const mainPkgJsonPath = findDepPackageJson(packageName, directory);
155
147
  if (!mainPkgJsonPath) {
156
148
  return null;
@@ -160,15 +152,13 @@ function _getPackageInfo(packageName, directory) {
160
152
  const version = mainPkgJson['version'];
161
153
  const esm = mainPkgJson['type'] === 'module';
162
154
  if (!version) {
163
- logger_1.logger.warn('No version found for ' + packageName);
155
+ logger.warn('No version found for ' + packageName);
164
156
  return null;
165
157
  }
166
158
  const pathToSecondary = path.relative(mainPkgName, packageName);
167
- const relSecondaryPath = !pathToSecondary
168
- ? '.'
169
- : './' + pathToSecondary.replace(/\\/g, '/');
159
+ const relSecondaryPath = !pathToSecondary ? '.' : './' + pathToSecondary.replace(/\\/g, '/');
170
160
  let secondaryEntryPoint = undefined;
171
- const packageJsonExportsEntry = Object.keys(mainPkgJson?.exports ?? []).find((e) => {
161
+ const packageJsonExportsEntry = Object.keys(mainPkgJson?.exports ?? []).find(e => {
172
162
  if (e === relSecondaryPath)
173
163
  return true;
174
164
  if (e === './*')
@@ -261,8 +251,8 @@ function _getPackageInfo(packageName, directory) {
261
251
  esm,
262
252
  };
263
253
  }
264
- logger_1.logger.warn('No entry point found for ' + packageName);
265
- logger_1.logger.warn("If you don't need this package, skip it in your federation.config.js or consider moving it into depDependencies in your package.json");
254
+ logger.warn('No entry point found for ' + packageName);
255
+ logger.warn("If you don't need this package, skip it in your federation.config.js or consider moving it into depDependencies in your package.json");
266
256
  return null;
267
257
  }
268
258
  function readJson(mainPkgJsonPath) {
@@ -276,4 +266,3 @@ function getPkgFolder(packageName) {
276
266
  }
277
267
  return folder;
278
268
  }
279
- //# sourceMappingURL=package-info.js.map
@@ -4,3 +4,4 @@ export declare class RebuildQueue {
4
4
  enqueue(rebuildFn: (signal: AbortSignal) => Promise<void>): Promise<void>;
5
5
  dispose(): void;
6
6
  }
7
+ //# sourceMappingURL=rebuild-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rebuild-queue.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/rebuild-queue.ts"],"names":[],"mappings":"AAOA,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAAwC;IAC5D,OAAO,CAAC,YAAY,CAAK;IAEnB,OAAO,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAsC/E,OAAO,IAAI,IAAI;CAMhB"}
@@ -1,24 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RebuildQueue = void 0;
4
- const logger_1 = require("./logger");
5
- class RebuildQueue {
1
+ import { logger } from './logger.js';
2
+ export class RebuildQueue {
6
3
  activeBuilds = new Map();
7
4
  buildCounter = 0;
8
5
  async enqueue(rebuildFn) {
9
6
  const buildId = ++this.buildCounter;
10
- const pendingCancellations = Array.from(this.activeBuilds.values()).map((buildInfo) => {
7
+ const pendingCancellations = Array.from(this.activeBuilds.values()).map(buildInfo => {
11
8
  buildInfo.controller.abort();
12
9
  return buildInfo.buildFinished.promise;
13
10
  });
14
11
  if (pendingCancellations.length > 0) {
15
- logger_1.logger.info(`Aborting ${pendingCancellations.length} bundling task(s)..`);
12
+ logger.info(`Aborting ${pendingCancellations.length} bundling task(s)..`);
16
13
  }
17
14
  if (pendingCancellations.length > 0) {
18
15
  await Promise.all(pendingCancellations);
19
16
  }
20
17
  let buildFinished;
21
- const completionPromise = new Promise((resolve) => {
18
+ const completionPromise = new Promise(resolve => {
22
19
  buildFinished = resolve;
23
20
  });
24
21
  const control = {
@@ -44,5 +41,3 @@ class RebuildQueue {
44
41
  this.activeBuilds.clear();
45
42
  }
46
43
  }
47
- exports.RebuildQueue = RebuildQueue;
48
- //# sourceMappingURL=rebuild-queue.js.map
@@ -1 +1,2 @@
1
1
  export declare function resolveGlobSync(pattern: string, baseDir?: string): string[];
2
+ //# sourceMappingURL=resolve-glob.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-glob.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/resolve-glob.ts"],"names":[],"mappings":"AAGA,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,SAAgB,GACtB,MAAM,EAAE,CAkCV"}
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveGlobSync = resolveGlobSync;
4
- const tslib_1 = require("tslib");
5
- const fs = tslib_1.__importStar(require("fs"));
6
- const path = tslib_1.__importStar(require("path"));
7
- function resolveGlobSync(pattern, baseDir = process.cwd()) {
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ export function resolveGlobSync(pattern, baseDir = process.cwd()) {
8
4
  if (pattern.startsWith('./')) {
9
5
  pattern = pattern.substring(2);
10
6
  }
@@ -31,4 +27,3 @@ function resolveGlobSync(pattern, baseDir = process.cwd()) {
31
27
  search(baseDir, 0);
32
28
  return results;
33
29
  }
34
- //# sourceMappingURL=resolve-glob.js.map
@@ -1,5 +1,3 @@
1
- export type KeyValuePair = {
2
- key: string;
3
- value: string;
4
- };
1
+ import type { KeyValuePair } from '../domain/utils/keyvaluepair.contract.js';
5
2
  export declare function resolveWildcardKeys(keyPattern: string, valuePattern: string, cwd: string): KeyValuePair[];
3
+ //# sourceMappingURL=resolve-wildcard-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-wildcard-keys.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/resolve-wildcard-keys.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AA0C7E,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,MAAM,GACV,YAAY,EAAE,CA4BhB"}
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveWildcardKeys = resolveWildcardKeys;
4
- const tslib_1 = require("tslib");
5
- const fast_glob_1 = tslib_1.__importDefault(require("fast-glob"));
1
+ import fg from 'fast-glob';
6
2
  function escapeRegex(str) {
7
3
  return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
8
4
  }
@@ -39,11 +35,11 @@ function withoutWildcard(template, wildcardValues) {
39
35
  }
40
36
  return result;
41
37
  }
42
- function resolveWildcardKeys(keyPattern, valuePattern, cwd) {
38
+ export function resolveWildcardKeys(keyPattern, valuePattern, cwd) {
43
39
  const normalizedPattern = valuePattern.replace(/^\.?\/+/, '');
44
40
  const globPattern = convertExportsToGlob(normalizedPattern);
45
41
  const regex = compilePattern(normalizedPattern);
46
- const files = fast_glob_1.default.sync(globPattern, {
42
+ const files = fg.sync(globPattern, {
47
43
  cwd,
48
44
  onlyFiles: true,
49
45
  deep: Infinity,
@@ -61,4 +57,3 @@ function resolveWildcardKeys(keyPattern, valuePattern, cwd) {
61
57
  }
62
58
  return keys;
63
59
  }
64
- //# sourceMappingURL=resolve-wildcard-keys.js.map
@@ -2,3 +2,4 @@ export declare const INTERNAL_SCOPE = "@nf-internal";
2
2
  export declare function rewriteChunkImports(filePath: string): void;
3
3
  export declare function isSourceFile(fileName: string): boolean;
4
4
  export declare function deriveInternalName(fileName: string): string;
5
+ //# sourceMappingURL=rewrite-chunk-imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rewrite-chunk-imports.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/rewrite-chunk-imports.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,iBAAiB,CAAC;AAE7C,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,QAmEnD;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAO3D"}
@@ -1,15 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.INTERNAL_SCOPE = void 0;
4
- exports.rewriteChunkImports = rewriteChunkImports;
5
- exports.isSourceFile = isSourceFile;
6
- exports.deriveInternalName = deriveInternalName;
7
- const tslib_1 = require("tslib");
8
- const ts = tslib_1.__importStar(require("typescript"));
9
- const fs = tslib_1.__importStar(require("fs"));
10
- const path = tslib_1.__importStar(require("path"));
11
- exports.INTERNAL_SCOPE = '@nf-internal';
12
- function rewriteChunkImports(filePath) {
1
+ import * as ts from 'typescript';
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+ export const INTERNAL_SCOPE = '@nf-internal';
5
+ export function rewriteChunkImports(filePath) {
13
6
  const sourceCode = fs.readFileSync(filePath, 'utf-8');
14
7
  const sourceFile = ts.createSourceFile(path.basename(filePath), sourceCode, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS);
15
8
  const printer = ts.createPrinter();
@@ -31,34 +24,32 @@ function rewriteChunkImports(filePath) {
31
24
  }
32
25
  }
33
26
  // import('./...')
34
- if (ts.isCallExpression(node) &&
35
- node.expression.kind === ts.SyntaxKind.ImportKeyword) {
27
+ if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {
36
28
  const [arg] = node.arguments;
37
29
  if (arg && ts.isStringLiteral(arg)) {
38
30
  const text = arg.text;
39
31
  if (text.startsWith('./')) {
40
32
  const newArg = ts.factory.createStringLiteral(deriveInternalName(text));
41
- return ts.factory.updateCallExpression(node, node.expression, node.typeArguments, [newArg]);
33
+ return ts.factory.updateCallExpression(node, node.expression, node.typeArguments, [
34
+ newArg,
35
+ ]);
42
36
  }
43
37
  }
44
38
  }
45
39
  return ts.visitEachChild(node, visit, undefined);
46
40
  }
47
- const transformed = ts.transform(sourceFile, [
48
- (context) => (node) => ts.visitNode(node, visit),
49
- ]);
41
+ const transformed = ts.transform(sourceFile, [_ => node => ts.visitNode(node, visit)]);
50
42
  const updatedSourceFile = transformed.transformed[0];
51
43
  const result = printer.printFile(updatedSourceFile);
52
44
  fs.writeFileSync(filePath, result, 'utf-8');
53
45
  }
54
- function isSourceFile(fileName) {
46
+ export function isSourceFile(fileName) {
55
47
  return !!fileName.match(/.(m|c)?js$/);
56
48
  }
57
- function deriveInternalName(fileName) {
49
+ export function deriveInternalName(fileName) {
58
50
  if (fileName.startsWith('./')) {
59
51
  fileName = fileName.slice(2);
60
52
  }
61
53
  const packageName = fileName.replace(/.(m|c)?js$/, '');
62
- return exports.INTERNAL_SCOPE + '/' + packageName;
54
+ return INTERNAL_SCOPE + '/' + packageName;
63
55
  }
64
- //# sourceMappingURL=rewrite-chunk-imports.js.map
package/LICENSE DELETED
@@ -1,8 +0,0 @@
1
- Copyright 2021 Softarc Consulting GmbH
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
-