@angular-architects/native-federation-v4 21.1.7 → 21.1.9
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/collection.json +5 -0
- package/migration-collection.json +6 -0
- package/package.json +5 -5
- package/src/builders/build/builder.d.ts.map +1 -1
- package/src/builders/build/builder.js +45 -49
- package/src/builders/build/schema.d.ts +3 -5
- package/src/builders/build/schema.json +8 -29
- package/src/config/angular-skip-list.d.ts +3 -0
- package/src/config/angular-skip-list.d.ts.map +1 -0
- package/src/config/angular-skip-list.js +13 -0
- package/src/config/share-utils.d.ts +9 -0
- package/src/config/share-utils.d.ts.map +1 -0
- package/src/config/share-utils.js +32 -0
- package/src/config.d.ts +2 -2
- package/src/config.d.ts.map +1 -1
- package/src/config.js +2 -2
- package/src/schematics/init/files/federation.config.js__tmpl__ +19 -7
- package/src/schematics/init/schema.d.ts +0 -1
- package/src/schematics/init/schema.json +2 -6
- package/src/schematics/init/schematic.d.ts.map +1 -1
- package/src/schematics/init/schematic.js +50 -25
- package/src/schematics/update-v4/schema.d.ts +4 -0
- package/src/schematics/update-v4/schema.json +23 -0
- package/src/schematics/update-v4/schematic.d.ts +4 -0
- package/src/schematics/update-v4/schematic.d.ts.map +1 -0
- package/src/schematics/update-v4/schematic.js +225 -0
- package/src/utils/angular-bundler.d.ts +3 -8
- package/src/utils/angular-bundler.d.ts.map +1 -1
- package/src/utils/angular-bundler.js +10 -57
- package/src/utils/angular-esbuild-adapter.d.ts +5 -4
- package/src/utils/angular-esbuild-adapter.d.ts.map +1 -1
- package/src/utils/angular-esbuild-adapter.js +16 -19
- package/src/utils/angular-locales.d.ts.map +1 -1
- package/src/utils/create-federation-tsconfig.d.ts +6 -0
- package/src/utils/create-federation-tsconfig.d.ts.map +1 -0
- package/src/utils/create-federation-tsconfig.js +49 -0
- package/src/utils/get-fallback-platform.d.ts +3 -0
- package/src/utils/get-fallback-platform.d.ts.map +1 -0
- package/src/utils/get-fallback-platform.js +13 -0
- package/src/utils/node-modules-bundler.d.ts +3 -8
- package/src/utils/node-modules-bundler.d.ts.map +1 -1
- package/src/utils/node-modules-bundler.js +4 -8
- package/src/utils/normalize-context-options.d.ts +23 -0
- package/src/utils/normalize-context-options.d.ts.map +1 -0
- package/src/utils/normalize-context-options.js +18 -0
- package/src/utils/shared-mappings-plugin.d.ts +2 -2
- package/src/utils/shared-mappings-plugin.d.ts.map +1 -1
- package/src/utils/shared-mappings-plugin.js +4 -4
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import JSON5 from 'json5';
|
|
4
|
+
import { isDeepStrictEqual } from 'util';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a tsconfig.federation.json that includes the federation entry points.
|
|
7
|
+
*/
|
|
8
|
+
export function createFederationTsConfig(workspaceRoot, tsConfigPath, entryPoints, optimizedMappings) {
|
|
9
|
+
const fullTsConfigPath = path.join(workspaceRoot, tsConfigPath);
|
|
10
|
+
const tsconfigDir = path.dirname(fullTsConfigPath);
|
|
11
|
+
const tsconfigAsString = fs.readFileSync(fullTsConfigPath, 'utf-8');
|
|
12
|
+
const tsconfig = JSON5.parse(tsconfigAsString);
|
|
13
|
+
tsconfig.files = entryPoints
|
|
14
|
+
.filter(ep => ep.fileName.startsWith('.'))
|
|
15
|
+
.map(ep => path.relative(tsconfigDir, ep.fileName).replace(/\\\\/g, '/'));
|
|
16
|
+
if (optimizedMappings) {
|
|
17
|
+
const filtered = entryPoints
|
|
18
|
+
.filter(ep => !ep.fileName.startsWith('.'))
|
|
19
|
+
.map(ep => path.relative(tsconfigDir, ep.fileName).replace(/\\\\/g, '/'));
|
|
20
|
+
if (!tsconfig.include) {
|
|
21
|
+
tsconfig.include = [];
|
|
22
|
+
}
|
|
23
|
+
for (const ep of filtered) {
|
|
24
|
+
if (!tsconfig.include.includes(ep)) {
|
|
25
|
+
tsconfig.include.push(ep);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const content = JSON5.stringify(tsconfig, null, 2);
|
|
30
|
+
const tsconfigFedPath = path.join(tsconfigDir, 'tsconfig.federation.json');
|
|
31
|
+
if (!doesFileExistAndJsonEqual(tsconfigFedPath, content)) {
|
|
32
|
+
fs.writeFileSync(tsconfigFedPath, JSON.stringify(tsconfig, null, 2));
|
|
33
|
+
}
|
|
34
|
+
return tsconfigFedPath;
|
|
35
|
+
}
|
|
36
|
+
function doesFileExistAndJsonEqual(filePath, content) {
|
|
37
|
+
if (!fs.existsSync(filePath)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const currentContent = fs.readFileSync(filePath, 'utf-8');
|
|
42
|
+
const currentJson = JSON5.parse(currentContent);
|
|
43
|
+
const newJson = JSON5.parse(content);
|
|
44
|
+
return isDeepStrictEqual(currentJson, newJson);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-fallback-platform.d.ts","sourceRoot":"","sources":["../../../src/utils/get-fallback-platform.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,EAAE,MAAM,EAI5C,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAMlE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const DEFAULT_SERVER_DEPS_LIST = [
|
|
2
|
+
'@angular/platform-server',
|
|
3
|
+
'@angular/platform-server/init',
|
|
4
|
+
'@angular/ssr',
|
|
5
|
+
];
|
|
6
|
+
export function getDefaultPlatform(cur) {
|
|
7
|
+
if (DEFAULT_SERVER_DEPS_LIST.find(e => cur.startsWith(e))) {
|
|
8
|
+
return 'node';
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return 'browser';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import * as esbuild from 'esbuild';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import type { ApplicationBuilderOptions } from '@angular/build';
|
|
5
|
-
import type { EntryPoint, FederationCache } from '@softarc/native-federation';
|
|
6
|
-
import type { MappedPath } from '@softarc/native-federation/internal';
|
|
7
|
-
export interface NodeModulesBundleResult {
|
|
2
|
+
import type { NormalizedContextOptions } from './normalize-context-options.js';
|
|
3
|
+
export declare function createNodeModulesEsbuildContext(options: NormalizedContextOptions): Promise<{
|
|
8
4
|
ctx: esbuild.BuildContext;
|
|
9
5
|
pluginDisposed: Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
export declare function createNodeModulesEsbuildContext(builderOptions: ApplicationBuilderOptions, context: BuilderContext, entryPoints: EntryPoint[], external: string[], outdir: string, mappedPaths: MappedPath[], cache: FederationCache<SourceFileCache>, dev?: boolean, hash?: boolean, chunks?: boolean, platform?: 'browser' | 'node'): Promise<NodeModulesBundleResult>;
|
|
6
|
+
}>;
|
|
12
7
|
//# sourceMappingURL=node-modules-bundler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-modules-bundler.d.ts","sourceRoot":"","sources":["../../../src/utils/node-modules-bundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"node-modules-bundler.d.ts","sourceRoot":"","sources":["../../../src/utils/node-modules-bundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAanC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAiE/E,wBAAsB,+BAA+B,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC;IAChG,GAAG,EAAE,OAAO,CAAC,YAAY,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B,CAAC,CAqFD"}
|
|
@@ -3,7 +3,6 @@ import * as path from 'path';
|
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import { transformSupportedBrowsersToTargets, getSupportedBrowsers, JavaScriptTransformer, Cache, } from '@angular/build/private';
|
|
5
5
|
import { normalizeSourceMaps } from '@angular-devkit/build-angular/src/utils/index.js';
|
|
6
|
-
import { createSharedMappingsPlugin } from './shared-mappings-plugin.js';
|
|
7
6
|
const LINKER_DECLARATION_PREFIX = 'ɵɵngDeclare';
|
|
8
7
|
/**
|
|
9
8
|
* Excludes @angular/core and @angular/compiler which define the declarations
|
|
@@ -49,7 +48,8 @@ function getOrCreateJsTransformerCacheStore(cachePath) {
|
|
|
49
48
|
}
|
|
50
49
|
return store;
|
|
51
50
|
}
|
|
52
|
-
export async function createNodeModulesEsbuildContext(
|
|
51
|
+
export async function createNodeModulesEsbuildContext(options) {
|
|
52
|
+
const { builderOptions, context, entryPoints, external, outdir, cache, dev, hash, chunks, platform, } = options;
|
|
53
53
|
const workspaceRoot = context.workspaceRoot;
|
|
54
54
|
const projectMetadata = await context.getProjectMetadata(context.target.project);
|
|
55
55
|
const projectRoot = path.join(workspaceRoot, projectMetadata['root'] ?? '');
|
|
@@ -91,13 +91,9 @@ export async function createNodeModulesEsbuildContext(builderOptions, context, e
|
|
|
91
91
|
format: 'esm',
|
|
92
92
|
target: target,
|
|
93
93
|
logLimit: 1,
|
|
94
|
-
plugins: [
|
|
95
|
-
createAngularLinkerPlugin(jsTransformer, advancedOptimizations),
|
|
96
|
-
...(mappedPaths && mappedPaths.length > 0 ? [createSharedMappingsPlugin(mappedPaths)] : []),
|
|
97
|
-
commonjsPlugin(),
|
|
98
|
-
],
|
|
94
|
+
plugins: [createAngularLinkerPlugin(jsTransformer, advancedOptimizations), commonjsPlugin()],
|
|
99
95
|
define: {
|
|
100
|
-
|
|
96
|
+
ngDevMode: dev ? 'true' : 'false',
|
|
101
97
|
ngJitMode: 'false',
|
|
102
98
|
},
|
|
103
99
|
...(builderOptions.loader ? { loader: builderOptions.loader } : {}),
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ApplicationBuilderOptions } from '@angular/build';
|
|
2
|
+
import type { BuilderContext } from '@angular-devkit/architect';
|
|
3
|
+
import type { SourceFileCache } from '@angular/build/private';
|
|
4
|
+
import type { FederationCache, EntryPoint, NFBuildAdapterOptions } from '@softarc/native-federation';
|
|
5
|
+
import type { PathToImport } from '@softarc/native-federation/internal';
|
|
6
|
+
export interface NormalizedContextOptions {
|
|
7
|
+
builderOptions: ApplicationBuilderOptions;
|
|
8
|
+
context: BuilderContext;
|
|
9
|
+
entryPoints: EntryPoint[];
|
|
10
|
+
external: string[];
|
|
11
|
+
outdir: string;
|
|
12
|
+
tsConfigPath?: string;
|
|
13
|
+
mappedPaths: PathToImport;
|
|
14
|
+
cache: FederationCache<SourceFileCache>;
|
|
15
|
+
dev: boolean;
|
|
16
|
+
isMappingOrExposed: boolean;
|
|
17
|
+
hash: boolean;
|
|
18
|
+
chunks?: boolean;
|
|
19
|
+
platform?: 'browser' | 'node';
|
|
20
|
+
optimizedMappings: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function normalizeContextOptions(builderOptions: ApplicationBuilderOptions, context: BuilderContext, adapterOptions: NFBuildAdapterOptions<SourceFileCache>): NormalizedContextOptions;
|
|
23
|
+
//# sourceMappingURL=normalize-context-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-context-options.d.ts","sourceRoot":"","sources":["../../../src/utils/normalize-context-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAExE,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,yBAAyB,CAAC;IAC1C,OAAO,EAAE,cAAc,CAAC;IACxB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,YAAY,CAAC;IAC1B,KAAK,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;IACxC,GAAG,EAAE,OAAO,CAAC;IACb,kBAAkB,EAAE,OAAO,CAAC;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9B,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,yBAAyB,EACzC,OAAO,EAAE,cAAc,EACvB,cAAc,EAAE,qBAAqB,CAAC,eAAe,CAAC,GACrD,wBAAwB,CAiB1B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function normalizeContextOptions(builderOptions, context, adapterOptions) {
|
|
2
|
+
return {
|
|
3
|
+
builderOptions,
|
|
4
|
+
context,
|
|
5
|
+
entryPoints: adapterOptions.entryPoints,
|
|
6
|
+
external: adapterOptions.external,
|
|
7
|
+
outdir: adapterOptions.outdir,
|
|
8
|
+
tsConfigPath: adapterOptions.tsConfigPath,
|
|
9
|
+
mappedPaths: adapterOptions.mappedPaths,
|
|
10
|
+
cache: adapterOptions.cache,
|
|
11
|
+
dev: !!adapterOptions.dev,
|
|
12
|
+
isMappingOrExposed: !!adapterOptions.isMappingOrExposed,
|
|
13
|
+
hash: !!adapterOptions.hash,
|
|
14
|
+
chunks: adapterOptions.chunks,
|
|
15
|
+
platform: adapterOptions.platform,
|
|
16
|
+
optimizedMappings: !!adapterOptions.optimizedMappings,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Plugin } from 'esbuild';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function createSharedMappingsPlugin(mappedPaths:
|
|
2
|
+
import type { PathToImport } from '@softarc/native-federation/internal';
|
|
3
|
+
export declare function createSharedMappingsPlugin(mappedPaths: PathToImport): Plugin;
|
|
4
4
|
//# sourceMappingURL=shared-mappings-plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-mappings-plugin.d.ts","sourceRoot":"","sources":["../../../src/utils/shared-mappings-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,SAAS,CAAC;AAEnD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"shared-mappings-plugin.d.ts","sourceRoot":"","sources":["../../../src/utils/shared-mappings-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,SAAS,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAExE,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,YAAY,GAAG,MAAM,CA8B5E"}
|
|
@@ -4,20 +4,20 @@ export function createSharedMappingsPlugin(mappedPaths) {
|
|
|
4
4
|
name: 'custom',
|
|
5
5
|
setup(build) {
|
|
6
6
|
build.onResolve({ filter: /^[.]/ }, async (args) => {
|
|
7
|
-
let mappedPath =
|
|
7
|
+
let mappedPath = undefined;
|
|
8
8
|
let isSelf = false;
|
|
9
9
|
if (args.kind === 'import-statement') {
|
|
10
10
|
const importPath = path.join(args.resolveDir, args.path);
|
|
11
11
|
if (mappedPaths) {
|
|
12
|
-
mappedPath = mappedPaths.find(p => importPath.startsWith(path.dirname(p
|
|
12
|
+
mappedPath = Object.keys(mappedPaths).find(p => importPath.startsWith(path.dirname(p)));
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
if (mappedPath) {
|
|
16
|
-
isSelf = args.importer.startsWith(path.dirname(mappedPath
|
|
16
|
+
isSelf = args.importer.startsWith(path.dirname(mappedPath));
|
|
17
17
|
}
|
|
18
18
|
if (mappedPath && !isSelf) {
|
|
19
19
|
return {
|
|
20
|
-
path: mappedPath
|
|
20
|
+
path: mappedPaths[mappedPath],
|
|
21
21
|
external: true,
|
|
22
22
|
};
|
|
23
23
|
}
|