@softarc/native-federation 4.3.0 → 4.3.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.
Files changed (37) hide show
  1. package/README.md +2 -2
  2. package/dist/internal/browser.d.ts +6 -0
  3. package/dist/internal/browser.js +9 -0
  4. package/dist/internal.d.ts +9 -6
  5. package/dist/internal.js +21 -6
  6. package/dist/lib/config/with-native-federation.js +2 -1
  7. package/dist/lib/core/build/build-for-federation.d.ts +7 -0
  8. package/dist/lib/core/build/build-for-federation.js +32 -134
  9. package/dist/lib/core/build/bundle-shared.d.ts +7 -0
  10. package/dist/lib/core/build/bundle-shared.js +38 -7
  11. package/dist/lib/core/build/rebuild-for-federation.d.ts +8 -0
  12. package/dist/lib/core/build/rebuild-for-federation.js +26 -0
  13. package/dist/lib/core/build/resolve-shared-dirs.d.ts +16 -0
  14. package/dist/lib/core/build/resolve-shared-dirs.js +66 -0
  15. package/dist/lib/core/build/shared-bundle-plan.d.ts +22 -0
  16. package/dist/lib/core/build/shared-bundle-plan.js +70 -0
  17. package/dist/lib/core/build/synthesize-cjs-exports.d.ts +12 -0
  18. package/dist/lib/core/build/synthesize-cjs-exports.js +58 -0
  19. package/dist/lib/core/cache/cache-persistence.d.ts +2 -2
  20. package/dist/lib/core/cache/cache-persistence.js +7 -4
  21. package/dist/lib/core/federation-builder.d.ts +2 -1
  22. package/dist/lib/core/federation-builder.js +3 -0
  23. package/dist/lib/core/output/densify-externals.d.ts +1 -0
  24. package/dist/lib/core/output/densify-externals.js +21 -4
  25. package/dist/lib/core/output/write-federation-info.js +1 -1
  26. package/dist/lib/domain/config/federation-config.contract.d.ts +2 -0
  27. package/dist/lib/domain/core/federation-info.contract.d.ts +1 -0
  28. package/dist/lib/domain/utils/file-watcher.contract.d.ts +7 -1
  29. package/dist/lib/domain/utils/io-port.contract.d.ts +14 -3
  30. package/dist/lib/utils/file-watcher.d.ts +1 -1
  31. package/dist/lib/utils/file-watcher.js +23 -6
  32. package/dist/lib/utils/io/node-io-adapter.js +77 -21
  33. package/dist/lib/utils/package/cjs-named-exports.d.ts +21 -0
  34. package/dist/lib/utils/package/cjs-named-exports.js +36 -0
  35. package/dist/lib/utils/package/esm-detection.d.ts +13 -0
  36. package/dist/lib/utils/package/esm-detection.js +29 -0
  37. package/package.json +9 -3
@@ -5,6 +5,35 @@ const isESMExport = (e) => {
5
5
  if (e === "cjs" || e === "commonjs") return false;
6
6
  return void 0;
7
7
  };
8
+ const classifyByExtension = (entryPoint) => {
9
+ if (entryPoint.endsWith(".mjs")) return "esm";
10
+ if (entryPoint.endsWith(".cjs")) return "cjs";
11
+ if (entryPoint.endsWith(".js")) return "unknown";
12
+ return "esm";
13
+ };
14
+ const hasEsmSyntax = (source) => {
15
+ const head = source.slice(0, 16384);
16
+ const exportStmt = /(?:^|[;\n}])\s*export\s*(?:\{|\*|default\b|const\b|let\b|var\b|function\b|async\b|class\b)/;
17
+ const importStmt = /(?:^|[;\n}])\s*import\s*(?:[A-Za-z_$]|\{|\*|['"])/;
18
+ return exportStmt.test(head) || importStmt.test(head);
19
+ };
20
+ const isCjsCandidate = (input) => {
21
+ if (input.esm === true) return false;
22
+ const fmt = classifyByExtension(input.entryPoint);
23
+ if (fmt === "esm") return false;
24
+ if (fmt === "cjs") return true;
25
+ if (input.packageType === "module") return false;
26
+ if (input.readSource) {
27
+ try {
28
+ if (hasEsmSyntax(input.readSource())) return false;
29
+ } catch {
30
+ }
31
+ }
32
+ return true;
33
+ };
8
34
  export {
35
+ classifyByExtension,
36
+ hasEsmSyntax,
37
+ isCjsCandidate,
9
38
  isESMExport
10
39
  };
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@softarc/native-federation",
3
- "version": "4.3.0",
3
+ "version": "4.3.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
+ "packageManager": "pnpm@11.11.0",
6
7
  "scripts": {
7
8
  "build": "node esbuild.config.mjs && tsc -p tsconfig.build.json",
8
9
  "lint": "eslint src",
@@ -27,11 +28,11 @@
27
28
  "jiti": "^2.6.1",
28
29
  "jsdom": "^29.0.0",
29
30
  "knip": "^6.20.0",
30
- "prettier": "^3.8.1",
31
+ "prettier": "^3.9.4",
31
32
  "tslib": "^2.3.0",
32
33
  "typescript": "~6.0.0",
33
34
  "typescript-eslint": "^8.61.0",
34
- "vite": "^8.0.0",
35
+ "vite": "^8.1.3",
35
36
  "vitest": "^4.0.0"
36
37
  },
37
38
  "exports": {
@@ -55,6 +56,11 @@
55
56
  "types": "./dist/internal.d.ts",
56
57
  "import": "./dist/internal.js",
57
58
  "default": "./dist/internal.js"
59
+ },
60
+ "./internal/browser": {
61
+ "types": "./dist/internal/browser.d.ts",
62
+ "import": "./dist/internal/browser.js",
63
+ "default": "./dist/internal/browser.js"
58
64
  }
59
65
  },
60
66
  "main": "./dist/index.js",