@nf-beta/angular 0.0.1 → 0.0.3
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/builders.json +10 -0
- package/collection.json +27 -0
- package/generators.json +12 -0
- package/migration-collection.json +13 -0
- package/package.json +29 -5
- package/src/builders/build/builder.d.ts +6 -0
- package/src/builders/build/builder.d.ts.map +1 -0
- package/src/builders/build/builder.js +348 -0
- package/src/builders/build/federation-build-notifier.d.ts +70 -0
- package/src/builders/build/federation-build-notifier.d.ts.map +1 -0
- package/src/builders/build/federation-build-notifier.js +186 -0
- package/src/builders/build/schema.d.ts +21 -0
- package/src/builders/build/schema.json +84 -0
- package/src/config.d.ts +3 -0
- package/src/config.d.ts.map +1 -0
- package/src/config.js +2 -0
- package/src/generators/native-federation/files/src/index.ts__template__ +1 -0
- package/src/generators/native-federation/generator.d.ts +4 -0
- package/src/generators/native-federation/generator.d.ts.map +1 -0
- package/src/generators/native-federation/generator.js +43 -0
- package/src/generators/native-federation/schema.d.ts +5 -0
- package/src/generators/native-federation/schema.json +29 -0
- package/src/index.d.ts +2 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +1 -0
- package/src/patch-angular-build.d.ts +2 -0
- package/src/patch-angular-build.d.ts.map +1 -0
- package/src/patch-angular-build.js +5 -0
- package/src/plugin/dev-externals-mixin.d.ts +3 -0
- package/src/plugin/dev-externals-mixin.d.ts.map +1 -0
- package/src/plugin/dev-externals-mixin.js +29 -0
- package/src/plugin/externals-skip-list.d.ts +3 -0
- package/src/plugin/externals-skip-list.d.ts.map +1 -0
- package/src/plugin/externals-skip-list.js +4 -0
- package/src/plugin/index.d.ts +4 -0
- package/src/plugin/index.d.ts.map +1 -0
- package/src/plugin/index.js +75 -0
- package/src/schematics/appbuilder/schema.d.ts +3 -0
- package/src/schematics/appbuilder/schema.json +17 -0
- package/src/schematics/appbuilder/schematic.d.ts +5 -0
- package/src/schematics/appbuilder/schematic.d.ts.map +1 -0
- package/src/schematics/appbuilder/schematic.js +83 -0
- package/src/schematics/init/files/federation.config.js__tmpl__ +33 -0
- package/src/schematics/init/schema.d.ts +6 -0
- package/src/schematics/init/schema.json +34 -0
- package/src/schematics/init/schematic.d.ts +7 -0
- package/src/schematics/init/schematic.d.ts.map +1 -0
- package/src/schematics/init/schematic.js +422 -0
- package/src/schematics/remove/schema.d.ts +3 -0
- package/src/schematics/remove/schema.json +17 -0
- package/src/schematics/remove/schematic.d.ts +5 -0
- package/src/schematics/remove/schematic.d.ts.map +1 -0
- package/src/schematics/remove/schematic.js +109 -0
- package/src/schematics/update18/schema.json +7 -0
- package/src/schematics/update18/schematic.d.ts +3 -0
- package/src/schematics/update18/schematic.d.ts.map +1 -0
- package/src/schematics/update18/schematic.js +7 -0
- package/src/tools/fstart-as-data-url.d.ts +2 -0
- package/src/tools/fstart-as-data-url.d.ts.map +1 -0
- package/src/tools/fstart-as-data-url.js +1 -0
- package/src/utils/angular-esbuild-adapter.d.ts +10 -0
- package/src/utils/angular-esbuild-adapter.d.ts.map +1 -0
- package/src/utils/angular-esbuild-adapter.js +289 -0
- package/src/utils/angular-locales.d.ts +19 -0
- package/src/utils/angular-locales.d.ts.map +1 -0
- package/src/utils/angular-locales.js +18 -0
- package/src/utils/create-awaitable-compiler-plugin.d.ts +6 -0
- package/src/utils/create-awaitable-compiler-plugin.d.ts.map +1 -0
- package/src/utils/create-awaitable-compiler-plugin.js +29 -0
- package/src/utils/create-compiler-options.d.ts +5 -0
- package/src/utils/create-compiler-options.d.ts.map +1 -0
- package/src/utils/create-compiler-options.js +42 -0
- package/src/utils/event-source.d.ts +10 -0
- package/src/utils/event-source.d.ts.map +1 -0
- package/src/utils/event-source.js +10 -0
- package/src/utils/i18n.d.ts +23 -0
- package/src/utils/i18n.d.ts.map +1 -0
- package/src/utils/i18n.js +61 -0
- package/src/utils/mem-resuts.d.ts +29 -0
- package/src/utils/mem-resuts.d.ts.map +1 -0
- package/src/utils/mem-resuts.js +50 -0
- package/src/utils/patch-angular-build.d.ts +4 -0
- package/src/utils/patch-angular-build.d.ts.map +1 -0
- package/src/utils/patch-angular-build.js +29 -0
- package/src/utils/rebuild-events.d.ts +8 -0
- package/src/utils/rebuild-events.d.ts.map +1 -0
- package/src/utils/rebuild-events.js +4 -0
- package/src/utils/shared-mappings-plugin.d.ts +4 -0
- package/src/utils/shared-mappings-plugin.d.ts.map +1 -0
- package/src/utils/shared-mappings-plugin.js +28 -0
- package/src/utils/updateIndexHtml.d.ts +5 -0
- package/src/utils/updateIndexHtml.d.ts.map +1 -0
- package/src/utils/updateIndexHtml.js +34 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-awaitable-compiler-plugin.d.ts","sourceRoot":"","sources":["../../../src/utils/create-awaitable-compiler-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,KAAK,0BAA0B,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE1E,wBAAgB,6BAA6B,CAC3C,aAAa,EAAE,0BAA0B,CAAC,CAAC,CAAC,EAC5C,YAAY,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAC1C,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CA+BjC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createCompilerPlugin } from '@angular/build/private';
|
|
2
|
+
export function createAwaitableCompilerPlugin(pluginOptions, styleOptions) {
|
|
3
|
+
const originalPlugin = createCompilerPlugin(pluginOptions, styleOptions);
|
|
4
|
+
let resolveDispose;
|
|
5
|
+
const onDisposePromise = new Promise(resolve => {
|
|
6
|
+
resolveDispose = resolve;
|
|
7
|
+
});
|
|
8
|
+
const wrappedPlugin = {
|
|
9
|
+
...originalPlugin,
|
|
10
|
+
setup(build) {
|
|
11
|
+
// Wrap the build object to intercept onDispose
|
|
12
|
+
const wrappedBuild = new Proxy(build, {
|
|
13
|
+
get(target, prop) {
|
|
14
|
+
if (prop === 'onDispose') {
|
|
15
|
+
return (callback) => {
|
|
16
|
+
return target.onDispose(() => {
|
|
17
|
+
callback();
|
|
18
|
+
resolveDispose();
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return target[prop];
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
return originalPlugin.setup(wrappedBuild);
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
return [wrappedPlugin, onDisposePromise];
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BuilderContext } from '@angular-devkit/architect';
|
|
2
|
+
import type { FederationInfo } from '@nf-beta/runtime';
|
|
3
|
+
export type WorkspaceConfig = {
|
|
4
|
+
i18n?: I18nConfig;
|
|
5
|
+
};
|
|
6
|
+
export type LocaleTranslation = string | string[];
|
|
7
|
+
export type LocaleObject = {
|
|
8
|
+
translation: LocaleTranslation;
|
|
9
|
+
baseHref?: string;
|
|
10
|
+
subPath?: string;
|
|
11
|
+
};
|
|
12
|
+
export type I18nConfig = {
|
|
13
|
+
sourceLocale: string | SourceLocaleObject;
|
|
14
|
+
locales: Record<string, LocaleTranslation | LocaleObject>;
|
|
15
|
+
};
|
|
16
|
+
export type SourceLocaleObject = {
|
|
17
|
+
code: string;
|
|
18
|
+
baseHref?: string;
|
|
19
|
+
subPath?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function getI18nConfig(context: BuilderContext): Promise<I18nConfig | undefined>;
|
|
22
|
+
export declare function translateFederationArtefacts(i18n: I18nConfig, localize: boolean | string[], outputPath: string, federationResult: FederationInfo): Promise<void>;
|
|
23
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../src/utils/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAKhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAElD,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,YAAY,EAAE,MAAM,GAAG,kBAAkB,CAAC;IAC1C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,YAAY,CAAC,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAsB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAO5F;AAED,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,OAAO,GAAG,MAAM,EAAE,EAC5B,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,cAAc,iBAgDjC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { logger } from '@nf-beta/core/build';
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
export async function getI18nConfig(context) {
|
|
6
|
+
const workspaceConfig = (await context.getProjectMetadata(context.target?.project || ''));
|
|
7
|
+
const i18nConfig = workspaceConfig?.i18n;
|
|
8
|
+
return i18nConfig;
|
|
9
|
+
}
|
|
10
|
+
export async function translateFederationArtefacts(i18n, localize, outputPath, federationResult) {
|
|
11
|
+
const neededLocales = Array.isArray(localize) ? localize : Object.keys(i18n.locales);
|
|
12
|
+
const locales = Object.keys(i18n.locales).filter(locale => neededLocales.includes(locale));
|
|
13
|
+
if (locales.length === 0) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
logger.info('Writing Translations');
|
|
17
|
+
const translationFiles = locales
|
|
18
|
+
.map(loc => i18n.locales[loc])
|
|
19
|
+
.map(config => typeof config === 'string' || Array.isArray(config) ? config : config.translation)
|
|
20
|
+
.map(files => JSON.stringify(files))
|
|
21
|
+
.join(' ');
|
|
22
|
+
const targetLocales = locales.join(' ');
|
|
23
|
+
const sourceLocale = typeof i18n.sourceLocale === 'string' ? i18n.sourceLocale : i18n.sourceLocale.code;
|
|
24
|
+
const translationOutPath = path.join(outputPath, 'browser', '{{LOCALE}}');
|
|
25
|
+
const federationFiles = [
|
|
26
|
+
...federationResult.shared.map(s => s.outFileName),
|
|
27
|
+
...federationResult.exposes.map(e => e.outFileName),
|
|
28
|
+
];
|
|
29
|
+
// Here, we use a glob with an exhaustive list i/o `"*.js"`
|
|
30
|
+
// to improve performance
|
|
31
|
+
const sourcePattern = '{' + federationFiles.join(',') + '}';
|
|
32
|
+
const sourceLocalePath = path.join(outputPath, 'browser', sourceLocale);
|
|
33
|
+
const localizeTranslate = path.resolve('node_modules/.bin/localize-translate');
|
|
34
|
+
const cmd = `${localizeTranslate} -r ${sourceLocalePath} -s "${sourcePattern}" -t ${translationFiles} -o ${translationOutPath} --target-locales ${targetLocales} -l ${sourceLocale}`;
|
|
35
|
+
ensureDistFolders(locales, outputPath);
|
|
36
|
+
copyRemoteEntry(locales, outputPath, sourceLocalePath);
|
|
37
|
+
logger.debug('Running: ' + cmd);
|
|
38
|
+
execCommand(cmd, 'Successfully translated');
|
|
39
|
+
}
|
|
40
|
+
function execCommand(cmd, defaultSuccessInfo) {
|
|
41
|
+
try {
|
|
42
|
+
const output = execSync(cmd);
|
|
43
|
+
logger.info(output.toString() || defaultSuccessInfo);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
logger.error(error.message);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function copyRemoteEntry(locales, outputPath, sourceLocalePath) {
|
|
50
|
+
const remoteEntry = path.join(sourceLocalePath, 'remoteEntry.json');
|
|
51
|
+
for (const locale of locales) {
|
|
52
|
+
const localePath = path.join(outputPath, 'browser', locale, 'remoteEntry.json');
|
|
53
|
+
fs.copyFileSync(remoteEntry, localePath);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function ensureDistFolders(locales, outputPath) {
|
|
57
|
+
for (const locale of locales) {
|
|
58
|
+
const localePath = path.join(outputPath, 'browser', locale);
|
|
59
|
+
fs.mkdirSync(localePath, { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const privateEntrySrc = "\nexports = require('./src/private.js');\n";
|
|
2
|
+
export declare function patchAngularBuildPackageJson(packageJson: any): void;
|
|
3
|
+
export declare function patchAngularBuild(workspaceRoot: string): void;
|
|
4
|
+
//# sourceMappingURL=patch-angular-build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch-angular-build.d.ts","sourceRoot":"","sources":["../../../src/utils/patch-angular-build.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,+CAE3B,CAAC;AAEF,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,GAAG,GAAG,IAAI,CAcnE;AAED,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAiB7D"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
export const privateEntrySrc = `
|
|
4
|
+
exports = require('./src/private.js');
|
|
5
|
+
`;
|
|
6
|
+
export function patchAngularBuildPackageJson(packageJson) {
|
|
7
|
+
const exportsMap = packageJson['exports'];
|
|
8
|
+
if (!exportsMap) {
|
|
9
|
+
console.log('No need to patch @angular/build/package.json');
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
packageJson['_exports'] = exportsMap;
|
|
13
|
+
delete packageJson['exports'];
|
|
14
|
+
packageJson['types'] = './src/index.d.ts';
|
|
15
|
+
packageJson['main'] = './src/index.js';
|
|
16
|
+
packageJson['module'] = './src/index.js';
|
|
17
|
+
}
|
|
18
|
+
export function patchAngularBuild(workspaceRoot) {
|
|
19
|
+
const packagePath = path.join(workspaceRoot, 'node_modules/@angular/build/package.json');
|
|
20
|
+
const privatePath = path.join(workspaceRoot, 'node_modules/@angular/build/private.js');
|
|
21
|
+
if (!fs.existsSync(packagePath)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8'));
|
|
25
|
+
patchAngularBuildPackageJson(packageJson);
|
|
26
|
+
fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2));
|
|
27
|
+
fs.writeFileSync(privatePath, privateEntrySrc);
|
|
28
|
+
console.log('@angular/build/package.json patched');
|
|
29
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +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,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,CA8B5E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
export function createSharedMappingsPlugin(mappedPaths) {
|
|
3
|
+
return {
|
|
4
|
+
name: 'custom',
|
|
5
|
+
setup(build) {
|
|
6
|
+
build.onResolve({ filter: /^[.]/ }, async (args) => {
|
|
7
|
+
let mappedPath = null;
|
|
8
|
+
let isSelf = false;
|
|
9
|
+
if (args.kind === 'import-statement') {
|
|
10
|
+
const importPath = path.join(args.resolveDir, args.path);
|
|
11
|
+
if (mappedPaths) {
|
|
12
|
+
mappedPath = mappedPaths.find(p => importPath.startsWith(path.dirname(p.path))) ?? null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (mappedPath) {
|
|
16
|
+
isSelf = args.importer.startsWith(path.dirname(mappedPath.path));
|
|
17
|
+
}
|
|
18
|
+
if (mappedPath && !isSelf) {
|
|
19
|
+
return {
|
|
20
|
+
path: mappedPath.key,
|
|
21
|
+
external: true,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return {};
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FederationOptions } from '@nf-beta/core/build';
|
|
2
|
+
import type { NfBuilderSchema } from '../builders/build/schema.js';
|
|
3
|
+
export declare function updateIndexHtml(fedOptions: FederationOptions, nfOptions: NfBuilderSchema): void;
|
|
4
|
+
export declare function updateScriptTags(indexContent: string, nfOptions: NfBuilderSchema): string;
|
|
5
|
+
//# sourceMappingURL=updateIndexHtml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateIndexHtml.d.ts","sourceRoot":"","sources":["../../../src/utils/updateIndexHtml.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,wBAAgB,eAAe,CAAC,UAAU,EAAE,iBAAiB,EAAE,SAAS,EAAE,eAAe,QAuBxF;AAED,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,UAqBhF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
export function updateIndexHtml(fedOptions, nfOptions) {
|
|
4
|
+
const outputPath = path.join(fedOptions.workspaceRoot, fedOptions.outputPath);
|
|
5
|
+
const indexPathCands = [
|
|
6
|
+
path.join(outputPath, '../server/index.server.html'),
|
|
7
|
+
path.join(outputPath, 'index.html'),
|
|
8
|
+
];
|
|
9
|
+
const indexPath = indexPathCands.find(c => fs.existsSync(c));
|
|
10
|
+
if (!indexPath) {
|
|
11
|
+
console.error('No index.html found! Searched locations: ', indexPathCands.join(', '));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
// const mainName = fs.readdirSync(outputPath).find(f => f.startsWith('main') && f.endsWith('.js'));
|
|
15
|
+
// const polyfillsName = fs
|
|
16
|
+
// .readdirSync(outputPath)
|
|
17
|
+
// .find(f => f.startsWith('polyfills') && f.endsWith('.js'));
|
|
18
|
+
let indexContent = fs.readFileSync(indexPath, 'utf-8');
|
|
19
|
+
indexContent = updateScriptTags(indexContent, nfOptions);
|
|
20
|
+
fs.writeFileSync(indexPath, indexContent, 'utf-8');
|
|
21
|
+
}
|
|
22
|
+
export function updateScriptTags(indexContent, nfOptions) {
|
|
23
|
+
const esmsOptions = {
|
|
24
|
+
shimMode: true,
|
|
25
|
+
...nfOptions.esmsInitOptions,
|
|
26
|
+
};
|
|
27
|
+
const htmlFragment = `
|
|
28
|
+
<script type="esms-options">${JSON.stringify(esmsOptions)}</script>
|
|
29
|
+
`;
|
|
30
|
+
indexContent = indexContent.replace(/<script\s+src="([^"]*polyfills[^"]*)"[^>]*><\/script>/, '<script type="module" src="$1"></script>');
|
|
31
|
+
indexContent = indexContent.replace(/<script\s+src="([^"]*main[^"]*)"[^>]*><\/script>/, '<script type="module-shim" src="$1"></script>');
|
|
32
|
+
indexContent = indexContent.replace(/(<body.*?>)/, `$1\n\t\t${htmlFragment}`);
|
|
33
|
+
return indexContent;
|
|
34
|
+
}
|