@angular-architects/native-federation-v4 21.1.4 → 21.1.7
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/README.md +7 -7
- package/migration-collection.json +1 -1
- package/package.json +16 -8
- package/src/builders/build/builder.d.ts +2 -1
- package/src/builders/build/builder.d.ts.map +1 -1
- package/src/builders/build/builder.js +117 -113
- package/src/builders/build/schema.d.ts +1 -0
- package/src/builders/build/schema.json +3 -0
- package/src/builders/build/setup-builder-env-variables.d.ts +2 -0
- package/src/builders/build/setup-builder-env-variables.d.ts.map +1 -0
- package/src/builders/build/setup-builder-env-variables.js +9 -0
- package/src/plugin/externals-skip-list.js +1 -1
- package/src/utils/angular-bundler.d.ts +12 -0
- package/src/utils/angular-bundler.d.ts.map +1 -0
- package/src/utils/angular-bundler.js +167 -0
- package/src/utils/angular-esbuild-adapter.d.ts +5 -5
- package/src/utils/angular-esbuild-adapter.d.ts.map +1 -1
- package/src/utils/angular-esbuild-adapter.js +81 -261
- package/src/utils/node-modules-bundler.d.ts +12 -0
- package/src/utils/node-modules-bundler.d.ts.map +1 -0
- package/src/utils/node-modules-bundler.js +113 -0
- package/src/utils/create-compiler-options.d.ts +0 -5
- package/src/utils/create-compiler-options.d.ts.map +0 -1
- package/src/utils/create-compiler-options.js +0 -42
- package/src/utils/event-source.d.ts +0 -10
- package/src/utils/event-source.d.ts.map +0 -1
- package/src/utils/event-source.js +0 -10
- package/src/utils/mem-resuts.d.ts +0 -29
- package/src/utils/mem-resuts.d.ts.map +0 -1
- package/src/utils/mem-resuts.js +0 -50
- package/src/utils/rebuild-events.d.ts +0 -8
- package/src/utils/rebuild-events.d.ts.map +0 -1
- package/src/utils/rebuild-events.js +0 -4
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import * as esbuild from 'esbuild';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import { transformSupportedBrowsersToTargets, getSupportedBrowsers, JavaScriptTransformer, Cache, } from '@angular/build/private';
|
|
5
|
+
import { normalizeSourceMaps } from '@angular-devkit/build-angular/src/utils/index.js';
|
|
6
|
+
import { createSharedMappingsPlugin } from './shared-mappings-plugin.js';
|
|
7
|
+
const LINKER_DECLARATION_PREFIX = 'ɵɵngDeclare';
|
|
8
|
+
/**
|
|
9
|
+
* Excludes @angular/core and @angular/compiler which define the declarations
|
|
10
|
+
* and would cause false positives.
|
|
11
|
+
*/
|
|
12
|
+
function requiresLinking(filePath, source) {
|
|
13
|
+
if (/[\\/]@angular[\\/](?:compiler|core)[\\/]/.test(filePath)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return source.includes(LINKER_DECLARATION_PREFIX);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates an esbuild plugin that applies the Angular linker to partially compiled
|
|
20
|
+
* Angular libraries like a design system.
|
|
21
|
+
*
|
|
22
|
+
* Uses Angular's JavaScriptTransformer which handles linking internally.
|
|
23
|
+
*/
|
|
24
|
+
function createAngularLinkerPlugin(jsTransformer, advancedOptimizations) {
|
|
25
|
+
return {
|
|
26
|
+
name: 'angular-linker',
|
|
27
|
+
setup(build) {
|
|
28
|
+
build.onLoad({ filter: /\.m?js$/ }, async (args) => {
|
|
29
|
+
const contents = await fs.promises.readFile(args.path, 'utf-8');
|
|
30
|
+
const needsLinking = requiresLinking(args.path, contents);
|
|
31
|
+
if (!needsLinking && !advancedOptimizations) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const result = await jsTransformer.transformData(args.path, contents, !needsLinking, undefined);
|
|
35
|
+
return {
|
|
36
|
+
contents: Buffer.from(result).toString('utf-8'),
|
|
37
|
+
loader: 'js',
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const jsTransformerCacheStores = new Map();
|
|
44
|
+
function getOrCreateJsTransformerCacheStore(cachePath) {
|
|
45
|
+
let store = jsTransformerCacheStores.get(cachePath);
|
|
46
|
+
if (!store) {
|
|
47
|
+
store = new Map();
|
|
48
|
+
jsTransformerCacheStores.set(cachePath, store);
|
|
49
|
+
}
|
|
50
|
+
return store;
|
|
51
|
+
}
|
|
52
|
+
export async function createNodeModulesEsbuildContext(builderOptions, context, entryPoints, external, outdir, mappedPaths, cache, dev, hash = false, chunks, platform) {
|
|
53
|
+
const workspaceRoot = context.workspaceRoot;
|
|
54
|
+
const projectMetadata = await context.getProjectMetadata(context.target.project);
|
|
55
|
+
const projectRoot = path.join(workspaceRoot, projectMetadata['root'] ?? '');
|
|
56
|
+
const browsers = getSupportedBrowsers(projectRoot, context.logger);
|
|
57
|
+
const target = transformSupportedBrowsersToTargets(browsers);
|
|
58
|
+
const sourcemapOptions = normalizeSourceMaps(builderOptions.sourceMap);
|
|
59
|
+
const commonjsPluginModule = await import('@chialab/esbuild-plugin-commonjs');
|
|
60
|
+
const commonjsPlugin = commonjsPluginModule.default;
|
|
61
|
+
// Create JavaScriptTransformer for handling Angular partial compilation linking
|
|
62
|
+
const advancedOptimizations = !dev;
|
|
63
|
+
const jsTransformerCacheStore = getOrCreateJsTransformerCacheStore(cache.cachePath);
|
|
64
|
+
const jsTransformerCache = new Cache(jsTransformerCacheStore, 'jstransformer');
|
|
65
|
+
const jsTransformer = new JavaScriptTransformer({
|
|
66
|
+
sourcemap: !!sourcemapOptions.scripts,
|
|
67
|
+
thirdPartySourcemaps: false,
|
|
68
|
+
advancedOptimizations,
|
|
69
|
+
jit: false,
|
|
70
|
+
}, 1, // maxThreads - keep low for node_modules bundling
|
|
71
|
+
jsTransformerCache);
|
|
72
|
+
const config = {
|
|
73
|
+
entryPoints: entryPoints.map(ep => ({
|
|
74
|
+
in: ep.fileName,
|
|
75
|
+
out: path.parse(ep.outName).name,
|
|
76
|
+
})),
|
|
77
|
+
outdir,
|
|
78
|
+
entryNames: hash ? '[name]-[hash]' : '[name]',
|
|
79
|
+
write: false,
|
|
80
|
+
external,
|
|
81
|
+
logLevel: 'warning',
|
|
82
|
+
bundle: true,
|
|
83
|
+
sourcemap: sourcemapOptions.scripts,
|
|
84
|
+
minify: !dev,
|
|
85
|
+
supported: {
|
|
86
|
+
'async-await': false,
|
|
87
|
+
'object-rest-spread': false,
|
|
88
|
+
},
|
|
89
|
+
splitting: chunks,
|
|
90
|
+
platform: platform ?? 'browser',
|
|
91
|
+
format: 'esm',
|
|
92
|
+
target: target,
|
|
93
|
+
logLimit: 1,
|
|
94
|
+
plugins: [
|
|
95
|
+
createAngularLinkerPlugin(jsTransformer, advancedOptimizations),
|
|
96
|
+
...(mappedPaths && mappedPaths.length > 0 ? [createSharedMappingsPlugin(mappedPaths)] : []),
|
|
97
|
+
commonjsPlugin(),
|
|
98
|
+
],
|
|
99
|
+
define: {
|
|
100
|
+
...(!dev ? { ngDevMode: 'false' } : {}),
|
|
101
|
+
ngJitMode: 'false',
|
|
102
|
+
},
|
|
103
|
+
...(builderOptions.loader ? { loader: builderOptions.loader } : {}),
|
|
104
|
+
resolveExtensions: ['.mjs', '.js', '.cjs'],
|
|
105
|
+
};
|
|
106
|
+
const ctx = await esbuild.context(config);
|
|
107
|
+
const originalDispose = ctx.dispose.bind(ctx);
|
|
108
|
+
ctx.dispose = async () => {
|
|
109
|
+
await originalDispose();
|
|
110
|
+
await jsTransformer.close();
|
|
111
|
+
};
|
|
112
|
+
return { ctx, pluginDisposed: Promise.resolve() };
|
|
113
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-compiler-options.d.ts","sourceRoot":"","sources":["../../../src/utils/create-compiler-options.ts"],"names":[],"mappings":"AAGA,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,EAAE,EAChB,eAAe,CAAC,EAAE,GAAG,GACpB;IACD,aAAa,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IACtB,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;CACtB,CA0DA"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// Taken from https://github.com/angular/angular-cli/blob/main/packages/angular/build/src/tools/esbuild/compiler-plugin-options.ts
|
|
2
|
-
// Currently, this type cannot be accessed from the outside
|
|
3
|
-
export function createCompilerPluginOptions(options, target, sourceFileCache) {
|
|
4
|
-
const { workspaceRoot, optimizationOptions, sourcemapOptions, tsconfig, outputNames, fileReplacements, externalDependencies, preserveSymlinks, stylePreprocessorOptions, advancedOptimizations, inlineStyleLanguage, jit, cacheOptions, tailwindConfiguration, postcssConfiguration, publicPath, } = options;
|
|
5
|
-
return {
|
|
6
|
-
// JS/TS options
|
|
7
|
-
pluginOptions: {
|
|
8
|
-
sourcemap: !!sourcemapOptions.scripts &&
|
|
9
|
-
(sourcemapOptions.hidden ? 'external' : true),
|
|
10
|
-
thirdPartySourcemaps: sourcemapOptions.vendor,
|
|
11
|
-
tsconfig,
|
|
12
|
-
jit,
|
|
13
|
-
advancedOptimizations,
|
|
14
|
-
fileReplacements,
|
|
15
|
-
sourceFileCache,
|
|
16
|
-
loadResultCache: sourceFileCache?.loadResultCache,
|
|
17
|
-
incremental: !!options.watch,
|
|
18
|
-
},
|
|
19
|
-
// Component stylesheet options
|
|
20
|
-
styleOptions: {
|
|
21
|
-
workspaceRoot,
|
|
22
|
-
inlineFonts: !!optimizationOptions.fonts.inline,
|
|
23
|
-
optimization: !!optimizationOptions.styles.minify,
|
|
24
|
-
sourcemap:
|
|
25
|
-
// Hidden component stylesheet sourcemaps are inaccessible which is effectively
|
|
26
|
-
// the same as being disabled. Disabling has the advantage of avoiding the overhead
|
|
27
|
-
// of sourcemap processing.
|
|
28
|
-
sourcemapOptions.styles && !sourcemapOptions.hidden ? 'linked' : false,
|
|
29
|
-
outputNames,
|
|
30
|
-
includePaths: stylePreprocessorOptions?.includePaths,
|
|
31
|
-
sass: stylePreprocessorOptions?.sass,
|
|
32
|
-
externalDependencies,
|
|
33
|
-
target,
|
|
34
|
-
inlineStyleLanguage,
|
|
35
|
-
preserveSymlinks,
|
|
36
|
-
tailwindConfiguration,
|
|
37
|
-
postcssConfiguration,
|
|
38
|
-
cacheOptions,
|
|
39
|
-
publicPath,
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type EventHandler = () => Promise<void>;
|
|
2
|
-
export interface EventSource {
|
|
3
|
-
register(handler: EventHandler): void;
|
|
4
|
-
}
|
|
5
|
-
export declare class EventHub implements EventSource {
|
|
6
|
-
private handlers;
|
|
7
|
-
register(handler: EventHandler): void;
|
|
8
|
-
emit(): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=event-source.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-source.d.ts","sourceRoot":"","sources":["../../../src/utils/event-source.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAE/C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;CACvC;AAED,qBAAa,QAAS,YAAW,WAAW;IAC1C,OAAO,CAAC,QAAQ,CAAsB;IAEtC,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAI/B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAI5B"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { OutputFile } from 'esbuild';
|
|
2
|
-
export interface BuildResult {
|
|
3
|
-
fileName: string;
|
|
4
|
-
get(): Uint8Array | Buffer;
|
|
5
|
-
}
|
|
6
|
-
export declare class EsBuildResult implements BuildResult {
|
|
7
|
-
private outputFile;
|
|
8
|
-
private fullOutDir?;
|
|
9
|
-
get fileName(): string;
|
|
10
|
-
constructor(outputFile: OutputFile, fullOutDir?: string | undefined);
|
|
11
|
-
get(): Uint8Array;
|
|
12
|
-
}
|
|
13
|
-
export interface NgCliAssetFile {
|
|
14
|
-
source: string;
|
|
15
|
-
destination: string;
|
|
16
|
-
}
|
|
17
|
-
export declare class NgCliAssetResult implements BuildResult {
|
|
18
|
-
get fileName(): string;
|
|
19
|
-
private file;
|
|
20
|
-
constructor(assetFile: NgCliAssetFile);
|
|
21
|
-
get(): Buffer;
|
|
22
|
-
}
|
|
23
|
-
export declare class MemResults {
|
|
24
|
-
private map;
|
|
25
|
-
add(result: BuildResult[]): void;
|
|
26
|
-
get(fileName: string): BuildResult | undefined;
|
|
27
|
-
getFileNames(): string[];
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=mem-resuts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mem-resuts.d.ts","sourceRoot":"","sources":["../../../src/utils/mem-resuts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI1C,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,IAAI,UAAU,GAAG,MAAM,CAAC;CAC5B;AAED,qBAAa,aAAc,YAAW,WAAW;IASnC,OAAO,CAAC,UAAU;IAAc,OAAO,CAAC,UAAU,CAAC;IAR/D,IAAI,QAAQ,WAMX;gBAEmB,UAAU,EAAE,UAAU,EAAU,UAAU,CAAC,EAAE,MAAM,YAAA;IAEvE,GAAG,IAAI,UAAU;CAGlB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,gBAAiB,YAAW,WAAW;IAClD,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,OAAO,CAAC,IAAI,CAAiB;gBAEjB,SAAS,EAAE,cAAc;IAIrC,GAAG,IAAI,MAAM;CAGd;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAkC;IAEtC,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI;IAMhC,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAI9C,YAAY,IAAI,MAAM,EAAE;CAGhC"}
|
package/src/utils/mem-resuts.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
export class EsBuildResult {
|
|
4
|
-
outputFile;
|
|
5
|
-
fullOutDir;
|
|
6
|
-
get fileName() {
|
|
7
|
-
if (this.fullOutDir) {
|
|
8
|
-
return unify(path.relative(this.fullOutDir, this.outputFile.path));
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
return unify(this.outputFile.path);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
constructor(outputFile, fullOutDir) {
|
|
15
|
-
this.outputFile = outputFile;
|
|
16
|
-
this.fullOutDir = fullOutDir;
|
|
17
|
-
}
|
|
18
|
-
get() {
|
|
19
|
-
return this.outputFile.contents;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export class NgCliAssetResult {
|
|
23
|
-
get fileName() {
|
|
24
|
-
return unify(this.file.destination);
|
|
25
|
-
}
|
|
26
|
-
file;
|
|
27
|
-
constructor(assetFile) {
|
|
28
|
-
this.file = assetFile;
|
|
29
|
-
}
|
|
30
|
-
get() {
|
|
31
|
-
return fs.readFileSync(this.file.source);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export class MemResults {
|
|
35
|
-
map = new Map();
|
|
36
|
-
add(result) {
|
|
37
|
-
for (const file of result) {
|
|
38
|
-
this.map.set(file.fileName, file);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
get(fileName) {
|
|
42
|
-
return this.map.get(fileName);
|
|
43
|
-
}
|
|
44
|
-
getFileNames() {
|
|
45
|
-
return [...this.map.keys()];
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function unify(path) {
|
|
49
|
-
return path?.replace(/\\/g, '/');
|
|
50
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { EventHub, type EventSource } from './event-source.js';
|
|
2
|
-
export interface RebuildEvents {
|
|
3
|
-
readonly rebuild: EventSource;
|
|
4
|
-
}
|
|
5
|
-
export declare class RebuildHubs implements RebuildEvents {
|
|
6
|
-
readonly rebuild: EventHub;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=rebuild-events.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rebuild-events.d.ts","sourceRoot":"","sources":["../../../src/utils/rebuild-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;CAC/B;AAED,qBAAa,WAAY,YAAW,aAAa;IAC/C,QAAQ,CAAC,OAAO,WAAkB;CACnC"}
|