@softarc/native-federation 4.1.3 → 4.2.0
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/LICENSE.md +7 -0
- package/README.md +638 -0
- package/dist/config.js +17 -0
- package/dist/domain.js +2 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +21 -0
- package/{src → dist}/internal.d.ts +6 -7
- package/dist/internal.js +26 -0
- package/dist/lib/config/configuration-context.js +15 -0
- package/dist/lib/config/default-skip-list.js +36 -0
- package/dist/lib/config/get-external-imports.d.ts +2 -0
- package/dist/lib/config/get-external-imports.js +60 -0
- package/dist/lib/config/get-used-dependencies.d.ts +24 -0
- package/dist/lib/config/get-used-dependencies.js +126 -0
- package/{src/lib/utils → dist/lib/config}/mapped-paths.d.ts +2 -2
- package/dist/lib/config/mapped-paths.js +31 -0
- package/dist/lib/config/remove-unused-deps.js +11 -0
- package/dist/lib/config/share-utils.d.ts +20 -0
- package/dist/lib/config/share-utils.js +344 -0
- package/dist/lib/config/with-native-federation.js +80 -0
- package/{src/lib/core → dist/lib/core/build}/build-adapter.d.ts +1 -1
- package/dist/lib/core/build/build-adapter.js +16 -0
- package/dist/lib/core/build/build-for-federation.d.ts +4 -0
- package/dist/lib/core/build/build-for-federation.js +207 -0
- package/{src/lib/utils → dist/lib/core/build}/build-result-map.d.ts +1 -1
- package/dist/lib/core/build/build-result-map.js +39 -0
- package/dist/lib/core/build/bundle-exposed-and-mappings.d.ts +13 -0
- package/dist/lib/core/build/bundle-exposed-and-mappings.js +178 -0
- package/dist/lib/core/build/bundle-shared.d.ts +34 -0
- package/dist/lib/core/build/bundle-shared.js +261 -0
- package/dist/lib/core/build/compute-integrity.d.ts +11 -0
- package/dist/lib/core/build/compute-integrity.js +20 -0
- package/dist/lib/core/build/default-external-list.js +32 -0
- package/dist/lib/core/build/get-externals.d.ts +2 -0
- package/dist/lib/core/build/get-externals.js +9 -0
- package/dist/lib/core/build/rebuild-for-federation.d.ts +4 -0
- package/dist/lib/core/build/rebuild-for-federation.js +52 -0
- package/dist/lib/core/build/rewrite-chunk-imports.d.ts +5 -0
- package/dist/lib/core/build/rewrite-chunk-imports.js +74 -0
- package/dist/lib/core/cache/cache-persistence.d.ts +22 -0
- package/dist/lib/core/cache/cache-persistence.js +63 -0
- package/{src/lib/core → dist/lib/core/cache}/federation-cache.d.ts +2 -2
- package/dist/lib/core/cache/federation-cache.js +22 -0
- package/dist/lib/core/federation-builder.js +53 -0
- package/{src → dist}/lib/core/normalize-options.d.ts +13 -1
- package/dist/lib/core/normalize-options.js +67 -0
- package/dist/lib/core/output/write-federation-info.d.ts +5 -0
- package/dist/lib/core/output/write-federation-info.js +17 -0
- package/dist/lib/core/output/write-import-map.d.ts +11 -0
- package/dist/lib/core/output/write-import-map.js +42 -0
- package/dist/lib/core/rebuild-queue.js +61 -0
- package/{src → dist}/lib/domain/config/external-config.contract.d.ts +2 -2
- package/dist/lib/domain/config/external-config.contract.js +0 -0
- package/dist/lib/domain/config/federation-config.contract.js +0 -0
- package/dist/lib/domain/config/index.js +0 -0
- package/dist/lib/domain/config/skip-list.contract.js +0 -0
- package/dist/lib/domain/core/build-adapter.contract.js +0 -0
- package/dist/lib/domain/core/build-notification-options.contract.js +9 -0
- package/dist/lib/domain/core/chunk.js +12 -0
- package/dist/lib/domain/core/federation-cache.contract.js +0 -0
- package/dist/lib/domain/core/federation-info.contract.js +0 -0
- package/dist/lib/domain/core/federation-options.contract.js +0 -0
- package/dist/lib/domain/core/index.js +9 -0
- package/dist/lib/domain/core/manifest.contract.js +0 -0
- package/dist/lib/domain/utils/file-watcher.contract.js +0 -0
- package/dist/lib/domain/utils/io-port.contract.d.ts +45 -0
- package/dist/lib/domain/utils/io-port.contract.js +0 -0
- package/dist/lib/domain/utils/keyvaluepair.contract.js +0 -0
- package/dist/lib/domain/utils/mapped-path.contract.js +0 -0
- package/dist/lib/domain/utils/package-json.contract.d.ts +27 -0
- package/dist/lib/domain/utils/package-json.contract.js +0 -0
- package/dist/lib/domain/utils/used-dependencies.contract.js +0 -0
- package/dist/lib/utils/errors.js +10 -0
- package/{src → dist}/lib/utils/file-watcher.d.ts +2 -0
- package/dist/lib/utils/file-watcher.js +51 -0
- package/dist/lib/utils/hash-file.d.ts +7 -0
- package/dist/lib/utils/hash-file.js +15 -0
- package/dist/lib/utils/io/node-io-adapter.d.ts +2 -0
- package/dist/lib/utils/io/node-io-adapter.js +68 -0
- package/dist/lib/utils/io/package-json-repository.d.ts +5 -0
- package/dist/lib/utils/io/package-json-repository.js +79 -0
- package/dist/lib/utils/logger.js +29 -0
- package/dist/lib/utils/normalize.js +22 -0
- package/dist/lib/utils/package/entry-point-resolver.d.ts +2 -0
- package/dist/lib/utils/package/entry-point-resolver.js +78 -0
- package/dist/lib/utils/package/esm-detection.d.ts +5 -0
- package/dist/lib/utils/package/esm-detection.js +10 -0
- package/dist/lib/utils/package/exports-resolver.d.ts +13 -0
- package/dist/lib/utils/package/exports-resolver.js +55 -0
- package/dist/lib/utils/package/package-info.d.ts +7 -0
- package/dist/lib/utils/package/package-info.js +31 -0
- package/dist/lib/utils/package/resolve-wildcard-keys.d.ts +3 -0
- package/dist/lib/utils/package/resolve-wildcard-keys.js +22 -0
- package/dist/lib/utils/package/version-maps.d.ts +3 -0
- package/dist/lib/utils/package/version-maps.js +8 -0
- package/dist/lib/utils/path-patterns.d.ts +14 -0
- package/dist/lib/utils/path-patterns.js +28 -0
- package/package.json +45 -22
- package/src/config.js +0 -4
- package/src/domain.js +0 -2
- package/src/index.d.ts +0 -10
- package/src/index.js +0 -10
- package/src/internal.js +0 -11
- package/src/lib/config/configuration-context.js +0 -10
- package/src/lib/config/default-skip-list.js +0 -31
- package/src/lib/config/remove-unused-deps.js +0 -10
- package/src/lib/config/share-utils.d.ts +0 -10
- package/src/lib/config/share-utils.js +0 -302
- package/src/lib/config/with-native-federation.js +0 -79
- package/src/lib/core/build-adapter.js +0 -12
- package/src/lib/core/build-for-federation.d.ts +0 -4
- package/src/lib/core/build-for-federation.js +0 -173
- package/src/lib/core/bundle-exposed-and-mappings.d.ts +0 -7
- package/src/lib/core/bundle-exposed-and-mappings.js +0 -177
- package/src/lib/core/bundle-shared.d.ts +0 -13
- package/src/lib/core/bundle-shared.js +0 -222
- package/src/lib/core/default-external-list.js +0 -29
- package/src/lib/core/federation-builder.js +0 -45
- package/src/lib/core/federation-cache.js +0 -16
- package/src/lib/core/get-externals.d.ts +0 -2
- package/src/lib/core/get-externals.js +0 -6
- package/src/lib/core/normalize-options.js +0 -58
- package/src/lib/core/rebuild-for-federation.d.ts +0 -4
- package/src/lib/core/rebuild-for-federation.js +0 -43
- package/src/lib/core/write-federation-info.d.ts +0 -3
- package/src/lib/core/write-federation-info.js +0 -6
- package/src/lib/core/write-import-map.d.ts +0 -6
- package/src/lib/core/write-import-map.js +0 -33
- package/src/lib/domain/config/external-config.contract.js +0 -1
- package/src/lib/domain/config/federation-config.contract.js +0 -1
- package/src/lib/domain/config/index.js +0 -1
- package/src/lib/domain/config/skip-list.contract.js +0 -1
- package/src/lib/domain/config/with-native-federation.contract.d.ts +0 -2
- package/src/lib/domain/config/with-native-federation.contract.js +0 -1
- package/src/lib/domain/core/build-adapter.contract.js +0 -1
- package/src/lib/domain/core/build-notification-options.contract.js +0 -6
- package/src/lib/domain/core/chunk.js +0 -8
- package/src/lib/domain/core/federation-cache.contract.js +0 -1
- package/src/lib/domain/core/federation-info.contract.js +0 -1
- package/src/lib/domain/core/federation-options.contract.js +0 -1
- package/src/lib/domain/core/index.js +0 -2
- package/src/lib/domain/core/manifest.contract.js +0 -1
- package/src/lib/domain/utils/file-watcher.contract.js +0 -1
- package/src/lib/domain/utils/index.d.ts +0 -2
- package/src/lib/domain/utils/index.js +0 -1
- package/src/lib/domain/utils/keyvaluepair.contract.js +0 -1
- package/src/lib/domain/utils/mapped-path.contract.js +0 -5
- package/src/lib/domain/utils/used-dependencies.contract.js +0 -1
- package/src/lib/utils/build-result-map.js +0 -29
- package/src/lib/utils/cache-persistence.d.ts +0 -19
- package/src/lib/utils/cache-persistence.js +0 -66
- package/src/lib/utils/errors.js +0 -7
- package/src/lib/utils/file-watcher.js +0 -51
- package/src/lib/utils/get-external-imports.d.ts +0 -1
- package/src/lib/utils/get-external-imports.js +0 -80
- package/src/lib/utils/get-used-dependencies.d.ts +0 -8
- package/src/lib/utils/get-used-dependencies.js +0 -123
- package/src/lib/utils/hash-file.d.ts +0 -3
- package/src/lib/utils/hash-file.js +0 -13
- package/src/lib/utils/logger.js +0 -27
- package/src/lib/utils/mapped-paths.js +0 -33
- package/src/lib/utils/normalize.js +0 -17
- package/src/lib/utils/package-info.d.ts +0 -30
- package/src/lib/utils/package-info.js +0 -268
- package/src/lib/utils/rebuild-queue.js +0 -63
- package/src/lib/utils/resolve-glob.d.ts +0 -1
- package/src/lib/utils/resolve-glob.js +0 -29
- package/src/lib/utils/resolve-wildcard-keys.d.ts +0 -29
- package/src/lib/utils/resolve-wildcard-keys.js +0 -126
- package/src/lib/utils/rewrite-chunk-imports.d.ts +0 -2
- package/src/lib/utils/rewrite-chunk-imports.js +0 -48
- /package/{src → dist}/config.d.ts +0 -0
- /package/{src → dist}/domain.d.ts +0 -0
- /package/{src → dist}/lib/config/configuration-context.d.ts +0 -0
- /package/{src → dist}/lib/config/default-skip-list.d.ts +0 -0
- /package/{src → dist}/lib/config/remove-unused-deps.d.ts +0 -0
- /package/{src → dist}/lib/config/with-native-federation.d.ts +0 -0
- /package/{src/lib/core → dist/lib/core/build}/default-external-list.d.ts +0 -0
- /package/{src → dist}/lib/core/federation-builder.d.ts +0 -0
- /package/{src/lib/utils → dist/lib/core}/rebuild-queue.d.ts +0 -0
- /package/{src → dist}/lib/domain/config/federation-config.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/config/index.d.ts +0 -0
- /package/{src → dist}/lib/domain/config/skip-list.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/build-adapter.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/build-notification-options.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/chunk.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/federation-cache.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/federation-info.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/federation-options.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/index.d.ts +0 -0
- /package/{src → dist}/lib/domain/core/manifest.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/utils/file-watcher.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/utils/keyvaluepair.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/utils/mapped-path.contract.d.ts +0 -0
- /package/{src → dist}/lib/domain/utils/used-dependencies.contract.d.ts +0 -0
- /package/{src → dist}/lib/utils/errors.d.ts +0 -0
- /package/{src → dist}/lib/utils/logger.d.ts +0 -0
- /package/{src → dist}/lib/utils/normalize.d.ts +0 -0
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import fg from 'fast-glob';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
import { logger } from './logger.js';
|
|
5
|
-
// TypeScript's module resolution for directories checks these in order
|
|
6
|
-
// @see https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution
|
|
7
|
-
const TS_INDEX_FILES = [
|
|
8
|
-
'index.ts',
|
|
9
|
-
'index.tsx',
|
|
10
|
-
'index.mts',
|
|
11
|
-
'index.cts',
|
|
12
|
-
'index.d.ts',
|
|
13
|
-
'index.js',
|
|
14
|
-
'index.jsx',
|
|
15
|
-
'index.mjs',
|
|
16
|
-
'index.cjs',
|
|
17
|
-
];
|
|
18
|
-
/**
|
|
19
|
-
* Resolves tsconfig wildcard paths.
|
|
20
|
-
*
|
|
21
|
-
* In tsconfig.json, paths like `@features/*` → `libs/features/src/*` work as follows:
|
|
22
|
-
* - The `*` captures a single path segment (the module name)
|
|
23
|
-
* - When importing `@features/feature-a`, TypeScript captures `feature-a`
|
|
24
|
-
* - It then replaces `*` in the value pattern: `libs/features/src/feature-a`
|
|
25
|
-
*
|
|
26
|
-
* For discovery, we find all directories at the wildcard position that TypeScript
|
|
27
|
-
* would recognize as valid modules (directories with index files or package.json).
|
|
28
|
-
*
|
|
29
|
-
// @see https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution
|
|
30
|
-
*/
|
|
31
|
-
export function resolveTsConfigWildcard(keyPattern, valuePattern, cwd) {
|
|
32
|
-
const normalizedPattern = valuePattern.replace(/^\.?\/+/, '');
|
|
33
|
-
const asteriskIndex = normalizedPattern.indexOf('*');
|
|
34
|
-
if (asteriskIndex === -1) {
|
|
35
|
-
return [];
|
|
36
|
-
}
|
|
37
|
-
const prefix = normalizedPattern.substring(0, asteriskIndex);
|
|
38
|
-
const suffix = normalizedPattern.substring(asteriskIndex + 1);
|
|
39
|
-
const searchPath = path.join(cwd, prefix);
|
|
40
|
-
let entries;
|
|
41
|
-
try {
|
|
42
|
-
entries = fs.readdirSync(searchPath);
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
const keys = [];
|
|
48
|
-
for (const entry of entries) {
|
|
49
|
-
const entryPath = path.join(searchPath, entry);
|
|
50
|
-
let stats;
|
|
51
|
-
try {
|
|
52
|
-
stats = fs.statSync(entryPath);
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
if (!stats.isDirectory()) {
|
|
58
|
-
// Skipping individual files, we only process modules
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
let modulePath = path.join(prefix, entry, suffix).replace(/\\/g, '/');
|
|
62
|
-
const fullPath = path.join(cwd, modulePath);
|
|
63
|
-
let fullPathStats;
|
|
64
|
-
try {
|
|
65
|
-
fullPathStats = fs.statSync(fullPath);
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
const key = keyPattern.replace('*', entry);
|
|
71
|
-
if (fullPathStats.isDirectory()) {
|
|
72
|
-
const indexFile = TS_INDEX_FILES.find(indexFile => fs.existsSync(path.join(fullPath, indexFile)));
|
|
73
|
-
if (!indexFile) {
|
|
74
|
-
logger.warn(`[shared-mappings] Internal lib '${key}' does not contain an entryPoint (barrel file).`);
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
modulePath = path.join(modulePath, indexFile);
|
|
78
|
-
}
|
|
79
|
-
else if (!fullPathStats.isFile()) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
keys.push({
|
|
83
|
-
key,
|
|
84
|
-
value: modulePath,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
return keys;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Resolves package.json exports wildcard patterns.
|
|
91
|
-
*
|
|
92
|
-
* In package.json exports, patterns like `./features/*.js` → `./src/features/*.js` work as follows:
|
|
93
|
-
* - The `*` is a literal string replacement that can include path separators
|
|
94
|
-
* - Importing `pkg/features/a/b.js` captures `a/b` and replaces `*` → `./src/features/a/b.js`
|
|
95
|
-
* - This matches actual files, not directories
|
|
96
|
-
*
|
|
97
|
-
* @see https://nodejs.org/api/packages.html#subpath-patterns
|
|
98
|
-
*/
|
|
99
|
-
export function resolvePackageJsonExportsWildcard(keyPattern, valuePattern, cwd) {
|
|
100
|
-
const normalizedPattern = valuePattern.replace(/^\.?\/+/, '');
|
|
101
|
-
const asteriskIndex = normalizedPattern.indexOf('*');
|
|
102
|
-
if (asteriskIndex === -1) {
|
|
103
|
-
return [];
|
|
104
|
-
}
|
|
105
|
-
const prefix = normalizedPattern.substring(0, asteriskIndex);
|
|
106
|
-
const suffix = normalizedPattern.substring(asteriskIndex + 1);
|
|
107
|
-
// fast-glob requires **/* pattern for matching files at any depth
|
|
108
|
-
const files = fg.sync(prefix + '**/*' + suffix, {
|
|
109
|
-
cwd,
|
|
110
|
-
onlyFiles: true,
|
|
111
|
-
deep: Infinity,
|
|
112
|
-
});
|
|
113
|
-
const keys = [];
|
|
114
|
-
for (const file of files) {
|
|
115
|
-
const relPath = file.replace(/\\/g, '/').replace(/^\.\//, '');
|
|
116
|
-
const captured = suffix
|
|
117
|
-
? relPath.slice(prefix.length, -suffix.length)
|
|
118
|
-
: relPath.slice(prefix.length);
|
|
119
|
-
const key = keyPattern.replace('*', captured);
|
|
120
|
-
keys.push({
|
|
121
|
-
key,
|
|
122
|
-
value: relPath,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
return keys;
|
|
126
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import * as ts from 'typescript';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
import { toChunkImport } from '../domain/core/chunk.js';
|
|
5
|
-
export function rewriteChunkImports(filePath) {
|
|
6
|
-
const sourceCode = fs.readFileSync(filePath, 'utf-8');
|
|
7
|
-
const sourceFile = ts.createSourceFile(path.basename(filePath), sourceCode, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS);
|
|
8
|
-
const printer = ts.createPrinter();
|
|
9
|
-
function visit(node) {
|
|
10
|
-
// import ... from '...'
|
|
11
|
-
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
|
|
12
|
-
const moduleSpecifier = node.moduleSpecifier;
|
|
13
|
-
if (moduleSpecifier && ts.isStringLiteral(moduleSpecifier)) {
|
|
14
|
-
const text = moduleSpecifier.text;
|
|
15
|
-
if (text.startsWith('./')) {
|
|
16
|
-
const newModuleSpecifier = ts.factory.createStringLiteral(toChunkImport(text));
|
|
17
|
-
if (ts.isImportDeclaration(node)) {
|
|
18
|
-
return ts.factory.updateImportDeclaration(node, node.modifiers, node.importClause, newModuleSpecifier, node.assertClause);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
return ts.factory.updateExportDeclaration(node, node.modifiers, node.isTypeOnly, node.exportClause, newModuleSpecifier, node.assertClause);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
// import('./...')
|
|
27
|
-
if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {
|
|
28
|
-
const [arg] = node.arguments;
|
|
29
|
-
if (arg && ts.isStringLiteral(arg)) {
|
|
30
|
-
const text = arg.text;
|
|
31
|
-
if (text.startsWith('./')) {
|
|
32
|
-
const newArg = ts.factory.createStringLiteral(toChunkImport(text));
|
|
33
|
-
return ts.factory.updateCallExpression(node, node.expression, node.typeArguments, [
|
|
34
|
-
newArg,
|
|
35
|
-
]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return ts.visitEachChild(node, visit, undefined);
|
|
40
|
-
}
|
|
41
|
-
const transformed = ts.transform(sourceFile, [_ => node => ts.visitNode(node, visit)]);
|
|
42
|
-
const updatedSourceFile = transformed.transformed[0];
|
|
43
|
-
const result = printer.printFile(updatedSourceFile);
|
|
44
|
-
fs.writeFileSync(filePath, result, 'utf-8');
|
|
45
|
-
}
|
|
46
|
-
export function isSourceFile(fileName) {
|
|
47
|
-
return !!fileName.match(/.(m|c)?js$/);
|
|
48
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|