@nf-beta/angular 0.0.1 → 0.0.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 (95) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +458 -0
  3. package/builders.json +10 -0
  4. package/collection.json +27 -0
  5. package/generators.json +12 -0
  6. package/migration-collection.json +13 -0
  7. package/package.json +18 -8
  8. package/src/builders/build/builder.d.ts +6 -0
  9. package/src/builders/build/builder.d.ts.map +1 -0
  10. package/src/builders/build/builder.js +348 -0
  11. package/src/builders/build/federation-build-notifier.d.ts +70 -0
  12. package/src/builders/build/federation-build-notifier.d.ts.map +1 -0
  13. package/src/builders/build/federation-build-notifier.js +186 -0
  14. package/src/builders/build/schema.d.ts +21 -0
  15. package/src/builders/build/schema.json +84 -0
  16. package/src/config.d.ts +3 -0
  17. package/src/config.d.ts.map +1 -0
  18. package/src/config.js +2 -0
  19. package/src/generators/native-federation/files/src/index.ts__template__ +1 -0
  20. package/src/generators/native-federation/generator.d.ts +4 -0
  21. package/src/generators/native-federation/generator.d.ts.map +1 -0
  22. package/src/generators/native-federation/generator.js +43 -0
  23. package/src/generators/native-federation/schema.d.ts +5 -0
  24. package/src/generators/native-federation/schema.json +29 -0
  25. package/src/index.d.ts +2 -0
  26. package/src/index.d.ts.map +1 -0
  27. package/src/index.js +1 -0
  28. package/src/patch-angular-build.d.ts +2 -0
  29. package/src/patch-angular-build.d.ts.map +1 -0
  30. package/src/patch-angular-build.js +5 -0
  31. package/src/plugin/dev-externals-mixin.d.ts +3 -0
  32. package/src/plugin/dev-externals-mixin.d.ts.map +1 -0
  33. package/src/plugin/dev-externals-mixin.js +29 -0
  34. package/src/plugin/externals-skip-list.d.ts +3 -0
  35. package/src/plugin/externals-skip-list.d.ts.map +1 -0
  36. package/src/plugin/externals-skip-list.js +4 -0
  37. package/src/plugin/index.d.ts +4 -0
  38. package/src/plugin/index.d.ts.map +1 -0
  39. package/src/plugin/index.js +75 -0
  40. package/src/schematics/appbuilder/schema.d.ts +3 -0
  41. package/src/schematics/appbuilder/schema.json +17 -0
  42. package/src/schematics/appbuilder/schematic.d.ts +5 -0
  43. package/src/schematics/appbuilder/schematic.d.ts.map +1 -0
  44. package/src/schematics/appbuilder/schematic.js +83 -0
  45. package/src/schematics/init/files/federation.config.js__tmpl__ +33 -0
  46. package/src/schematics/init/schema.d.ts +6 -0
  47. package/src/schematics/init/schema.json +34 -0
  48. package/src/schematics/init/schematic.d.ts +7 -0
  49. package/src/schematics/init/schematic.d.ts.map +1 -0
  50. package/src/schematics/init/schematic.js +422 -0
  51. package/src/schematics/remove/schema.d.ts +3 -0
  52. package/src/schematics/remove/schema.json +17 -0
  53. package/src/schematics/remove/schematic.d.ts +5 -0
  54. package/src/schematics/remove/schematic.d.ts.map +1 -0
  55. package/src/schematics/remove/schematic.js +109 -0
  56. package/src/schematics/update18/schema.json +7 -0
  57. package/src/schematics/update18/schematic.d.ts +3 -0
  58. package/src/schematics/update18/schematic.d.ts.map +1 -0
  59. package/src/schematics/update18/schematic.js +7 -0
  60. package/src/tools/fstart-as-data-url.d.ts +2 -0
  61. package/src/tools/fstart-as-data-url.d.ts.map +1 -0
  62. package/src/tools/fstart-as-data-url.js +1 -0
  63. package/src/utils/angular-esbuild-adapter.d.ts +10 -0
  64. package/src/utils/angular-esbuild-adapter.d.ts.map +1 -0
  65. package/src/utils/angular-esbuild-adapter.js +289 -0
  66. package/src/utils/angular-locales.d.ts +19 -0
  67. package/src/utils/angular-locales.d.ts.map +1 -0
  68. package/src/utils/angular-locales.js +18 -0
  69. package/src/utils/create-awaitable-compiler-plugin.d.ts +6 -0
  70. package/src/utils/create-awaitable-compiler-plugin.d.ts.map +1 -0
  71. package/src/utils/create-awaitable-compiler-plugin.js +29 -0
  72. package/src/utils/create-compiler-options.d.ts +5 -0
  73. package/src/utils/create-compiler-options.d.ts.map +1 -0
  74. package/src/utils/create-compiler-options.js +42 -0
  75. package/src/utils/event-source.d.ts +10 -0
  76. package/src/utils/event-source.d.ts.map +1 -0
  77. package/src/utils/event-source.js +10 -0
  78. package/src/utils/i18n.d.ts +23 -0
  79. package/src/utils/i18n.d.ts.map +1 -0
  80. package/src/utils/i18n.js +61 -0
  81. package/src/utils/mem-resuts.d.ts +29 -0
  82. package/src/utils/mem-resuts.d.ts.map +1 -0
  83. package/src/utils/mem-resuts.js +50 -0
  84. package/src/utils/patch-angular-build.d.ts +4 -0
  85. package/src/utils/patch-angular-build.d.ts.map +1 -0
  86. package/src/utils/patch-angular-build.js +29 -0
  87. package/src/utils/rebuild-events.d.ts +8 -0
  88. package/src/utils/rebuild-events.d.ts.map +1 -0
  89. package/src/utils/rebuild-events.js +4 -0
  90. package/src/utils/shared-mappings-plugin.d.ts +4 -0
  91. package/src/utils/shared-mappings-plugin.d.ts.map +1 -0
  92. package/src/utils/shared-mappings-plugin.js +28 -0
  93. package/src/utils/updateIndexHtml.d.ts +5 -0
  94. package/src/utils/updateIndexHtml.d.ts.map +1 -0
  95. package/src/utils/updateIndexHtml.js +34 -0
@@ -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,4 @@
1
+ import { EventHub } from './event-source.js';
2
+ export class RebuildHubs {
3
+ rebuild = new EventHub();
4
+ }
@@ -0,0 +1,4 @@
1
+ import type { Plugin } from 'esbuild';
2
+ import type { MappedPath } from '@nf-beta/core/build';
3
+ export declare function createSharedMappingsPlugin(mappedPaths: MappedPath[]): Plugin;
4
+ //# sourceMappingURL=shared-mappings-plugin.d.ts.map
@@ -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
+ }