@nx/angular 19.5.0 → 19.5.1
Sign up to get free protection for your applications and to get access to all the features.
- package/ng-package.json +2 -1
- package/package.json +9 -8
- package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.js +2 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +2 -0
- package/src/generators/utils/add-mf-env-to-inputs.js +1 -1
- package/src/utils/mf/with-module-federation-ssr.js +53 -38
- package/src/utils/mf/with-module-federation.js +56 -41
package/ng-package.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/angular",
|
3
|
-
"version": "19.5.
|
3
|
+
"version": "19.5.1",
|
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": {
|
@@ -78,15 +78,16 @@
|
|
78
78
|
"semver": "^7.5.3",
|
79
79
|
"tslib": "^2.3.0",
|
80
80
|
"webpack-merge": "^5.8.0",
|
81
|
+
"webpack": "^5.88.0",
|
81
82
|
"@module-federation/enhanced": "~0.2.3",
|
82
|
-
"@nx/devkit": "19.5.
|
83
|
-
"@nx/js": "19.5.
|
84
|
-
"@nx/eslint": "19.5.
|
85
|
-
"@nx/webpack": "19.5.
|
86
|
-
"@nx/web": "19.5.
|
87
|
-
"@nx/workspace": "19.5.
|
83
|
+
"@nx/devkit": "19.5.1",
|
84
|
+
"@nx/js": "19.5.1",
|
85
|
+
"@nx/eslint": "19.5.1",
|
86
|
+
"@nx/webpack": "19.5.1",
|
87
|
+
"@nx/web": "19.5.1",
|
88
|
+
"@nx/workspace": "19.5.1",
|
88
89
|
"piscina": "^4.4.0",
|
89
|
-
"@nrwl/angular": "19.5.
|
90
|
+
"@nrwl/angular": "19.5.1"
|
90
91
|
},
|
91
92
|
"peerDependencies": {
|
92
93
|
"@angular-devkit/build-angular": ">= 16.0.0 < 19.0.0",
|
@@ -36,6 +36,8 @@ function executeModuleFederationDevSSRBuilder(schema, context) {
|
|
36
36
|
: Array.isArray(options.devRemotes)
|
37
37
|
? options.devRemotes
|
38
38
|
: [options.devRemotes];
|
39
|
+
// Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
|
40
|
+
process.env.NX_MF_DEV_REMOTES = JSON.stringify(devServeRemotes);
|
39
41
|
(0, module_federation_1.validateDevRemotes)({ devRemotes: devServeRemotes }, workspaceProjects);
|
40
42
|
const remotesToSkip = new Set(options.skipRemotes ?? []);
|
41
43
|
const staticRemotes = (0, module_federation_1.getStaticRemotes)(project, context, workspaceProjects, remotesToSkip);
|
@@ -62,6 +62,8 @@ async function* moduleFederationDevServerExecutor(schema, context) {
|
|
62
62
|
projectGraph: context.projectGraph,
|
63
63
|
root: context.root,
|
64
64
|
}, pathToManifestFile);
|
65
|
+
// Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
|
66
|
+
process.env.NX_MF_DEV_REMOTES = JSON.stringify(remotes.devRemotes.map((r) => (typeof r === 'string' ? r : r.remoteName)));
|
65
67
|
if (remotes.devRemotes.length > 0 && !schema.staticRemotesPort) {
|
66
68
|
options.staticRemotesPort = options.devRemotes.reduce((portToUse, r) => {
|
67
69
|
const remoteName = typeof r === 'string' ? r : r.remoteName;
|
@@ -5,7 +5,7 @@ const devkit_1 = require("@nx/devkit");
|
|
5
5
|
function addMfEnvToTargetDefaultInputs(tree) {
|
6
6
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
7
7
|
const webpackExecutor = '@nx/angular:webpack-browser';
|
8
|
-
const mfEnvVar = '
|
8
|
+
const mfEnvVar = 'NX_MF_DEV_REMOTES';
|
9
9
|
nxJson.targetDefaults ??= {};
|
10
10
|
nxJson.targetDefaults[webpackExecutor] ??= {};
|
11
11
|
nxJson.targetDefaults[webpackExecutor].inputs ??= [
|
@@ -9,44 +9,59 @@ async function withModuleFederationForSSR(options, configOverride) {
|
|
9
9
|
const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_1.getModuleFederationConfig)(options, {
|
10
10
|
isServer: true,
|
11
11
|
});
|
12
|
-
return (config) =>
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
optimization: {
|
20
|
-
...(config.optimization ?? {}),
|
21
|
-
runtimeChunk: false,
|
22
|
-
},
|
23
|
-
resolve: {
|
24
|
-
...(config.resolve ?? {}),
|
25
|
-
alias: {
|
26
|
-
...(config.resolve?.alias ?? {}),
|
27
|
-
...sharedLibraries.getAliases(),
|
12
|
+
return (config) => {
|
13
|
+
const updatedConfig = {
|
14
|
+
...(config ?? {}),
|
15
|
+
target: false,
|
16
|
+
output: {
|
17
|
+
...(config.output ?? {}),
|
18
|
+
uniqueName: options.name,
|
28
19
|
},
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
...sharedDependencies,
|
39
|
-
},
|
40
|
-
library: {
|
41
|
-
type: 'commonjs-module',
|
20
|
+
optimization: {
|
21
|
+
...(config.optimization ?? {}),
|
22
|
+
runtimeChunk: false,
|
23
|
+
},
|
24
|
+
resolve: {
|
25
|
+
...(config.resolve ?? {}),
|
26
|
+
alias: {
|
27
|
+
...(config.resolve?.alias ?? {}),
|
28
|
+
...sharedLibraries.getAliases(),
|
42
29
|
},
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
30
|
+
},
|
31
|
+
plugins: [
|
32
|
+
...(config.plugins ?? []),
|
33
|
+
new (require('@module-federation/node').UniversalFederationPlugin)({
|
34
|
+
name: options.name,
|
35
|
+
filename: 'remoteEntry.js',
|
36
|
+
exposes: options.exposes,
|
37
|
+
remotes: mappedRemotes,
|
38
|
+
shared: {
|
39
|
+
...sharedDependencies,
|
40
|
+
},
|
41
|
+
library: {
|
42
|
+
type: 'commonjs-module',
|
43
|
+
},
|
44
|
+
isServer: true,
|
45
|
+
/**
|
46
|
+
* Apply user-defined config override
|
47
|
+
*/
|
48
|
+
...(configOverride ? configOverride : {}),
|
49
|
+
runtimePlugins: process.env.NX_MF_DEV_REMOTES &&
|
50
|
+
!options.disableNxRuntimeLibraryControlPlugin
|
51
|
+
? [
|
52
|
+
...(configOverride?.runtimePlugins ?? []),
|
53
|
+
require.resolve('@nx/webpack/src/utils/module-federation/plugins/runtime-library-control.plugin.js'),
|
54
|
+
]
|
55
|
+
: configOverride?.runtimePlugins,
|
56
|
+
}, {}),
|
57
|
+
sharedLibraries.getReplacementPlugin(),
|
58
|
+
],
|
59
|
+
};
|
60
|
+
// The env var is only set from the module-federation-dev-server
|
61
|
+
// Attach the runtime plugin
|
62
|
+
updatedConfig.plugins.push(new (require('webpack').DefinePlugin)({
|
63
|
+
'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
|
64
|
+
}));
|
65
|
+
return updatedConfig;
|
66
|
+
};
|
52
67
|
}
|
@@ -8,47 +8,62 @@ async function withModuleFederation(options, configOverride) {
|
|
8
8
|
return (config) => config;
|
9
9
|
}
|
10
10
|
const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_1.getModuleFederationConfig)(options);
|
11
|
-
return (config) =>
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
optimization: {
|
19
|
-
...(config.optimization ?? {}),
|
20
|
-
runtimeChunk: false,
|
21
|
-
},
|
22
|
-
resolve: {
|
23
|
-
...(config.resolve ?? {}),
|
24
|
-
alias: {
|
25
|
-
...(config.resolve?.alias ?? {}),
|
26
|
-
...sharedLibraries.getAliases(),
|
11
|
+
return (config) => {
|
12
|
+
const updatedConfig = {
|
13
|
+
...(config ?? {}),
|
14
|
+
output: {
|
15
|
+
...(config.output ?? {}),
|
16
|
+
uniqueName: options.name,
|
17
|
+
publicPath: 'auto',
|
27
18
|
},
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
filename: 'remoteEntry.mjs',
|
38
|
-
exposes: options.exposes,
|
39
|
-
remotes: mappedRemotes,
|
40
|
-
shared: {
|
41
|
-
...sharedDependencies,
|
42
|
-
},
|
43
|
-
library: {
|
44
|
-
type: 'module',
|
19
|
+
optimization: {
|
20
|
+
...(config.optimization ?? {}),
|
21
|
+
runtimeChunk: false,
|
22
|
+
},
|
23
|
+
resolve: {
|
24
|
+
...(config.resolve ?? {}),
|
25
|
+
alias: {
|
26
|
+
...(config.resolve?.alias ?? {}),
|
27
|
+
...sharedLibraries.getAliases(),
|
45
28
|
},
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
}
|
51
|
-
|
52
|
-
|
53
|
-
|
29
|
+
},
|
30
|
+
experiments: {
|
31
|
+
...(config.experiments ?? {}),
|
32
|
+
outputModule: true,
|
33
|
+
},
|
34
|
+
plugins: [
|
35
|
+
...(config.plugins ?? []),
|
36
|
+
new webpack_1.ModuleFederationPlugin({
|
37
|
+
name: options.name,
|
38
|
+
filename: 'remoteEntry.mjs',
|
39
|
+
exposes: options.exposes,
|
40
|
+
remotes: mappedRemotes,
|
41
|
+
shared: {
|
42
|
+
...sharedDependencies,
|
43
|
+
},
|
44
|
+
library: {
|
45
|
+
type: 'module',
|
46
|
+
},
|
47
|
+
/**
|
48
|
+
* Apply user-defined config override
|
49
|
+
*/
|
50
|
+
...(configOverride ? configOverride : {}),
|
51
|
+
runtimePlugins: process.env.NX_MF_DEV_REMOTES &&
|
52
|
+
!options.disableNxRuntimeLibraryControlPlugin
|
53
|
+
? [
|
54
|
+
...(configOverride?.runtimePlugins ?? []),
|
55
|
+
require.resolve('@nx/webpack/src/utils/module-federation/plugins/runtime-library-control.plugin.js'),
|
56
|
+
]
|
57
|
+
: configOverride?.runtimePlugins,
|
58
|
+
}),
|
59
|
+
sharedLibraries.getReplacementPlugin(),
|
60
|
+
],
|
61
|
+
};
|
62
|
+
// The env var is only set from the module-federation-dev-server
|
63
|
+
// Attach the runtime plugin
|
64
|
+
updatedConfig.plugins.push(new (require('webpack').DefinePlugin)({
|
65
|
+
'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
|
66
|
+
}));
|
67
|
+
return updatedConfig;
|
68
|
+
};
|
54
69
|
}
|