@nx/angular 19.6.0 → 19.7.0-canary.20240817-b91d788
Sign up to get free protection for your applications and to get access to all the features.
- package/migrations.json +6 -0
- package/package.json +8 -8
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +6 -2
- package/src/generators/setup-mf/lib/index.d.ts +1 -0
- package/src/generators/setup-mf/lib/index.js +1 -0
- package/src/generators/setup-mf/lib/move-angular-plugin-to-dependencies.d.ts +2 -0
- package/src/generators/setup-mf/lib/move-angular-plugin-to-dependencies.js +15 -0
- package/src/generators/setup-mf/setup-mf.d.ts +1 -1
- package/src/generators/setup-mf/setup-mf.js +9 -1
- package/src/generators/utils/add-mf-env-to-inputs.js +1 -0
- package/src/migrations/update-19-6-1/ensure-depends-on-for-mf.d.ts +2 -0
- package/src/migrations/update-19-6-1/ensure-depends-on-for-mf.js +46 -0
package/migrations.json
CHANGED
@@ -428,6 +428,12 @@
|
|
428
428
|
},
|
429
429
|
"description": "Update the @angular/cli package version to ~18.2.0.",
|
430
430
|
"factory": "./src/migrations/update-19-6-0/update-angular-cli"
|
431
|
+
},
|
432
|
+
"update-19-6-1-ensure-module-federation-target-defaults": {
|
433
|
+
"cli": "nx",
|
434
|
+
"version": "19.6.1-beta.0",
|
435
|
+
"description": "Ensure Target Defaults are set correctly for Module Federation.",
|
436
|
+
"factory": "./src/migrations/update-19-6-1/ensure-depends-on-for-mf"
|
431
437
|
}
|
432
438
|
},
|
433
439
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/angular",
|
3
|
-
"version": "19.
|
3
|
+
"version": "19.7.0-canary.20240817-b91d788",
|
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,14 +79,14 @@
|
|
79
79
|
"webpack-merge": "^5.8.0",
|
80
80
|
"webpack": "^5.88.0",
|
81
81
|
"@module-federation/enhanced": "~0.2.3",
|
82
|
-
"@nx/devkit": "19.
|
83
|
-
"@nx/js": "19.
|
84
|
-
"@nx/eslint": "19.
|
85
|
-
"@nx/webpack": "19.
|
86
|
-
"@nx/web": "19.
|
87
|
-
"@nx/workspace": "19.
|
82
|
+
"@nx/devkit": "19.7.0-canary.20240817-b91d788",
|
83
|
+
"@nx/js": "19.7.0-canary.20240817-b91d788",
|
84
|
+
"@nx/eslint": "19.7.0-canary.20240817-b91d788",
|
85
|
+
"@nx/webpack": "19.7.0-canary.20240817-b91d788",
|
86
|
+
"@nx/web": "19.7.0-canary.20240817-b91d788",
|
87
|
+
"@nx/workspace": "19.7.0-canary.20240817-b91d788",
|
88
88
|
"piscina": "^4.4.0",
|
89
|
-
"@nrwl/angular": "19.
|
89
|
+
"@nrwl/angular": "19.7.0-canary.20240817-b91d788"
|
90
90
|
},
|
91
91
|
"peerDependencies": {
|
92
92
|
"@angular-devkit/build-angular": ">= 16.0.0 < 19.0.0",
|
package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js
CHANGED
@@ -17,11 +17,15 @@ const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
|
|
17
17
|
const normalize_options_1 = require("./lib/normalize-options");
|
18
18
|
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
19
19
|
const start_ssr_remote_proxies_1 = require("@nx/webpack/src/utils/module-federation/start-ssr-remote-proxies");
|
20
|
-
const
|
20
|
+
const angular_version_utils_1 = require("../utilities/angular-version-utils");
|
21
21
|
async function* moduleFederationSsrDevServerExecutor(schema, context) {
|
22
22
|
const nxBin = require.resolve('nx/bin/nx');
|
23
23
|
const options = (0, normalize_options_1.normalizeOptions)(schema);
|
24
|
-
const
|
24
|
+
const { major: angularMajorVersion } = (0, angular_version_utils_1.getInstalledAngularVersionInfo)();
|
25
|
+
const { executeSSRDevServerBuilder } = angularMajorVersion >= 17
|
26
|
+
? require('@angular-devkit/build-angular')
|
27
|
+
: require('@nguniversal/builders');
|
28
|
+
const currIter = (0, rxjs_for_await_1.eachValueFrom)(executeSSRDevServerBuilder(options, await (0, ngcli_adapter_1.createBuilderContext)({
|
25
29
|
builderName: '@nx/angular:webpack-server',
|
26
30
|
description: 'Build a ssr application',
|
27
31
|
optionSchema: require('../../builders/webpack-server/schema.json'),
|
@@ -5,6 +5,7 @@ export * from './change-build-target';
|
|
5
5
|
export * from './fix-bootstrap';
|
6
6
|
export * from './generate-config';
|
7
7
|
export * from './get-remotes-with-ports';
|
8
|
+
export * from './move-angular-plugin-to-dependencies';
|
8
9
|
export * from './normalize-options';
|
9
10
|
export * from './update-tsconfig';
|
10
11
|
export * from './setup-host-if-dynamic';
|
@@ -8,6 +8,7 @@ tslib_1.__exportStar(require("./change-build-target"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./fix-bootstrap"), exports);
|
9
9
|
tslib_1.__exportStar(require("./generate-config"), exports);
|
10
10
|
tslib_1.__exportStar(require("./get-remotes-with-ports"), exports);
|
11
|
+
tslib_1.__exportStar(require("./move-angular-plugin-to-dependencies"), exports);
|
11
12
|
tslib_1.__exportStar(require("./normalize-options"), exports);
|
12
13
|
tslib_1.__exportStar(require("./update-tsconfig"), exports);
|
13
14
|
tslib_1.__exportStar(require("./setup-host-if-dynamic"), exports);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.moveAngularPluginToDependencies = moveAngularPluginToDependencies;
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
5
|
+
function moveAngularPluginToDependencies(tree) {
|
6
|
+
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
7
|
+
if (packageJson.dependencies?.['@nx/angular']) {
|
8
|
+
return;
|
9
|
+
}
|
10
|
+
packageJson.dependencies ??= {};
|
11
|
+
packageJson.dependencies['@nx/angular'] =
|
12
|
+
packageJson.devDependencies['@nx/angular'];
|
13
|
+
delete packageJson.devDependencies['@nx/angular'];
|
14
|
+
(0, devkit_1.writeJson)(tree, 'package.json', packageJson);
|
15
|
+
}
|
@@ -2,8 +2,8 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.setupMf = setupMf;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
|
-
const lib_1 = require("./lib");
|
6
5
|
const versions_1 = require("../../utils/versions");
|
6
|
+
const lib_1 = require("./lib");
|
7
7
|
async function setupMf(tree, rawOptions) {
|
8
8
|
const options = (0, lib_1.normalizeOptions)(tree, rawOptions);
|
9
9
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.appName);
|
@@ -50,6 +50,14 @@ async function setupMf(tree, rawOptions) {
|
|
50
50
|
}
|
51
51
|
}
|
52
52
|
(0, lib_1.fixBootstrap)(tree, projectConfig.root, options);
|
53
|
+
if (options.mfType === 'host' || options.federationType === 'dynamic') {
|
54
|
+
/**
|
55
|
+
* Host applications and dynamic federation applications generate runtime
|
56
|
+
* code that depends on the @nx/angular plugin. Ensure that the plugin is
|
57
|
+
* in the production dependencies.
|
58
|
+
*/
|
59
|
+
(0, lib_1.moveAngularPluginToDependencies)(tree);
|
60
|
+
}
|
53
61
|
if (!options.skipE2E) {
|
54
62
|
(0, lib_1.addCypressOnErrorWorkaround)(tree, options);
|
55
63
|
}
|
@@ -12,6 +12,7 @@ function addMfEnvToTargetDefaultInputs(tree) {
|
|
12
12
|
'production',
|
13
13
|
'^production',
|
14
14
|
];
|
15
|
+
nxJson.targetDefaults[webpackExecutor].dependsOn ??= ['^build'];
|
15
16
|
let mfEnvVarExists = false;
|
16
17
|
for (const input of nxJson.targetDefaults[webpackExecutor].inputs) {
|
17
18
|
if (typeof input === 'object' && input['env'] === mfEnvVar) {
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = default_1;
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
6
|
+
async function default_1(tree) {
|
7
|
+
let usesModuleFederation = false;
|
8
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/angular:webpack-browser', (options, projectName, targetName) => {
|
9
|
+
const webpackConfig = options.webpackConfig;
|
10
|
+
if (!webpackConfig) {
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
const webpackContents = tree.read(webpackConfig, 'utf-8');
|
14
|
+
if (['withModuleFederation', 'withModuleFederationForSSR'].some((p) => webpackContents.includes(p))) {
|
15
|
+
usesModuleFederation = true;
|
16
|
+
}
|
17
|
+
});
|
18
|
+
if (!usesModuleFederation) {
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
22
|
+
const nxMFDevRemotesEnvVar = 'NX_MF_DEV_REMOTES';
|
23
|
+
if (!nxJson.targetDefaults ||
|
24
|
+
!nxJson.targetDefaults?.['@nx/angular:webpack-browser']) {
|
25
|
+
nxJson.targetDefaults ??= {};
|
26
|
+
nxJson.targetDefaults['@nx/angular:webpack-browser'] = {
|
27
|
+
cache: true,
|
28
|
+
inputs: ['production', '^production', { env: nxMFDevRemotesEnvVar }],
|
29
|
+
dependsOn: ['^build'],
|
30
|
+
};
|
31
|
+
}
|
32
|
+
else {
|
33
|
+
nxJson.targetDefaults['@nx/angular:webpack-browser'].dependsOn ??= [];
|
34
|
+
if (!nxJson.targetDefaults['@nx/angular:webpack-browser'].dependsOn.includes('^build')) {
|
35
|
+
nxJson.targetDefaults['@nx/angular:webpack-browser'].dependsOn.push('^build');
|
36
|
+
}
|
37
|
+
nxJson.targetDefaults['@nx/angular:webpack-browser'].inputs ??= [];
|
38
|
+
if (!nxJson.targetDefaults['@nx/angular:webpack-browser'].inputs.find((i) => typeof i === 'string' ? false : i['env'] === nxMFDevRemotesEnvVar)) {
|
39
|
+
nxJson.targetDefaults['@nx/angular:webpack-browser'].inputs.push({
|
40
|
+
env: nxMFDevRemotesEnvVar,
|
41
|
+
});
|
42
|
+
}
|
43
|
+
}
|
44
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
45
|
+
await (0, devkit_1.formatFiles)(tree);
|
46
|
+
}
|