@nx/angular 0.0.0-pr-27786-e5e2109 → 0.0.0-pr-27404-f7ba497

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/migrations.json CHANGED
@@ -2122,6 +2122,19 @@
2122
2122
  "alwaysAddToPackageJson": false
2123
2123
  }
2124
2124
  }
2125
+ },
2126
+ "19.7.0": {
2127
+ "version": "19.7.0-beta.0",
2128
+ "packages": {
2129
+ "@module-federation/enhanced": {
2130
+ "version": "~0.6.0",
2131
+ "alwaysAddToPackageJson": false
2132
+ },
2133
+ "@module-federation/node": {
2134
+ "version": "~2.5.0",
2135
+ "alwaysAddToPackageJson": false
2136
+ }
2137
+ }
2125
2138
  }
2126
2139
  }
2127
2140
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "0.0.0-pr-27786-e5e2109",
3
+ "version": "0.0.0-pr-27404-f7ba497",
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": {
@@ -69,7 +69,7 @@
69
69
  },
70
70
  "dependencies": {
71
71
  "@phenomnomnominal/tsquery": "~5.0.1",
72
- "@typescript-eslint/type-utils": "^7.16.0",
72
+ "@typescript-eslint/type-utils": "^8.0.0",
73
73
  "chalk": "^4.1.0",
74
74
  "find-cache-dir": "^3.3.2",
75
75
  "magic-string": "~0.30.2",
@@ -78,15 +78,15 @@
78
78
  "tslib": "^2.3.0",
79
79
  "webpack-merge": "^5.8.0",
80
80
  "webpack": "^5.88.0",
81
- "@module-federation/enhanced": "~0.2.3",
82
- "@nx/devkit": "0.0.0-pr-27786-e5e2109",
83
- "@nx/js": "0.0.0-pr-27786-e5e2109",
84
- "@nx/eslint": "0.0.0-pr-27786-e5e2109",
85
- "@nx/webpack": "0.0.0-pr-27786-e5e2109",
86
- "@nx/web": "0.0.0-pr-27786-e5e2109",
87
- "@nx/workspace": "0.0.0-pr-27786-e5e2109",
81
+ "@module-federation/enhanced": "~0.6.0",
82
+ "@nx/devkit": "0.0.0-pr-27404-f7ba497",
83
+ "@nx/js": "0.0.0-pr-27404-f7ba497",
84
+ "@nx/eslint": "0.0.0-pr-27404-f7ba497",
85
+ "@nx/webpack": "0.0.0-pr-27404-f7ba497",
86
+ "@nx/web": "0.0.0-pr-27404-f7ba497",
87
+ "@nx/workspace": "0.0.0-pr-27404-f7ba497",
88
88
  "piscina": "^4.4.0",
89
- "@nrwl/angular": "0.0.0-pr-27786-e5e2109"
89
+ "@nrwl/angular": "0.0.0-pr-27404-f7ba497"
90
90
  },
91
91
  "peerDependencies": {
92
92
  "@angular-devkit/build-angular": ">= 16.0.0 < 19.0.0",
@@ -33,9 +33,7 @@ function buildServerAppWithCustomWebpackConfiguration(options, context, pathToWe
33
33
  // Therefore, if the build is an MF Server build, remove the auto-includes from
34
34
  // the base webpack config from Angular
35
35
  let mergedConfig = await (0, webpack_1.mergeCustomWebpackConfig)(baseWebpackConfig, pathToWebpackConfig, options, context.target);
36
- if (mergedConfig.plugins
37
- .map((p) => p.constructor.name)
38
- .includes('UniversalFederationPlugin')) {
36
+ if (mergedConfig.target === 'async-node') {
39
37
  mergedConfig.entry.main = mergedConfig.entry.main.filter((m) => !m.startsWith('@angular/platform-server/init'));
40
38
  mergedConfig.module.rules = mergedConfig.module.rules.filter((m) => !m.loader
41
39
  ? true
@@ -1,9 +1,4 @@
1
1
  import { type ExecutorContext } from '@nx/devkit';
2
2
  import { type Schema } from '../schema';
3
3
  import type { StaticRemotesConfig } from '@nx/webpack/src/utils/module-federation/parse-static-remotes-config';
4
- export declare function startStaticRemotes(ssrStaticRemotesConfig: StaticRemotesConfig, context: ExecutorContext, options: Schema): AsyncGenerator<{
5
- success: boolean;
6
- baseUrl: string;
7
- }, {
8
- success: boolean;
9
- }, unknown>;
4
+ export declare function startStaticRemotes(ssrStaticRemotesConfig: StaticRemotesConfig, context: ExecutorContext, options: Schema): AsyncIterable<unknown>;
@@ -6,9 +6,13 @@ const devkit_1 = require("@nx/devkit");
6
6
  const file_server_impl_1 = tslib_1.__importDefault(require("@nx/web/src/executors/file-server/file-server.impl"));
7
7
  const path_1 = require("path");
8
8
  const fs_1 = require("fs");
9
+ const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
9
10
  function startStaticRemotes(ssrStaticRemotesConfig, context, options) {
10
11
  if (ssrStaticRemotesConfig.remotes.length === 0) {
11
- return;
12
+ return (0, async_iterable_1.createAsyncIterable)(({ next, done }) => {
13
+ next({ success: true });
14
+ done();
15
+ });
12
16
  }
13
17
  // The directories are usually generated with /browser and /server suffixes so we need to copy them to a common directory
14
18
  const commonOutputDirectory = (0, path_1.join)(devkit_1.workspaceRoot, 'tmp/static-remotes');
@@ -1,4 +1,4 @@
1
1
  import { type ExecutorContext } from '@nx/devkit';
2
2
  import type { Schema } from './schema';
3
- export declare function moduleFederationSsrDevServerExecutor(schema: Schema, context: ExecutorContext): AsyncGenerator<any, any, undefined>;
3
+ export declare function moduleFederationSsrDevServerExecutor(schema: Schema, context: ExecutorContext): AsyncGenerator<unknown, any, undefined>;
4
4
  export default moduleFederationSsrDevServerExecutor;
@@ -74,7 +74,7 @@ async function* moduleFederationSsrDevServerExecutor(schema, context) {
74
74
  ...v,
75
75
  baseUrl: undefined,
76
76
  }));
77
- return yield* (0, async_iterable_1.combineAsyncIterables)(removeBaseUrlEmission(currIter), ...devRemotes.map(removeBaseUrlEmission), ...(staticRemotes ? [removeBaseUrlEmission(staticRemotes)] : []), (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
77
+ const combined = (0, async_iterable_1.combineAsyncIterables)(removeBaseUrlEmission(staticRemotes), ...(devRemotes ? devRemotes.map(removeBaseUrlEmission) : []), (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
78
78
  if (!options.isInitialHost) {
79
79
  done();
80
80
  return;
@@ -94,6 +94,7 @@ async function* moduleFederationSsrDevServerExecutor(schema, context) {
94
94
  retryDelay: 2500,
95
95
  host: 'localhost',
96
96
  })));
97
+ next({ success: true, baseUrl: `http://localhost:${options.port}` });
97
98
  }
98
99
  catch (error) {
99
100
  throw new Error(`Failed to start remotes. Check above for any errors.`, {
@@ -104,5 +105,15 @@ async function* moduleFederationSsrDevServerExecutor(schema, context) {
104
105
  done();
105
106
  }
106
107
  }));
108
+ let refs = 2 + (devRemotes?.length ?? 0);
109
+ for await (const result of combined) {
110
+ if (result.success === false)
111
+ throw new Error('Remotes failed to start');
112
+ if (result.success)
113
+ refs--;
114
+ if (refs === 0)
115
+ break;
116
+ }
117
+ return yield* currIter;
107
118
  }
108
119
  exports.default = moduleFederationSsrDevServerExecutor;
@@ -8,6 +8,7 @@ const global_eslint_config_1 = require("@nx/eslint/src/generators/init/global-es
8
8
  const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
9
9
  const add_angular_eslint_dependencies_1 = require("./lib/add-angular-eslint-dependencies");
10
10
  const buildable_project_1 = require("./lib/buildable-project");
11
+ const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
11
12
  async function addLintingGenerator(tree, options) {
12
13
  const tasks = [];
13
14
  const rootProject = options.projectRoot === '.' || options.projectRoot === '';
@@ -32,21 +33,10 @@ async function addLintingGenerator(tree, options) {
32
33
  const hasParserOptions = tree
33
34
  .read((0, devkit_1.joinPathFragments)(options.projectRoot, eslintFile), 'utf8')
34
35
  .includes(`${options.projectRoot}/tsconfig.*?.json`);
35
- (0, eslint_file_1.replaceOverridesInLintConfig)(tree, options.projectRoot, [
36
- ...(rootProject ? [global_eslint_config_1.typeScriptOverride, global_eslint_config_1.javaScriptOverride] : []),
37
- {
38
- files: ['*.ts'],
39
- ...(hasParserOptions
40
- ? {
41
- parserOptions: {
42
- project: [`${options.projectRoot}/tsconfig.*?.json`],
43
- },
44
- }
45
- : {}),
46
- extends: [
47
- 'plugin:@nx/angular',
48
- 'plugin:@angular-eslint/template/process-inline-templates',
49
- ],
36
+ if ((0, flat_config_1.useFlatConfig)(tree)) {
37
+ (0, eslint_file_1.addPredefinedConfigToFlatLintConfig)(tree, options.projectRoot, 'flat/angular');
38
+ (0, eslint_file_1.addPredefinedConfigToFlatLintConfig)(tree, options.projectRoot, 'flat/angular-template');
39
+ (0, eslint_file_1.addOverrideToLintConfig)(tree, options.projectRoot, {
50
40
  rules: {
51
41
  '@angular-eslint/directive-selector': [
52
42
  'error',
@@ -65,28 +55,86 @@ async function addLintingGenerator(tree, options) {
65
55
  },
66
56
  ],
67
57
  },
68
- },
69
- {
70
- files: ['*.html'],
71
- extends: ['plugin:@nx/angular-template'],
72
- /**
73
- * Having an empty rules object present makes it more obvious to the user where they would
74
- * extend things from if they needed to
75
- */
76
- rules: {},
77
- },
78
- ...((0, buildable_project_1.isBuildableLibraryProject)(tree, options.projectName)
79
- ? [
80
- {
81
- files: ['*.json'],
82
- parser: 'jsonc-eslint-parser',
83
- rules: {
84
- '@nx/dependency-checks': 'error',
85
- },
58
+ });
59
+ if ((0, buildable_project_1.isBuildableLibraryProject)(tree, options.projectName)) {
60
+ (0, eslint_file_1.addOverrideToLintConfig)(tree, '', {
61
+ files: ['*.json'],
62
+ parser: 'jsonc-eslint-parser',
63
+ rules: {
64
+ '@nx/dependency-checks': [
65
+ 'error',
66
+ {
67
+ // With flat configs, we don't want to include imports in the eslint js/cjs/mjs files to be checked
68
+ ignoredFiles: ['**/*/*eslint*'],
69
+ },
70
+ ],
71
+ },
72
+ });
73
+ }
74
+ }
75
+ else {
76
+ (0, eslint_file_1.replaceOverridesInLintConfig)(tree, options.projectRoot, [
77
+ ...(rootProject ? [global_eslint_config_1.typeScriptOverride, global_eslint_config_1.javaScriptOverride] : []),
78
+ {
79
+ files: ['*.ts'],
80
+ ...(hasParserOptions
81
+ ? {
82
+ parserOptions: {
83
+ project: [`${options.projectRoot}/tsconfig.*?.json`],
84
+ },
85
+ }
86
+ : {}),
87
+ extends: [
88
+ 'plugin:@nx/angular',
89
+ 'plugin:@angular-eslint/template/process-inline-templates',
90
+ ],
91
+ rules: {
92
+ '@angular-eslint/directive-selector': [
93
+ 'error',
94
+ {
95
+ type: 'attribute',
96
+ prefix: (0, string_utils_1.camelize)(options.prefix),
97
+ style: 'camelCase',
98
+ },
99
+ ],
100
+ '@angular-eslint/component-selector': [
101
+ 'error',
102
+ {
103
+ type: 'element',
104
+ prefix: (0, string_utils_1.dasherize)(options.prefix),
105
+ style: 'kebab-case',
106
+ },
107
+ ],
86
108
  },
87
- ]
88
- : []),
89
- ]);
109
+ },
110
+ {
111
+ files: ['*.html'],
112
+ extends: ['plugin:@nx/angular-template'],
113
+ /**
114
+ * Having an empty rules object present makes it more obvious to the user where they would
115
+ * extend things from if they needed to
116
+ */
117
+ rules: {},
118
+ },
119
+ ...((0, buildable_project_1.isBuildableLibraryProject)(tree, options.projectName)
120
+ ? [
121
+ {
122
+ files: ['*.json'],
123
+ parser: 'jsonc-eslint-parser',
124
+ rules: {
125
+ '@nx/dependency-checks': [
126
+ 'error',
127
+ {
128
+ // With flat configs, we don't want to include imports in the eslint js/cjs/mjs files to be checked
129
+ ignoredFiles: ['**/*/*eslint*'],
130
+ },
131
+ ],
132
+ },
133
+ },
134
+ ]
135
+ : []),
136
+ ]);
137
+ }
90
138
  }
91
139
  if (!options.skipPackageJson) {
92
140
  const installTask = (0, add_angular_eslint_dependencies_1.addAngularEsLintDependencies)(tree, options.projectName);
@@ -4,14 +4,19 @@ exports.addAngularEsLintDependencies = addAngularEsLintDependencies;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const version_utils_1 = require("../../utils/version-utils");
6
6
  const buildable_project_1 = require("./buildable-project");
7
+ const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
7
8
  function addAngularEsLintDependencies(tree, projectName) {
8
9
  const compatVersions = (0, version_utils_1.versions)(tree);
9
10
  const angularEslintVersionToInstall = compatVersions.angularEslintVersion;
10
- const devDependencies = {
11
- '@angular-eslint/eslint-plugin': angularEslintVersionToInstall,
12
- '@angular-eslint/eslint-plugin-template': angularEslintVersionToInstall,
13
- '@angular-eslint/template-parser': angularEslintVersionToInstall,
14
- };
11
+ const devDependencies = (0, flat_config_1.useFlatConfig)(tree)
12
+ ? {
13
+ 'angular-eslint': angularEslintVersionToInstall,
14
+ }
15
+ : {
16
+ '@angular-eslint/eslint-plugin': angularEslintVersionToInstall,
17
+ '@angular-eslint/eslint-plugin-template': angularEslintVersionToInstall,
18
+ '@angular-eslint/template-parser': angularEslintVersionToInstall,
19
+ };
15
20
  if ('typescriptEslintVersion' in compatVersions) {
16
21
  devDependencies['@typescript-eslint/utils'] =
17
22
  compatVersions.typescriptEslintVersion;
@@ -22,6 +22,7 @@ function addMfEnvToTargetDefaultInputs(tree) {
22
22
  }
23
23
  if (!mfEnvVarExists) {
24
24
  nxJson.targetDefaults[webpackExecutor].inputs.push({ env: mfEnvVar });
25
- (0, devkit_1.updateNxJson)(tree, nxJson);
26
25
  }
26
+ nxJson.targetDefaults[webpackExecutor].cache = true;
27
+ (0, devkit_1.updateNxJson)(tree, nxJson);
27
28
  }
@@ -12,7 +12,7 @@ async function withModuleFederationForSSR(options, configOverride) {
12
12
  return (config) => {
13
13
  const updatedConfig = {
14
14
  ...(config ?? {}),
15
- target: false,
15
+ target: 'async-node',
16
16
  output: {
17
17
  ...(config.output ?? {}),
18
18
  uniqueName: options.name,
@@ -30,7 +30,7 @@ async function withModuleFederationForSSR(options, configOverride) {
30
30
  },
31
31
  plugins: [
32
32
  ...(config.plugins ?? []),
33
- new (require('@module-federation/node').UniversalFederationPlugin)({
33
+ new (require('@module-federation/enhanced').ModuleFederationPlugin)({
34
34
  name: options.name,
35
35
  filename: 'remoteEntry.js',
36
36
  exposes: options.exposes,
@@ -38,10 +38,6 @@ async function withModuleFederationForSSR(options, configOverride) {
38
38
  shared: {
39
39
  ...sharedDependencies,
40
40
  },
41
- library: {
42
- type: 'commonjs-module',
43
- },
44
- isServer: true,
45
41
  /**
46
42
  * Apply user-defined config override
47
43
  */
@@ -50,9 +46,14 @@ async function withModuleFederationForSSR(options, configOverride) {
50
46
  !options.disableNxRuntimeLibraryControlPlugin
51
47
  ? [
52
48
  ...(configOverride?.runtimePlugins ?? []),
49
+ require.resolve('@module-federation/node/runtimePlugin'),
53
50
  require.resolve('@nx/webpack/src/utils/module-federation/plugins/runtime-library-control.plugin.js'),
54
51
  ]
55
- : configOverride?.runtimePlugins,
52
+ : [
53
+ ...(configOverride?.runtimePlugins ?? []),
54
+ require.resolve('@module-federation/node/runtimePlugin'),
55
+ ],
56
+ virtualRuntimeEntry: true,
56
57
  }, {}),
57
58
  sharedLibraries.getReplacementPlugin(),
58
59
  ],
@@ -55,6 +55,7 @@ async function withModuleFederation(options, configOverride) {
55
55
  require.resolve('@nx/webpack/src/utils/module-federation/plugins/runtime-library-control.plugin.js'),
56
56
  ]
57
57
  : configOverride?.runtimePlugins,
58
+ virtualRuntimeEntry: true,
58
59
  }),
59
60
  sharedLibraries.getReplacementPlugin(),
60
61
  ],
@@ -12,9 +12,9 @@ export declare const typesCorsVersion = "~2.8.5";
12
12
  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
- export declare const moduleFederationNodeVersion = "~2.4.0";
16
- export declare const moduleFederationEnhancedVersion = "~0.2.3";
17
- export declare const angularEslintVersion = "^18.0.1";
15
+ export declare const moduleFederationNodeVersion = "~2.5.0";
16
+ export declare const moduleFederationEnhancedVersion = "~0.6.0";
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";
20
20
  export declare const postcssVersion = "^8.4.5";
@@ -15,9 +15,9 @@ exports.typesCorsVersion = '~2.8.5';
15
15
  exports.expressVersion = '~4.18.2';
16
16
  exports.typesExpressVersion = '4.17.14';
17
17
  exports.browserSyncVersion = '^3.0.0';
18
- exports.moduleFederationNodeVersion = '~2.4.0';
19
- exports.moduleFederationEnhancedVersion = '~0.2.3';
20
- exports.angularEslintVersion = '^18.0.1';
18
+ exports.moduleFederationNodeVersion = '~2.5.0';
19
+ exports.moduleFederationEnhancedVersion = '~0.6.0';
20
+ exports.angularEslintVersion = '^18.3.0';
21
21
  exports.typescriptEslintVersion = '^7.16.0';
22
22
  exports.tailwindVersion = '^3.0.2';
23
23
  exports.postcssVersion = '^8.4.5';