@nx/angular 20.0.8 → 20.1.0-beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. package/esm2022/mf/mf.mjs +65 -1
  2. package/fesm2022/nx-angular-mf.mjs +64 -0
  3. package/fesm2022/nx-angular-mf.mjs.map +1 -1
  4. package/mf/mf.d.ts +64 -0
  5. package/package.json +8 -8
  6. package/src/generators/application/files/ng-module/src/app/app.component.html__tpl__ +8 -1
  7. package/src/generators/application/files/standalone-components/src/app/app.component.html__tpl__ +8 -1
  8. package/src/generators/application/lib/add-unit-test-runner.js +18 -7
  9. package/src/generators/application/schema.json +2 -1
  10. package/src/generators/component/files/__fileName__.__style__ +1 -1
  11. package/src/generators/component-story/files/__componentFileName__.stories.ts__tmpl__ +4 -4
  12. package/src/generators/federate-module/schema.json +2 -1
  13. package/src/generators/host/schema.json +2 -1
  14. package/src/generators/library/files/base/README.md__tpl__ +2 -2
  15. package/src/generators/library/library.js +19 -7
  16. package/src/generators/library/schema.json +2 -1
  17. package/src/generators/remote/schema.json +2 -1
  18. package/src/generators/setup-mf/lib/add-remote-to-host.js +21 -8
  19. package/src/generators/setup-mf/lib/fix-bootstrap.js +3 -2
  20. package/src/generators/setup-mf/setup-mf.js +3 -2
  21. package/src/generators/utils/add-jest.js +4 -4
  22. package/src/generators/utils/add-vitest.d.ts +8 -0
  23. package/src/generators/utils/add-vitest.js +49 -0
  24. package/src/utils/backward-compatible-versions.d.ts +2 -2
  25. package/src/utils/test-runners.d.ts +2 -1
  26. package/src/utils/test-runners.js +1 -0
  27. package/src/utils/versions.d.ts +2 -1
  28. package/src/utils/versions.js +3 -2
package/esm2022/mf/mf.mjs CHANGED
@@ -1,17 +1,81 @@
1
1
  let resolveRemoteUrl;
2
+ /**
3
+ * @deprecated Use Runtime Helpers from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
4
+ */
2
5
  export function setRemoteUrlResolver(_resolveRemoteUrl) {
3
6
  resolveRemoteUrl = _resolveRemoteUrl;
4
7
  }
5
8
  let remoteUrlDefinitions;
9
+ /**
10
+ * @deprecated Use init() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
11
+ * If you have a remote app called `my-remote-app` and you want to use the `http://localhost:4201/mf-manifest.json` as the remote url, you should change it from:
12
+ * ```ts
13
+ * import { setRemoteDefinitions } from '@nx/angular/mf';
14
+ *
15
+ * setRemoteDefinitions({
16
+ * 'my-remote-app': 'http://localhost:4201/mf-manifest.json'
17
+ * });
18
+ * ```
19
+ * to use init():
20
+ * ```ts
21
+ * import { init } from '@module-federation/enhanced/runtime';
22
+ *
23
+ * init({
24
+ * name: 'host',
25
+ * remotes: [{
26
+ * name: 'my-remote-app',
27
+ * entry: 'http://localhost:4201/mf-manifest.json'
28
+ * }]
29
+ * });
30
+ * ```
31
+ */
6
32
  export function setRemoteDefinitions(definitions) {
7
33
  remoteUrlDefinitions = definitions;
8
34
  }
35
+ /**
36
+ * @deprecated Use registerRemotes() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
37
+ * If you set a remote app with `setRemoteDefinition` such as:
38
+ * ```ts
39
+ * import { setRemoteDefinition } from '@nx/angular/mf';
40
+ *
41
+ * setRemoteDefinition(
42
+ * 'my-remote-app',
43
+ * 'http://localhost:4201/mf-manifest.json'
44
+ * );
45
+ * ```
46
+ * change it to use registerRemotes():
47
+ * ```ts
48
+ * import { registerRemotes } from '@module-federation/enhanced/runtime';
49
+ *
50
+ * registerRemotes([
51
+ * {
52
+ * name: 'my-remote-app',
53
+ * entry: 'http://localhost:4201/mf-manifest.json'
54
+ * }
55
+ * ]);
56
+ * ```
57
+ */
9
58
  export function setRemoteDefinition(remoteName, remoteUrl) {
10
59
  remoteUrlDefinitions ??= {};
11
60
  remoteUrlDefinitions[remoteName] = remoteUrl;
12
61
  }
13
62
  let remoteModuleMap = new Map();
14
63
  let remoteContainerMap = new Map();
64
+ /**
65
+ * @deprecated Use loadRemote() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
66
+ * If you set a load a remote with `loadRemoteModule` such as:
67
+ * ```ts
68
+ * import { loadRemoteModule } from '@nx/angular/mf';
69
+ *
70
+ * loadRemoteModule('my-remote-app', './Module').then(m => m.RemoteEntryModule);
71
+ * ```
72
+ * change it to use loadRemote():
73
+ * ```ts
74
+ * import { loadRemote } from '@module-federation/enhanced/runtime';
75
+ *
76
+ * loadRemote<typeof import('my-remote-app/Module')>('my-remote-app/Module').then(m => m.RemoteEntryModule);
77
+ * ```
78
+ */
15
79
  export async function loadRemoteModule(remoteName, moduleName) {
16
80
  const remoteModuleKey = `${remoteName}:${moduleName}`;
17
81
  if (remoteModuleMap.has(remoteModuleKey)) {
@@ -49,4 +113,4 @@ async function loadRemoteContainer(remoteName) {
49
113
  remoteContainerMap.set(remoteName, container);
50
114
  return container;
51
115
  }
52
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWYuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9hbmd1bGFyL21mL21mLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQU9BLElBQUksZ0JBQTBDLENBQUM7QUFFL0MsTUFBTSxVQUFVLG9CQUFvQixDQUNsQyxpQkFBMkM7SUFFM0MsZ0JBQWdCLEdBQUcsaUJBQWlCLENBQUM7QUFDdkMsQ0FBQztBQUVELElBQUksb0JBQTRDLENBQUM7QUFFakQsTUFBTSxVQUFVLG9CQUFvQixDQUFDLFdBQW1DO0lBQ3RFLG9CQUFvQixHQUFHLFdBQVcsQ0FBQztBQUNyQyxDQUFDO0FBRUQsTUFBTSxVQUFVLG1CQUFtQixDQUFDLFVBQWtCLEVBQUUsU0FBaUI7SUFDdkUsb0JBQW9CLEtBQUssRUFBRSxDQUFDO0lBQzVCLG9CQUFvQixDQUFDLFVBQVUsQ0FBQyxHQUFHLFNBQVMsQ0FBQztBQUMvQyxDQUFDO0FBRUQsSUFBSSxlQUFlLEdBQ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KCFyZW1vdGVVcmwuZW5kc1dpdGgoJy5tanMnKSAmJiAhcmVtb3RlVXJsLmVuZHNXaXRoKCcuanMnKSkge1xuICAgIGNvbnRhaW5lclVybCA9IGAke3JlbW90ZVVybH0ke1xuICAgICAgcmVtb3RlVXJsLmVuZHNXaXRoKCcvJykgPyAnJyA6ICcvJ1xuICAgIH1yZW1vdGVFbnRyeS5tanNgO1xuICB9XG5cbiAgY29uc3QgY29udGFpbmVyID0gYXdhaXQgbG9hZE1vZHVsZShjb250YWluZXJVcmwpO1xuICBhd2FpdCBjb250YWluZXIuaW5pdChfX3dlYnBhY2tfc2hhcmVfc2NvcGVzX18uZGVmYXVsdCk7XG5cbiAgcmVtb3RlQ29udGFpbmVyTWFwLnNldChyZW1vdGVOYW1lLCBjb250YWluZXIpO1xuICByZXR1cm4gY29udGFpbmVyO1xufVxuIl19
@@ -1,17 +1,81 @@
1
1
  let resolveRemoteUrl;
2
+ /**
3
+ * @deprecated Use Runtime Helpers from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
4
+ */
2
5
  function setRemoteUrlResolver(_resolveRemoteUrl) {
3
6
  resolveRemoteUrl = _resolveRemoteUrl;
4
7
  }
5
8
  let remoteUrlDefinitions;
9
+ /**
10
+ * @deprecated Use init() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
11
+ * If you have a remote app called `my-remote-app` and you want to use the `http://localhost:4201/mf-manifest.json` as the remote url, you should change it from:
12
+ * ```ts
13
+ * import { setRemoteDefinitions } from '@nx/angular/mf';
14
+ *
15
+ * setRemoteDefinitions({
16
+ * 'my-remote-app': 'http://localhost:4201/mf-manifest.json'
17
+ * });
18
+ * ```
19
+ * to use init():
20
+ * ```ts
21
+ * import { init } from '@module-federation/enhanced/runtime';
22
+ *
23
+ * init({
24
+ * name: 'host',
25
+ * remotes: [{
26
+ * name: 'my-remote-app',
27
+ * entry: 'http://localhost:4201/mf-manifest.json'
28
+ * }]
29
+ * });
30
+ * ```
31
+ */
6
32
  function setRemoteDefinitions(definitions) {
7
33
  remoteUrlDefinitions = definitions;
8
34
  }
35
+ /**
36
+ * @deprecated Use registerRemotes() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
37
+ * If you set a remote app with `setRemoteDefinition` such as:
38
+ * ```ts
39
+ * import { setRemoteDefinition } from '@nx/angular/mf';
40
+ *
41
+ * setRemoteDefinition(
42
+ * 'my-remote-app',
43
+ * 'http://localhost:4201/mf-manifest.json'
44
+ * );
45
+ * ```
46
+ * change it to use registerRemotes():
47
+ * ```ts
48
+ * import { registerRemotes } from '@module-federation/enhanced/runtime';
49
+ *
50
+ * registerRemotes([
51
+ * {
52
+ * name: 'my-remote-app',
53
+ * entry: 'http://localhost:4201/mf-manifest.json'
54
+ * }
55
+ * ]);
56
+ * ```
57
+ */
9
58
  function setRemoteDefinition(remoteName, remoteUrl) {
10
59
  remoteUrlDefinitions ??= {};
11
60
  remoteUrlDefinitions[remoteName] = remoteUrl;
12
61
  }
13
62
  let remoteModuleMap = new Map();
14
63
  let remoteContainerMap = new Map();
64
+ /**
65
+ * @deprecated Use loadRemote() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
66
+ * If you set a load a remote with `loadRemoteModule` such as:
67
+ * ```ts
68
+ * import { loadRemoteModule } from '@nx/angular/mf';
69
+ *
70
+ * loadRemoteModule('my-remote-app', './Module').then(m => m.RemoteEntryModule);
71
+ * ```
72
+ * change it to use loadRemote():
73
+ * ```ts
74
+ * import { loadRemote } from '@module-federation/enhanced/runtime';
75
+ *
76
+ * loadRemote<typeof import('my-remote-app/Module')>('my-remote-app/Module').then(m => m.RemoteEntryModule);
77
+ * ```
78
+ */
15
79
  async function loadRemoteModule(remoteName, moduleName) {
16
80
  const remoteModuleKey = `${remoteName}:${moduleName}`;
17
81
  if (remoteModuleMap.has(remoteModuleKey)) {
@@ -1 +1 @@
1
- {"version":3,"file":"nx-angular-mf.mjs","sources":["../../../../packages/angular/mf/mf.ts","../../../../packages/angular/mf/nx-angular-mf.ts"],"sourcesContent":["export type ResolveRemoteUrlFunction = (\n remoteName: string\n) => string | Promise<string>;\n\ndeclare const __webpack_init_sharing__: (scope: 'default') => Promise<void>;\ndeclare const __webpack_share_scopes__: { default: unknown };\n\nlet resolveRemoteUrl: ResolveRemoteUrlFunction;\n\nexport function setRemoteUrlResolver(\n _resolveRemoteUrl: ResolveRemoteUrlFunction\n) {\n resolveRemoteUrl = _resolveRemoteUrl;\n}\n\nlet remoteUrlDefinitions: Record<string, string>;\n\nexport function setRemoteDefinitions(definitions: Record<string, string>) {\n remoteUrlDefinitions = definitions;\n}\n\nexport function setRemoteDefinition(remoteName: string, remoteUrl: string) {\n remoteUrlDefinitions ??= {};\n remoteUrlDefinitions[remoteName] = remoteUrl;\n}\n\nlet remoteModuleMap = new Map<string, unknown>();\nlet remoteContainerMap = new Map<string, unknown>();\n\nexport async function loadRemoteModule(remoteName: string, moduleName: string) {\n const remoteModuleKey = `${remoteName}:${moduleName}`;\n if (remoteModuleMap.has(remoteModuleKey)) {\n return remoteModuleMap.get(remoteModuleKey);\n }\n\n const container = remoteContainerMap.has(remoteName)\n ? remoteContainerMap.get(remoteName)\n : await loadRemoteContainer(remoteName);\n\n const factory = await container.get(moduleName);\n const Module = factory();\n\n remoteModuleMap.set(remoteModuleKey, Module);\n\n return Module;\n}\n\nfunction loadModule(url: string) {\n return import(/* webpackIgnore:true */ url);\n}\n\nlet initialSharingScopeCreated = false;\n\nasync function loadRemoteContainer(remoteName: string) {\n if (!resolveRemoteUrl && !remoteUrlDefinitions) {\n throw new Error(\n 'Call setRemoteDefinitions or setRemoteUrlResolver to allow Dynamic Federation to find the remote apps correctly.'\n );\n }\n\n if (!initialSharingScopeCreated) {\n initialSharingScopeCreated = true;\n await __webpack_init_sharing__('default');\n }\n\n const remoteUrl = remoteUrlDefinitions\n ? remoteUrlDefinitions[remoteName]\n : await resolveRemoteUrl(remoteName);\n\n let containerUrl = remoteUrl;\n if (!remoteUrl.endsWith('.mjs') && !remoteUrl.endsWith('.js')) {\n containerUrl = `${remoteUrl}${\n remoteUrl.endsWith('/') ? '' : '/'\n }remoteEntry.mjs`;\n }\n\n const container = await loadModule(containerUrl);\n await container.init(__webpack_share_scopes__.default);\n\n remoteContainerMap.set(remoteName, container);\n return container;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAOA,IAAI,gBAA0C,CAAC;AAEzC,SAAU,oBAAoB,CAClC,iBAA2C,EAAA;IAE3C,gBAAgB,GAAG,iBAAiB,CAAC;AACvC,CAAC;AAED,IAAI,oBAA4C,CAAC;AAE3C,SAAU,oBAAoB,CAAC,WAAmC,EAAA;IACtE,oBAAoB,GAAG,WAAW,CAAC;AACrC,CAAC;AAEe,SAAA,mBAAmB,CAAC,UAAkB,EAAE,SAAiB,EAAA;IACvE,oBAAoB,KAAK,EAAE,CAAC;AAC5B,IAAA,oBAAoB,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;AAC/C,CAAC;AAED,IAAI,eAAe,GAAG,IAAI,GAAG,EAAmB,CAAC;AACjD,IAAI,kBAAkB,GAAG,IAAI,GAAG,EAAmB,CAAC;AAE7C,eAAe,gBAAgB,CAAC,UAAkB,EAAE,UAAkB,EAAA;AAC3E,IAAA,MAAM,eAAe,GAAG,CAAA,EAAG,UAAU,CAAI,CAAA,EAAA,UAAU,EAAE,CAAC;AACtD,IAAA,IAAI,eAAe,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE;AACxC,QAAA,OAAO,eAAe,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;KAC7C;AAED,IAAA,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC;AAClD,UAAE,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC;AACpC,UAAE,MAAM,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAE1C,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AA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G;;;;"}
1
+ {"version":3,"file":"nx-angular-mf.mjs","sources":["../../../../packages/angular/mf/mf.ts","../../../../packages/angular/mf/nx-angular-mf.ts"],"sourcesContent":["export type ResolveRemoteUrlFunction = (\n remoteName: string\n) => string | Promise<string>;\n\ndeclare const __webpack_init_sharing__: (scope: 'default') => Promise<void>;\ndeclare const __webpack_share_scopes__: { default: unknown };\n\nlet resolveRemoteUrl: ResolveRemoteUrlFunction;\n\n/**\n * @deprecated Use Runtime Helpers from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.\n */\nexport function setRemoteUrlResolver(\n _resolveRemoteUrl: ResolveRemoteUrlFunction\n) {\n resolveRemoteUrl = _resolveRemoteUrl;\n}\n\nlet remoteUrlDefinitions: Record<string, string>;\n\n/**\n * @deprecated Use init() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.\n * If you have a remote app called `my-remote-app` and you want to use the `http://localhost:4201/mf-manifest.json` as the remote url, you should change it from:\n * ```ts\n * import { setRemoteDefinitions } from '@nx/angular/mf';\n *\n * setRemoteDefinitions({\n * 'my-remote-app': 'http://localhost:4201/mf-manifest.json'\n * });\n * ```\n * to use init():\n * ```ts\n * import { init } from '@module-federation/enhanced/runtime';\n *\n * init({\n * name: 'host',\n * remotes: [{\n * name: 'my-remote-app',\n * entry: 'http://localhost:4201/mf-manifest.json'\n * }]\n * });\n * ```\n */\nexport function setRemoteDefinitions(definitions: Record<string, string>) {\n remoteUrlDefinitions = definitions;\n}\n\n/**\n * @deprecated Use registerRemotes() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.\n * If you set a remote app with `setRemoteDefinition` such as:\n * ```ts\n * import { setRemoteDefinition } from '@nx/angular/mf';\n *\n * setRemoteDefinition(\n * 'my-remote-app',\n * 'http://localhost:4201/mf-manifest.json'\n * );\n * ```\n * change it to use registerRemotes():\n * ```ts\n * import { registerRemotes } from '@module-federation/enhanced/runtime';\n *\n * registerRemotes([\n * {\n * name: 'my-remote-app',\n * entry: 'http://localhost:4201/mf-manifest.json'\n * }\n * ]);\n * ```\n */\nexport function setRemoteDefinition(remoteName: string, remoteUrl: string) {\n remoteUrlDefinitions ??= {};\n remoteUrlDefinitions[remoteName] = remoteUrl;\n}\n\nlet remoteModuleMap = new Map<string, unknown>();\nlet remoteContainerMap = new Map<string, unknown>();\n\n/**\n * @deprecated Use loadRemote() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.\n * If you set a load a remote with `loadRemoteModule` such as:\n * ```ts\n * import { loadRemoteModule } from '@nx/angular/mf';\n *\n * loadRemoteModule('my-remote-app', './Module').then(m => m.RemoteEntryModule);\n * ```\n * change it to use loadRemote():\n * ```ts\n * import { loadRemote } from '@module-federation/enhanced/runtime';\n *\n * loadRemote<typeof import('my-remote-app/Module')>('my-remote-app/Module').then(m => m.RemoteEntryModule);\n * ```\n */\nexport async function loadRemoteModule(remoteName: string, moduleName: string) {\n const remoteModuleKey = `${remoteName}:${moduleName}`;\n if (remoteModuleMap.has(remoteModuleKey)) {\n return remoteModuleMap.get(remoteModuleKey);\n }\n\n const container = remoteContainerMap.has(remoteName)\n ? remoteContainerMap.get(remoteName)\n : await loadRemoteContainer(remoteName);\n\n const factory = await container.get(moduleName);\n const Module = factory();\n\n remoteModuleMap.set(remoteModuleKey, Module);\n\n return Module;\n}\n\nfunction loadModule(url: string) {\n return import(/* webpackIgnore:true */ url);\n}\n\nlet initialSharingScopeCreated = false;\n\nasync function loadRemoteContainer(remoteName: string) {\n if (!resolveRemoteUrl && !remoteUrlDefinitions) {\n throw new Error(\n 'Call setRemoteDefinitions or setRemoteUrlResolver to allow Dynamic Federation to find the remote apps correctly.'\n );\n }\n\n if (!initialSharingScopeCreated) {\n initialSharingScopeCreated = true;\n await __webpack_init_sharing__('default');\n }\n\n const remoteUrl = remoteUrlDefinitions\n ? remoteUrlDefinitions[remoteName]\n : await resolveRemoteUrl(remoteName);\n\n let containerUrl = remoteUrl;\n if (!remoteUrl.endsWith('.mjs') && !remoteUrl.endsWith('.js')) {\n containerUrl = `${remoteUrl}${\n remoteUrl.endsWith('/') ? '' : '/'\n }remoteEntry.mjs`;\n }\n\n const container = await loadModule(containerUrl);\n await container.init(__webpack_share_scopes__.default);\n\n remoteContainerMap.set(remoteName, container);\n return container;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAOA,IAAI,gBAA0C,CAAC;AAE/C;;AAEG;AACG,SAAU,oBAAoB,CAClC,iBAA2C,EAAA;IAE3C,gBAAgB,GAAG,iBAAiB,CAAC;AACvC,CAAC;AAED,IAAI,oBAA4C,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,oBAAoB,CAAC,WAAmC,EAAA;IACtE,oBAAoB,GAAG,WAAW,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACa,SAAA,mBAAmB,CAAC,UAAkB,EAAE,SAAiB,EAAA;IACvE,oBAAoB,KAAK,EAAE,CAAC;AAC5B,IAAA,oBAAoB,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;AAC/C,CAAC;AAED,IAAI,eAAe,GAAG,IAAI,GAAG,EAAmB,CAAC;AACjD,IAAI,kBAAkB,GAAG,IAAI,GAAG,EAAmB,CAAC;AAEpD;;;;;;;;;;;;;;AAcG;AACI,eAAe,gBAAgB,CAAC,UAAkB,EAAE,UAAkB,EAAA;AAC3E,IAAA,MAAM,eAAe,GAAG,CAAA,EAAG,UAAU,CAAI,CAAA,EAAA,UAAU,EAAE,CAAC;AACtD,IAAA,IAAI,eAAe,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE;AACxC,QAAA,OAAO,eAAe,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;KAC7C;AAED,IAAA,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC;AAClD,UAAE,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC;AACpC,UAAE,MAAM,mBAAmB,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,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AAC9C,IAAA,OAAO,SAAS,CAAC;AACnB;;ACjJA;;AAEG;;;;"}
package/mf/mf.d.ts CHANGED
@@ -1,5 +1,69 @@
1
1
  export type ResolveRemoteUrlFunction = (remoteName: string) => string | Promise<string>;
2
+ /**
3
+ * @deprecated Use Runtime Helpers from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
4
+ */
2
5
  export declare function setRemoteUrlResolver(_resolveRemoteUrl: ResolveRemoteUrlFunction): void;
6
+ /**
7
+ * @deprecated Use init() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
8
+ * If you have a remote app called `my-remote-app` and you want to use the `http://localhost:4201/mf-manifest.json` as the remote url, you should change it from:
9
+ * ```ts
10
+ * import { setRemoteDefinitions } from '@nx/angular/mf';
11
+ *
12
+ * setRemoteDefinitions({
13
+ * 'my-remote-app': 'http://localhost:4201/mf-manifest.json'
14
+ * });
15
+ * ```
16
+ * to use init():
17
+ * ```ts
18
+ * import { init } from '@module-federation/enhanced/runtime';
19
+ *
20
+ * init({
21
+ * name: 'host',
22
+ * remotes: [{
23
+ * name: 'my-remote-app',
24
+ * entry: 'http://localhost:4201/mf-manifest.json'
25
+ * }]
26
+ * });
27
+ * ```
28
+ */
3
29
  export declare function setRemoteDefinitions(definitions: Record<string, string>): void;
30
+ /**
31
+ * @deprecated Use registerRemotes() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
32
+ * If you set a remote app with `setRemoteDefinition` such as:
33
+ * ```ts
34
+ * import { setRemoteDefinition } from '@nx/angular/mf';
35
+ *
36
+ * setRemoteDefinition(
37
+ * 'my-remote-app',
38
+ * 'http://localhost:4201/mf-manifest.json'
39
+ * );
40
+ * ```
41
+ * change it to use registerRemotes():
42
+ * ```ts
43
+ * import { registerRemotes } from '@module-federation/enhanced/runtime';
44
+ *
45
+ * registerRemotes([
46
+ * {
47
+ * name: 'my-remote-app',
48
+ * entry: 'http://localhost:4201/mf-manifest.json'
49
+ * }
50
+ * ]);
51
+ * ```
52
+ */
4
53
  export declare function setRemoteDefinition(remoteName: string, remoteUrl: string): void;
54
+ /**
55
+ * @deprecated Use loadRemote() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
56
+ * If you set a load a remote with `loadRemoteModule` such as:
57
+ * ```ts
58
+ * import { loadRemoteModule } from '@nx/angular/mf';
59
+ *
60
+ * loadRemoteModule('my-remote-app', './Module').then(m => m.RemoteEntryModule);
61
+ * ```
62
+ * change it to use loadRemote():
63
+ * ```ts
64
+ * import { loadRemote } from '@module-federation/enhanced/runtime';
65
+ *
66
+ * loadRemote<typeof import('my-remote-app/Module')>('my-remote-app/Module').then(m => m.RemoteEntryModule);
67
+ * ```
68
+ */
5
69
  export declare function loadRemoteModule(remoteName: string, moduleName: string): Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "20.0.8",
3
+ "version": "20.1.0-beta.0",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, Playwright and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -79,13 +79,13 @@
79
79
  "tslib": "^2.3.0",
80
80
  "webpack-merge": "^5.8.0",
81
81
  "webpack": "^5.88.0",
82
- "@module-federation/enhanced": "0.6.6",
83
- "@nx/devkit": "20.0.8",
84
- "@nx/js": "20.0.8",
85
- "@nx/eslint": "20.0.8",
86
- "@nx/webpack": "20.0.8",
87
- "@nx/web": "20.0.8",
88
- "@nx/workspace": "20.0.8",
82
+ "@module-federation/enhanced": "0.6.9",
83
+ "@nx/devkit": "20.1.0-beta.0",
84
+ "@nx/js": "20.1.0-beta.0",
85
+ "@nx/eslint": "20.1.0-beta.0",
86
+ "@nx/webpack": "20.1.0-beta.0",
87
+ "@nx/web": "20.1.0-beta.0",
88
+ "@nx/workspace": "20.1.0-beta.0",
89
89
  "piscina": "^4.4.0"
90
90
  },
91
91
  "peerDependencies": {
@@ -1 +1,8 @@
1
- <% if(minimal) { %><h1>Welcome <%= appName %></h1><% } else { %><<%= nxWelcomeSelector %>></<%= nxWelcomeSelector %>><% } %> <% if(routing) { %><router-outlet></router-outlet><% } %>
1
+ <%_ if(minimal) { _%>
2
+ <h1>Welcome <%= appName %></h1>
3
+ <%_ } else { _%>
4
+ <<%= nxWelcomeSelector %>></<%= nxWelcomeSelector %>>
5
+ <%_ } _%>
6
+ <%_ if(routing) { _%>
7
+ <router-outlet></router-outlet>
8
+ <%_ } _%>
@@ -1 +1,8 @@
1
- <% if(minimal) { %><h1>Welcome <%= appName %></h1><% } else { %><<%= nxWelcomeSelector %>></<%= nxWelcomeSelector %>><% } %> <% if(routing) { %><router-outlet></router-outlet><% } %>
1
+ <%_ if(minimal) { _%>
2
+ <h1>Welcome <%= appName %></h1>
3
+ <%_ } else { _%>
4
+ <<%= nxWelcomeSelector %>></<%= nxWelcomeSelector %>>
5
+ <%_ } _%>
6
+ <%_ if(routing) { _%>
7
+ <router-outlet></router-outlet>
8
+ <%_ } _%>
@@ -3,13 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addUnitTestRunner = addUnitTestRunner;
4
4
  const test_runners_1 = require("../../../utils/test-runners");
5
5
  const add_jest_1 = require("../../utils/add-jest");
6
+ const add_vitest_1 = require("../../utils/add-vitest");
6
7
  async function addUnitTestRunner(host, options) {
7
- if (options.unitTestRunner === test_runners_1.UnitTestRunner.Jest) {
8
- await (0, add_jest_1.addJest)(host, {
9
- name: options.name,
10
- projectRoot: options.appProjectRoot,
11
- skipPackageJson: options.skipPackageJson,
12
- strict: options.strict,
13
- });
8
+ switch (options.unitTestRunner) {
9
+ case test_runners_1.UnitTestRunner.Jest:
10
+ await (0, add_jest_1.addJest)(host, {
11
+ name: options.name,
12
+ projectRoot: options.appProjectRoot,
13
+ skipPackageJson: options.skipPackageJson,
14
+ strict: options.strict,
15
+ });
16
+ break;
17
+ case test_runners_1.UnitTestRunner.Vitest:
18
+ await (0, add_vitest_1.addVitest)(host, {
19
+ name: options.name,
20
+ projectRoot: options.appProjectRoot,
21
+ skipPackageJson: options.skipPackageJson,
22
+ strict: options.strict,
23
+ });
24
+ break;
14
25
  }
15
26
  }
@@ -99,8 +99,9 @@
99
99
  },
100
100
  "unitTestRunner": {
101
101
  "type": "string",
102
- "enum": ["jest", "none"],
102
+ "enum": ["jest", "vitest", "none"],
103
103
  "description": "Test runner to use for unit tests.",
104
+ "x-prompt": "Which unit test runner would you like to use?",
104
105
  "default": "jest"
105
106
  },
106
107
  "e2eTestRunner": {
@@ -2,5 +2,5 @@
2
2
  display: block;
3
3
  }
4
4
  <% } else { %>\:host
5
- display: block;
5
+ display: block
6
6
  <% }} %>
@@ -1,9 +1,9 @@
1
1
  import type { Meta, StoryObj } from '@storybook/angular';
2
2
  import { <%=componentName%> } from './<%=componentFileName%>';
3
- <% if ( interactionTests ) { %>
3
+ <%_ if ( interactionTests ) { _%>
4
4
  import { within } from '@storybook/testing-library';
5
5
  import { expect } from '@storybook/jest';
6
- <% } %>
6
+ <%_ } _%>
7
7
 
8
8
  const meta: Meta<<%= componentName %>> = {
9
9
  component: <%= componentName %>,
@@ -18,7 +18,7 @@ export const Primary: Story = {
18
18
  },
19
19
  };
20
20
 
21
- <% if ( interactionTests ) { %>
21
+ <%_ if ( interactionTests ) { _%>
22
22
  export const Heading: Story = {
23
23
  args: {<% for (let prop of props) { %>
24
24
  <%= prop.name %>: <%- prop.defaultValue %>,<% } %>
@@ -28,4 +28,4 @@ export const Heading: Story = {
28
28
  expect(canvas.getByText(/<%=componentNameSimple%> works!/gi)).toBeTruthy();
29
29
  },
30
30
  };
31
- <% } %>
31
+ <%_ } _%>
@@ -51,8 +51,9 @@
51
51
  },
52
52
  "unitTestRunner": {
53
53
  "type": "string",
54
- "enum": ["jest", "none"],
54
+ "enum": ["jest", "vitest", "none"],
55
55
  "description": "Test runner to use for unit tests of the remote if it needs to be created.",
56
+ "x-prompt": "Which unit test runner would you like to use?",
56
57
  "default": "jest"
57
58
  },
58
59
  "e2eTestRunner": {
@@ -108,8 +108,9 @@
108
108
  },
109
109
  "unitTestRunner": {
110
110
  "type": "string",
111
- "enum": ["jest", "none"],
111
+ "enum": ["jest", "vitest", "none"],
112
112
  "description": "Test runner to use for unit tests.",
113
+ "x-prompt": "Which unit test runner would you like to use?",
113
114
  "default": "jest"
114
115
  },
115
116
  "e2eTestRunner": {
@@ -1,9 +1,9 @@
1
1
  # <%= libName %>
2
2
 
3
3
  This library was generated with [Nx](https://nx.dev).
4
- <% if (unitTesting) { %>
4
+ <%_ if (unitTesting) { _%>
5
5
 
6
6
  ## Running unit tests
7
7
 
8
8
  Run `nx test <%= libName %>` to execute the unit tests.
9
- <% } %>
9
+ <%_ } _%>
@@ -22,6 +22,8 @@ const add_jest_1 = require("../utils/add-jest");
22
22
  const set_generator_defaults_1 = require("./lib/set-generator-defaults");
23
23
  const ensure_angular_dependencies_1 = require("../utils/ensure-angular-dependencies");
24
24
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
25
+ const test_runners_1 = require("../../utils/test-runners");
26
+ const add_vitest_1 = require("../utils/add-vitest");
25
27
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
26
28
  async function libraryGenerator(tree, schema) {
27
29
  (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'angular', 'library');
@@ -87,13 +89,23 @@ async function libraryGenerator(tree, schema) {
87
89
  };
88
90
  }
89
91
  async function addUnitTestRunner(host, options) {
90
- if (options.unitTestRunner === 'jest') {
91
- await (0, add_jest_1.addJest)(host, {
92
- name: options.name,
93
- projectRoot: options.projectRoot,
94
- skipPackageJson: options.skipPackageJson,
95
- strict: options.strict,
96
- });
92
+ switch (options.unitTestRunner) {
93
+ case test_runners_1.UnitTestRunner.Jest:
94
+ await (0, add_jest_1.addJest)(host, {
95
+ name: options.name,
96
+ projectRoot: options.projectRoot,
97
+ skipPackageJson: options.skipPackageJson,
98
+ strict: options.strict,
99
+ });
100
+ break;
101
+ case test_runners_1.UnitTestRunner.Vitest:
102
+ await (0, add_vitest_1.addVitest)(host, {
103
+ name: options.name,
104
+ projectRoot: options.projectRoot,
105
+ skipPackageJson: options.skipPackageJson,
106
+ strict: options.strict,
107
+ });
108
+ break;
97
109
  }
98
110
  }
99
111
  function updateNpmScopeIfBuildableOrPublishable(host, options) {
@@ -88,8 +88,9 @@
88
88
  },
89
89
  "unitTestRunner": {
90
90
  "type": "string",
91
- "enum": ["jest", "none"],
91
+ "enum": ["jest", "vitest", "none"],
92
92
  "description": "Test runner to use for unit tests.",
93
+ "x-prompt": "Which unit test runner would you like to use?",
93
94
  "default": "jest"
94
95
  },
95
96
  "importPath": {
@@ -102,8 +102,9 @@
102
102
  },
103
103
  "unitTestRunner": {
104
104
  "type": "string",
105
- "enum": ["jest", "none"],
105
+ "enum": ["jest", "vitest", "none"],
106
106
  "description": "Test runner to use for unit tests.",
107
+ "x-prompt": "Which unit test runner would you like to use?",
107
108
  "default": "jest"
108
109
  },
109
110
  "e2eTestRunner": {
@@ -25,7 +25,7 @@ function addRemoteToHost(tree, options) {
25
25
  addRemoteToStaticHost(tree, options, hostProject, isHostUsingTypescriptConfig);
26
26
  }
27
27
  else if (hostFederationType === 'dynamic') {
28
- addRemoteToDynamicHost(tree, options, pathToMFManifest);
28
+ addRemoteToDynamicHost(tree, options, pathToMFManifest, hostProject.sourceRoot);
29
29
  }
30
30
  addLazyLoadedRouteToHostAppModule(tree, options, hostFederationType);
31
31
  }
@@ -58,15 +58,18 @@ function addRemoteToStaticHost(tree, options, hostProject, isHostUsingTypescript
58
58
  const updatedConfig = `${hostMFConfig.slice(0, endOfPropertiesPos)}${isCommaNeeded ? ',' : ''}'${options.appName}',${hostMFConfig.slice(endOfPropertiesPos)}`;
59
59
  tree.write(hostMFConfigPath, updatedConfig);
60
60
  }
61
- function addRemoteToDynamicHost(tree, options, pathToMfManifest) {
61
+ function addRemoteToDynamicHost(tree, options, pathToMfManifest, hostSourceRoot) {
62
+ // TODO(Colum): Remove for Nx 22
63
+ const usingLegacyDynamicFederation = tree
64
+ .read(`${hostSourceRoot}/main.ts`, 'utf-8')
65
+ .includes('setRemoteDefinitions(');
62
66
  (0, devkit_1.updateJson)(tree, pathToMfManifest, (manifest) => {
63
67
  return {
64
68
  ...manifest,
65
- [options.appName]: `http://localhost:${options.port}`,
69
+ [options.appName]: `http://localhost:${options.port}${usingLegacyDynamicFederation ? '' : '/mf-manifest.json'}`,
66
70
  };
67
71
  });
68
72
  }
69
- // TODO(colum): future work: allow dev to pass to path to routing module
70
73
  function addLazyLoadedRouteToHostAppModule(tree, options, hostFederationType) {
71
74
  if (!tsModule) {
72
75
  tsModule = (0, ensure_typescript_1.ensureTypescript)();
@@ -78,19 +81,29 @@ function addLazyLoadedRouteToHostAppModule(tree, options, hostFederationType) {
78
81
  }
79
82
  const hostRootRoutingFile = tree.read(pathToHostRootRouting, 'utf-8');
80
83
  let sourceFile = tsModule.createSourceFile(pathToHostRootRouting, hostRootRoutingFile, tsModule.ScriptTarget.Latest, true);
84
+ // TODO(Colum): Remove for Nx 22
85
+ const usingLegacyDynamicFederation = hostFederationType === 'dynamic' &&
86
+ tree
87
+ .read(`${hostAppConfig.sourceRoot}/main.ts`, 'utf-8')
88
+ .includes('setRemoteDefinitions(');
81
89
  if (hostFederationType === 'dynamic') {
82
- sourceFile = (0, js_1.insertImport)(tree, sourceFile, pathToHostRootRouting, 'loadRemoteModule', '@nx/angular/mf');
90
+ sourceFile = (0, js_1.insertImport)(tree, sourceFile, pathToHostRootRouting, usingLegacyDynamicFederation ? 'loadRemoteModule' : 'loadRemote', usingLegacyDynamicFederation
91
+ ? '@nx/angular/mf'
92
+ : '@module-federation/enhanced/runtime');
83
93
  }
84
94
  const routePathName = options.standalone ? 'Routes' : 'Module';
85
95
  const exportedRemote = options.standalone
86
96
  ? 'remoteRoutes'
87
97
  : 'RemoteEntryModule';
98
+ const remoteModulePath = `${options.appName.replace(/-/g, '_')}/${routePathName}`;
88
99
  const routeToAdd = hostFederationType === 'dynamic'
89
- ? `loadRemoteModule('${options.appName.replace(/-/g, '_')}', './${routePathName}')`
90
- : `import('${options.appName.replace(/-/g, '_')}/${routePathName}')`;
100
+ ? usingLegacyDynamicFederation
101
+ ? `loadRemoteModule('${options.appName.replace(/-/g, '_')}', './${routePathName}')`
102
+ : `loadRemote<typeof import('${remoteModulePath}')>('${remoteModulePath}')`
103
+ : `import('${remoteModulePath}')`;
91
104
  (0, route_utils_1.addRoute)(tree, pathToHostRootRouting, `{
92
105
  path: '${options.appName}',
93
- loadChildren: () => ${routeToAdd}.then(m => m.${exportedRemote})
106
+ loadChildren: () => ${routeToAdd}.then(m => m!.${exportedRemote})
94
107
  }`);
95
108
  const pathToAppComponentTemplate = (0, devkit_1.joinPathFragments)(hostAppConfig.sourceRoot, 'app/app.component.html');
96
109
  const appComponent = tree.read(pathToAppComponentTemplate, 'utf-8');
@@ -20,11 +20,12 @@ function fixBootstrap(tree, appRoot, options) {
20
20
  if (tree.exists((0, devkit_1.joinPathFragments)(appRoot, 'public/module-federation.manifest.json'))) {
21
21
  manifestPath = '/module-federation.manifest.json';
22
22
  }
23
- const fetchMFManifestCode = `import { setRemoteDefinitions } from '@nx/angular/mf';
23
+ const fetchMFManifestCode = `import { init } from '@module-federation/enhanced/runtime';
24
24
 
25
25
  fetch('${manifestPath}')
26
26
  .then((res) => res.json())
27
- .then(definitions => setRemoteDefinitions(definitions))
27
+ .then((remotes: Record<string, string>) => Object.entries(remotes).map(([name, entry]) => ({ name,entry})))
28
+ .then(remotes => init({name: '${options.appName}', remotes}))
28
29
  .then(() => ${bootstrapImportCode});`;
29
30
  tree.write(mainFilePath, fetchMFManifestCode);
30
31
  }
@@ -19,10 +19,11 @@ async function setupMf(tree, rawOptions) {
19
19
  (0, lib_1.removeDeadCodeFromRemote)(tree, options);
20
20
  (0, lib_1.setupTspathForRemote)(tree, options);
21
21
  if (!options.skipPackageJson) {
22
- installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
22
+ installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
23
+ '@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion,
24
+ }, {
23
25
  '@nx/web': versions_1.nxVersion,
24
26
  '@nx/webpack': versions_1.nxVersion,
25
- '@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion,
26
27
  });
27
28
  }
28
29
  }
@@ -24,10 +24,10 @@ async function addJest(tree, options) {
24
24
  const contents = tree.read(setupFile, 'utf-8');
25
25
  tree.write(setupFile, `// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
26
26
  globalThis.ngJest = {
27
- testEnvironmentOptions: {
28
- errorOnUnknownElements: true,
29
- errorOnUnknownProperties: true,
30
- },
27
+ testEnvironmentOptions: {
28
+ errorOnUnknownElements: true,
29
+ errorOnUnknownProperties: true,
30
+ },
31
31
  };
32
32
  ${contents}`);
33
33
  }
@@ -0,0 +1,8 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export type AddVitestOptions = {
3
+ name: string;
4
+ projectRoot: string;
5
+ skipPackageJson: boolean;
6
+ strict: boolean;
7
+ };
8
+ export declare function addVitest(tree: Tree, options: AddVitestOptions): Promise<void>;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addVitest = addVitest;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("../../utils/versions");
6
+ async function addVitest(tree, options) {
7
+ if (!options.skipPackageJson) {
8
+ (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
9
+ '@analogjs/vitest-angular': versions_1.analogVitestAngular,
10
+ '@analogjs/vite-plugin-angular': versions_1.analogVitestAngular,
11
+ }, undefined, true);
12
+ }
13
+ const { createOrEditViteConfig, vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
14
+ const relativeTestSetupPath = (0, devkit_1.joinPathFragments)('src', 'test-setup.ts');
15
+ const setupFile = (0, devkit_1.joinPathFragments)(options.projectRoot, relativeTestSetupPath);
16
+ if (!tree.exists(setupFile)) {
17
+ tree.write(setupFile, `import '@analogjs/vitest-angular/setup-zone';
18
+
19
+ import {
20
+ BrowserDynamicTestingModule,
21
+ platformBrowserDynamicTesting,
22
+ } from '@angular/platform-browser-dynamic/testing';
23
+ import { getTestBed } from '@angular/core/testing';
24
+
25
+ getTestBed().initTestEnvironment(
26
+ BrowserDynamicTestingModule,
27
+ platformBrowserDynamicTesting()
28
+ );
29
+ `);
30
+ await vitestGenerator(tree, {
31
+ project: options.name,
32
+ uiFramework: 'none',
33
+ skipViteConfig: true,
34
+ testEnvironment: 'jsdom',
35
+ coverageProvider: 'v8',
36
+ addPlugin: false,
37
+ });
38
+ createOrEditViteConfig(tree, {
39
+ project: options.name,
40
+ includeLib: false,
41
+ includeVitest: true,
42
+ inSourceTests: false,
43
+ imports: [`import angular from '@analogjs/vite-plugin-angular'`],
44
+ plugins: ['angular()'],
45
+ setupFile: relativeTestSetupPath,
46
+ useEsmExtension: true,
47
+ }, true);
48
+ }
49
+ }
@@ -4,8 +4,8 @@ type LatestPackageVersionNames = Exclude<keyof typeof latestVersions, 'nxVersion
4
4
  type CompatPackageVersionNames = LatestPackageVersionNames | 'ngUniversalVersion';
5
5
  export type PackageVersionNames = LatestPackageVersionNames | CompatPackageVersionNames;
6
6
  export type VersionMap = {
7
- angularV16: Record<Exclude<CompatPackageVersionNames, 'typescriptEslintVersion'>, string>;
8
- angularV17: Record<Exclude<CompatPackageVersionNames, 'ngUniversalVersion' | 'typescriptEslintVersion'>, string>;
7
+ angularV16: Record<Exclude<CompatPackageVersionNames, 'analogVitestAngular' | 'typescriptEslintVersion'>, string>;
8
+ angularV17: Record<Exclude<CompatPackageVersionNames, 'analogVitestAngular' | 'ngUniversalVersion' | 'typescriptEslintVersion'>, string>;
9
9
  };
10
10
  export type PackageLatestVersions = Record<LatestPackageVersionNames, string>;
11
11
  export type PackageCompatVersions = VersionMap[SupportedVersions];
@@ -1,6 +1,7 @@
1
1
  export declare enum UnitTestRunner {
2
2
  Jest = "jest",
3
- None = "none"
3
+ None = "none",
4
+ Vitest = "vitest"
4
5
  }
5
6
  export declare enum E2eTestRunner {
6
7
  Cypress = "cypress",
@@ -5,6 +5,7 @@ var UnitTestRunner;
5
5
  (function (UnitTestRunner) {
6
6
  UnitTestRunner["Jest"] = "jest";
7
7
  UnitTestRunner["None"] = "none";
8
+ UnitTestRunner["Vitest"] = "vitest";
8
9
  })(UnitTestRunner || (exports.UnitTestRunner = UnitTestRunner = {}));
9
10
  var E2eTestRunner;
10
11
  (function (E2eTestRunner) {
@@ -13,7 +13,7 @@ export declare const expressVersion = "~4.18.2";
13
13
  export declare const typesExpressVersion = "4.17.14";
14
14
  export declare const browserSyncVersion = "^3.0.0";
15
15
  export declare const moduleFederationNodeVersion = "~2.5.0";
16
- export declare const moduleFederationEnhancedVersion = "0.6.6";
16
+ export declare const moduleFederationEnhancedVersion = "0.6.9";
17
17
  export declare const angularEslintVersion = "^18.3.0";
18
18
  export declare const typescriptEslintVersion = "^7.16.0";
19
19
  export declare const tailwindVersion = "^3.0.2";
@@ -24,4 +24,5 @@ export declare const tsNodeVersion = "10.9.1";
24
24
  export declare const jestPresetAngularVersion = "~14.1.0";
25
25
  export declare const typesNodeVersion = "18.16.9";
26
26
  export declare const jasmineMarblesVersion = "^0.9.2";
27
+ export declare const analogVitestAngular = "~1.9.1";
27
28
  export declare const jsoncEslintParserVersion = "^2.1.0";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jsoncEslintParserVersion = exports.jasmineMarblesVersion = exports.typesNodeVersion = exports.jestPresetAngularVersion = exports.tsNodeVersion = exports.autoprefixerVersion = exports.postcssUrlVersion = exports.postcssVersion = exports.tailwindVersion = exports.typescriptEslintVersion = exports.angularEslintVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.browserSyncVersion = exports.typesExpressVersion = exports.expressVersion = exports.typesCorsVersion = exports.corsVersion = exports.tsLibVersion = exports.angularJsVersion = exports.zoneJsVersion = exports.rxjsVersion = exports.ngrxVersion = exports.ngPackagrVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = void 0;
3
+ exports.jsoncEslintParserVersion = exports.analogVitestAngular = exports.jasmineMarblesVersion = exports.typesNodeVersion = exports.jestPresetAngularVersion = exports.tsNodeVersion = exports.autoprefixerVersion = exports.postcssUrlVersion = exports.postcssVersion = exports.tailwindVersion = exports.typescriptEslintVersion = exports.angularEslintVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.browserSyncVersion = exports.typesExpressVersion = exports.expressVersion = exports.typesCorsVersion = exports.corsVersion = exports.tsLibVersion = exports.angularJsVersion = exports.zoneJsVersion = exports.rxjsVersion = exports.ngrxVersion = exports.ngPackagrVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
5
  exports.angularVersion = '~18.2.0';
6
6
  exports.angularDevkitVersion = '~18.2.0';
@@ -16,7 +16,7 @@ exports.expressVersion = '~4.18.2';
16
16
  exports.typesExpressVersion = '4.17.14';
17
17
  exports.browserSyncVersion = '^3.0.0';
18
18
  exports.moduleFederationNodeVersion = '~2.5.0';
19
- exports.moduleFederationEnhancedVersion = '0.6.6';
19
+ exports.moduleFederationEnhancedVersion = '0.6.9';
20
20
  exports.angularEslintVersion = '^18.3.0';
21
21
  exports.typescriptEslintVersion = '^7.16.0';
22
22
  exports.tailwindVersion = '^3.0.2';
@@ -27,4 +27,5 @@ exports.tsNodeVersion = '10.9.1';
27
27
  exports.jestPresetAngularVersion = '~14.1.0';
28
28
  exports.typesNodeVersion = '18.16.9';
29
29
  exports.jasmineMarblesVersion = '^0.9.2';
30
+ exports.analogVitestAngular = '~1.9.1';
30
31
  exports.jsoncEslintParserVersion = '^2.1.0';