@nx/angular 17.1.1 → 17.2.0-beta.0
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 +16 -0
- package/package.json +10 -10
- package/src/builders/module-federation-dev-server/module-federation-dev-server.impl.d.ts +1 -1
- package/src/builders/module-federation-dev-server/module-federation-dev-server.impl.js +151 -110
- package/src/builders/module-federation-dev-server/schema.d.ts +1 -0
- package/src/builders/module-federation-dev-server/schema.json +4 -0
- package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.js +2 -1
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-package.transform.js +5 -1
- package/src/generators/application/files/ng-module/src/app/app.component.ts__tpl__ +4 -2
- package/src/generators/application/files/standalone-components/src/app/app.component.ts__tpl__ +4 -2
- package/src/generators/application/files/standalone-components/src/app/app.config.ts__tpl__ +1 -1
- package/src/generators/application/files/standalone-components/src/main.ts__tpl__ +1 -7
- package/src/generators/application/lib/create-files.js +3 -3
- package/src/generators/component/component.js +3 -0
- package/src/generators/component/files/__fileName__.ts__tpl__ +8 -2
- package/src/generators/host/host.js +1 -0
- package/src/generators/remote/files/common/pre-v17/src/main.server.ts__tmpl__ +1 -1
- package/src/generators/remote/files/common/v17+/src/main.server.ts__tmpl__ +1 -1
- package/src/generators/remote/remote.js +1 -0
- package/src/generators/setup-mf/files/ts-webpack/module-federation.config.ts__tmpl__ +12 -0
- package/src/generators/setup-mf/files/ts-webpack/tsconfig.lint.json__tmpl__ +12 -0
- package/src/generators/setup-mf/files/webpack/module-federation.config.js__tmpl__ +13 -1
- package/src/generators/setup-mf/lib/generate-config.js +3 -0
- package/src/generators/setup-mf/schema.d.ts +1 -0
- package/src/generators/setup-mf/schema.json +5 -0
- package/src/generators/storybook-configuration/lib/generate-stories.js +3 -3
- package/src/generators/storybook-configuration/lib/generate-storybook-configuration.js +1 -1
- package/src/generators/storybook-configuration/schema.d.ts +1 -1
- package/src/generators/storybook-configuration/schema.json +3 -3
- package/src/migrations/update-17-1-0/replace-nguniversal-engines.js +18 -8
- package/src/utils/mf/utils.js +7 -0
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
package/migrations.json
CHANGED
|
@@ -1489,6 +1489,22 @@
|
|
|
1489
1489
|
"alwaysAddToPackageJson": false
|
|
1490
1490
|
}
|
|
1491
1491
|
}
|
|
1492
|
+
},
|
|
1493
|
+
"17.1.3-jest": {
|
|
1494
|
+
"version": "17.1.3-beta.0",
|
|
1495
|
+
"requires": {
|
|
1496
|
+
"@angular-devkit/build-angular": ">=13.0.0 <18.0.0",
|
|
1497
|
+
"@angular/compiler-cli": ">=13.0.0 <18.0.0",
|
|
1498
|
+
"@angular/core": ">=13.0.0 <18.0.0",
|
|
1499
|
+
"@angular/platform-browser-dynamic": ">=13.0.0 <18.0.0",
|
|
1500
|
+
"jest": "^29.0.0"
|
|
1501
|
+
},
|
|
1502
|
+
"packages": {
|
|
1503
|
+
"jest-preset-angular": {
|
|
1504
|
+
"version": "~13.1.4",
|
|
1505
|
+
"alwaysAddToPackageJson": false
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1492
1508
|
}
|
|
1493
1509
|
}
|
|
1494
1510
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/angular",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.2.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, 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- Upgrading AngularJS applications \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
|
|
6
6
|
"repository": {
|
|
@@ -78,15 +78,15 @@
|
|
|
78
78
|
"tslib": "^2.3.0",
|
|
79
79
|
"webpack": "^5.80.0",
|
|
80
80
|
"webpack-merge": "^5.8.0",
|
|
81
|
-
"@nx/devkit": "17.
|
|
82
|
-
"@nx/cypress": "17.
|
|
83
|
-
"@nx/jest": "17.
|
|
84
|
-
"@nx/js": "17.
|
|
85
|
-
"@nx/eslint": "17.
|
|
86
|
-
"@nx/webpack": "17.
|
|
87
|
-
"@nx/web": "17.
|
|
88
|
-
"@nx/workspace": "17.
|
|
89
|
-
"@nrwl/angular": "17.
|
|
81
|
+
"@nx/devkit": "17.2.0-beta.0",
|
|
82
|
+
"@nx/cypress": "17.2.0-beta.0",
|
|
83
|
+
"@nx/jest": "17.2.0-beta.0",
|
|
84
|
+
"@nx/js": "17.2.0-beta.0",
|
|
85
|
+
"@nx/eslint": "17.2.0-beta.0",
|
|
86
|
+
"@nx/webpack": "17.2.0-beta.0",
|
|
87
|
+
"@nx/web": "17.2.0-beta.0",
|
|
88
|
+
"@nx/workspace": "17.2.0-beta.0",
|
|
89
|
+
"@nrwl/angular": "17.2.0-beta.0"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"@angular-devkit/build-angular": ">= 15.0.0 < 18.0.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { executeWebpackDevServerBuilder } from '../webpack-dev-server/webpack-dev-server.impl';
|
|
2
1
|
import type { Schema } from './schema';
|
|
2
|
+
import { executeWebpackDevServerBuilder } from '../webpack-dev-server/webpack-dev-server.impl';
|
|
3
3
|
export declare function executeModuleFederationDevServerBuilder(schema: Schema, context: import('@angular-devkit/architect').BuilderContext): ReturnType<typeof executeWebpackDevServerBuilder | any>;
|
|
4
4
|
declare const _default: any;
|
|
5
5
|
export default _default;
|
|
@@ -2,20 +2,147 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.executeModuleFederationDevServerBuilder = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const module_federation_1 = require("@nx/webpack/src/utils/module-federation");
|
|
6
|
-
const child_process_1 = require("child_process");
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
5
|
const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
|
|
9
|
-
const
|
|
6
|
+
const webpack_dev_server_impl_1 = require("../webpack-dev-server/webpack-dev-server.impl");
|
|
10
7
|
const project_graph_1 = require("nx/src/project-graph/project-graph");
|
|
8
|
+
const executor_utils_1 = require("nx/src/command-line/run/executor-utils");
|
|
9
|
+
const module_federation_1 = require("../utilities/module-federation");
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
11
|
const path_1 = require("path");
|
|
12
|
+
const module_federation_2 = require("@nx/webpack/src/utils/module-federation");
|
|
13
|
+
const child_process_1 = require("child_process");
|
|
12
14
|
const rxjs_1 = require("rxjs");
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
+
const fs_2 = require("fs");
|
|
16
|
+
function buildStaticRemotes(remotes, nxBin, context, options) {
|
|
17
|
+
const mappedLocationOfRemotes = {};
|
|
18
|
+
for (const app of remotes.staticRemotes) {
|
|
19
|
+
mappedLocationOfRemotes[app] = `http${options.ssl ? 's' : ''}://${options.host}:${options.staticRemotesPort}/${app}`;
|
|
20
|
+
}
|
|
21
|
+
process.env.NX_MF_DEV_SERVER_STATIC_REMOTES = JSON.stringify(mappedLocationOfRemotes);
|
|
22
|
+
const staticRemoteBuildPromise = new Promise((res) => {
|
|
23
|
+
devkit_1.logger.info(`NX Building ${remotes.staticRemotes.length} static remotes...`);
|
|
24
|
+
const staticProcess = (0, child_process_1.fork)(nxBin, [
|
|
25
|
+
'run-many',
|
|
26
|
+
`--target=build`,
|
|
27
|
+
`--projects=${remotes.staticRemotes.join(',')}`,
|
|
28
|
+
...(context.target.configuration
|
|
29
|
+
? [`--configuration=${context.target.configuration}`]
|
|
30
|
+
: []),
|
|
31
|
+
...(options.parallel ? [`--parallel=${options.parallel}`] : []),
|
|
32
|
+
], {
|
|
33
|
+
cwd: context.workspaceRoot,
|
|
34
|
+
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
|
|
35
|
+
});
|
|
36
|
+
staticProcess.stdout.on('data', (data) => {
|
|
37
|
+
const ANSII_CODE_REGEX = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
|
38
|
+
const stdoutString = data.toString().replace(ANSII_CODE_REGEX, '');
|
|
39
|
+
if (stdoutString.includes('Successfully ran target build')) {
|
|
40
|
+
staticProcess.stdout.removeAllListeners('data');
|
|
41
|
+
devkit_1.logger.info(`NX Built ${remotes.staticRemotes.length} static remotes`);
|
|
42
|
+
res();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
staticProcess.stderr.on('data', (data) => devkit_1.logger.info(data.toString()));
|
|
46
|
+
staticProcess.on('exit', (code) => {
|
|
47
|
+
if (code !== 0) {
|
|
48
|
+
throw new Error(`Remotes failed to build. See above for errors.`);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
|
|
52
|
+
process.on('exit', () => staticProcess.kill('SIGTERM'));
|
|
53
|
+
});
|
|
54
|
+
return staticRemoteBuildPromise;
|
|
55
|
+
}
|
|
56
|
+
function startStaticRemotesFileServer(remotes, projectGraph, options, context) {
|
|
57
|
+
let shouldMoveToCommonLocation = false;
|
|
58
|
+
let commonOutputDirectory;
|
|
59
|
+
for (const app of remotes.staticRemotes) {
|
|
60
|
+
const outputPath = projectGraph.nodes[app].data.targets['build'].options.outputPath;
|
|
61
|
+
const directoryOfOutputPath = (0, path_1.dirname)(outputPath);
|
|
62
|
+
if (!commonOutputDirectory) {
|
|
63
|
+
commonOutputDirectory = directoryOfOutputPath;
|
|
64
|
+
}
|
|
65
|
+
else if (commonOutputDirectory !== directoryOfOutputPath) {
|
|
66
|
+
shouldMoveToCommonLocation = true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (shouldMoveToCommonLocation) {
|
|
70
|
+
commonOutputDirectory = (0, path_1.join)(devkit_1.workspaceRoot, 'tmp/static-remotes');
|
|
71
|
+
for (const app of remotes.staticRemotes) {
|
|
72
|
+
const outputPath = projectGraph.nodes[app].data.targets['build'].options.outputPath;
|
|
73
|
+
const outputPathParts = outputPath.split('/');
|
|
74
|
+
(0, fs_2.cpSync)(outputPath, (0, path_1.join)(commonOutputDirectory, outputPathParts[outputPathParts.length - 1]), {
|
|
75
|
+
force: true,
|
|
76
|
+
recursive: true,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const staticRemotesIter$ = (0, rxjs_1.from)(Promise.resolve().then(() => require('@nx/web/src/executors/file-server/file-server.impl'))).pipe((0, rxjs_1.switchMap)((fileServerExecutor) => fileServerExecutor.default({
|
|
81
|
+
cors: true,
|
|
82
|
+
watch: false,
|
|
83
|
+
staticFilePath: commonOutputDirectory,
|
|
84
|
+
parallel: false,
|
|
85
|
+
spa: false,
|
|
86
|
+
withDeps: false,
|
|
87
|
+
host: options.host,
|
|
88
|
+
port: options.staticRemotesPort,
|
|
89
|
+
ssl: options.ssl,
|
|
90
|
+
sslCert: options.sslCert,
|
|
91
|
+
sslKey: options.sslKey,
|
|
92
|
+
}, {
|
|
93
|
+
projectGraph,
|
|
94
|
+
root: context.workspaceRoot,
|
|
95
|
+
target: projectGraph.nodes[context.target.project].data.targets[context.target.target],
|
|
96
|
+
targetName: context.target.target,
|
|
97
|
+
projectName: context.target.project,
|
|
98
|
+
configurationName: context.target.configuration,
|
|
99
|
+
cwd: context.currentDirectory,
|
|
100
|
+
isVerbose: options.verbose,
|
|
101
|
+
projectsConfigurations: (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph),
|
|
102
|
+
nxJsonConfiguration: (0, devkit_1.readNxJson)(),
|
|
103
|
+
})));
|
|
104
|
+
return staticRemotesIter$;
|
|
105
|
+
}
|
|
106
|
+
function startDevRemotes(remotes, workspaceProjects, options, context) {
|
|
107
|
+
const devRemotes$ = [];
|
|
108
|
+
for (const app of remotes.devRemotes) {
|
|
109
|
+
if (!workspaceProjects[app].targets?.['serve']) {
|
|
110
|
+
throw new Error(`Could not find "serve" target in "${app}" project.`);
|
|
111
|
+
}
|
|
112
|
+
else if (!workspaceProjects[app].targets?.['serve'].executor) {
|
|
113
|
+
throw new Error(`Could not find executor for "serve" target in "${app}" project.`);
|
|
114
|
+
}
|
|
115
|
+
const runOptions = {};
|
|
116
|
+
const [collection, executor] = workspaceProjects[app].targets['serve'].executor.split(':');
|
|
117
|
+
const isUsingModuleFederationDevServerExecutor = executor.includes('module-federation-dev-server');
|
|
118
|
+
const { schema } = (0, executor_utils_1.getExecutorInformation)(collection, executor, devkit_1.workspaceRoot, workspaceProjects);
|
|
119
|
+
if ((options.verbose && schema.additionalProperties) ||
|
|
120
|
+
'verbose' in schema.properties) {
|
|
121
|
+
runOptions.verbose = options.verbose;
|
|
122
|
+
}
|
|
123
|
+
if (isUsingModuleFederationDevServerExecutor) {
|
|
124
|
+
runOptions.isInitialHost = false;
|
|
125
|
+
}
|
|
126
|
+
const serve$ = (0, ngcli_adapter_1.scheduleTarget)(context.workspaceRoot, {
|
|
127
|
+
project: app,
|
|
128
|
+
target: 'serve',
|
|
129
|
+
configuration: context.target.configuration,
|
|
130
|
+
runOptions,
|
|
131
|
+
projects: workspaceProjects,
|
|
132
|
+
}, options.verbose).then((obs) => {
|
|
133
|
+
obs.toPromise().catch((err) => {
|
|
134
|
+
throw new Error(`Remote '${app}' failed to serve correctly due to the following: \r\n${err.toString()}`);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
devRemotes$.push(serve$);
|
|
138
|
+
}
|
|
139
|
+
return devRemotes$;
|
|
140
|
+
}
|
|
15
141
|
function executeModuleFederationDevServerBuilder(schema, context) {
|
|
16
142
|
// Force Node to resolve to look for the nx binary that is inside node_modules
|
|
17
143
|
const nxBin = require.resolve('nx/bin/nx');
|
|
18
144
|
const options = normalizeOptions(schema);
|
|
145
|
+
options.staticRemotesPort ??= options.port + 1;
|
|
19
146
|
const projectGraph = (0, devkit_1.readCachedProjectGraph)();
|
|
20
147
|
const { projects: workspaceProjects } = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
|
21
148
|
const project = workspaceProjects[context.target.project];
|
|
@@ -37,7 +164,7 @@ function executeModuleFederationDevServerBuilder(schema, context) {
|
|
|
37
164
|
configurationName: context.target.configuration,
|
|
38
165
|
cwd: context.currentDirectory,
|
|
39
166
|
isVerbose: options.verbose,
|
|
40
|
-
projectsConfigurations:
|
|
167
|
+
projectsConfigurations: { projects: workspaceProjects, version: 2 },
|
|
41
168
|
nxJsonConfiguration: (0, devkit_1.readNxJson)(),
|
|
42
169
|
})));
|
|
43
170
|
const webpackDevServer = (0, webpack_dev_server_impl_1.executeWebpackDevServerBuilder)(options, context);
|
|
@@ -56,116 +183,30 @@ function executeModuleFederationDevServerBuilder(schema, context) {
|
|
|
56
183
|
}
|
|
57
184
|
pathToManifestFile = userPathToManifestFile;
|
|
58
185
|
}
|
|
59
|
-
(0,
|
|
60
|
-
const moduleFederationConfig = (0,
|
|
61
|
-
const remotes = (0,
|
|
186
|
+
(0, module_federation_1.validateDevRemotes)(options, workspaceProjects);
|
|
187
|
+
const moduleFederationConfig = (0, module_federation_2.getModuleFederationConfig)(project.targets.build.options.tsConfig, context.workspaceRoot, project.root, 'angular');
|
|
188
|
+
const remotes = (0, module_federation_2.getRemotes)(options.devRemotes, options.skipRemotes, moduleFederationConfig, {
|
|
62
189
|
projectName: project.name,
|
|
63
190
|
projectGraph,
|
|
64
191
|
root: context.workspaceRoot,
|
|
65
192
|
}, pathToManifestFile);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
`--projects=${remotes.staticRemotes.join(',')}`,
|
|
72
|
-
...(context.target.configuration
|
|
73
|
-
? [`--configuration=${context.target.configuration}`]
|
|
74
|
-
: []),
|
|
75
|
-
...(options.parallel ? [`--parallel=${options.parallel}`] : []),
|
|
76
|
-
], {
|
|
77
|
-
cwd: context.workspaceRoot,
|
|
78
|
-
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
|
|
79
|
-
});
|
|
80
|
-
staticProcess.stdout.on('data', (data) => {
|
|
81
|
-
const ANSII_CODE_REGEX = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
|
82
|
-
const stdoutString = data.toString().replace(ANSII_CODE_REGEX, '');
|
|
83
|
-
if (stdoutString.includes('Successfully ran target build')) {
|
|
84
|
-
staticProcess.stdout.removeAllListeners('data');
|
|
85
|
-
devkit_1.logger.info(`NX Built ${remotes.staticRemotes.length} static remotes`);
|
|
86
|
-
res();
|
|
193
|
+
if (remotes.devRemotes.length > 0 && !schema.staticRemotesPort) {
|
|
194
|
+
options.staticRemotesPort = options.devRemotes.reduce((portToUse, r) => {
|
|
195
|
+
const remotePort = projectGraph.nodes[r].data.targets['serve'].options.port;
|
|
196
|
+
if (remotePort >= portToUse) {
|
|
197
|
+
return remotePort + 1;
|
|
87
198
|
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (code !== 0) {
|
|
92
|
-
throw new Error(`Remotes failed to build. See above for errors.`);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
|
|
96
|
-
process.on('exit', () => staticProcess.kill('SIGTERM'));
|
|
97
|
-
});
|
|
199
|
+
}, options.staticRemotesPort);
|
|
200
|
+
}
|
|
201
|
+
const staticRemoteBuildPromise = buildStaticRemotes(remotes, nxBin, context, options);
|
|
98
202
|
return (0, rxjs_1.from)(staticRemoteBuildPromise).pipe((0, rxjs_1.concatMap)(() => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
let outWithErr = [];
|
|
104
|
-
const staticProcess = (0, child_process_1.fork)(nxBin, [
|
|
105
|
-
'run',
|
|
106
|
-
`${app}:serve-static${context.target.configuration
|
|
107
|
-
? `:${context.target.configuration}`
|
|
108
|
-
: ''}`,
|
|
109
|
-
...(isUsingModuleFederationDevServerExecutor
|
|
110
|
-
? [`--isInitialHost=false`]
|
|
111
|
-
: []),
|
|
112
|
-
], {
|
|
113
|
-
cwd: context.workspaceRoot,
|
|
114
|
-
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
|
|
115
|
-
});
|
|
116
|
-
staticProcess.stdout.on('data', (data) => {
|
|
117
|
-
if (isCollectingStaticRemoteOutput) {
|
|
118
|
-
outWithErr.push(data.toString());
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
outWithErr = null;
|
|
122
|
-
staticProcess.stdout.removeAllListeners('data');
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
staticProcess.stderr.on('data', (data) => devkit_1.logger.info(data.toString()));
|
|
126
|
-
staticProcess.on('exit', (code) => {
|
|
127
|
-
if (code !== 0) {
|
|
128
|
-
devkit_1.logger.info(outWithErr.join(''));
|
|
129
|
-
throw new Error(`Remote failed to start. See above for errors.`);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
|
|
133
|
-
process.on('exit', () => staticProcess.kill('SIGTERM'));
|
|
134
|
-
}
|
|
135
|
-
const devRemotes$ = [];
|
|
136
|
-
for (const app of remotes.devRemotes) {
|
|
137
|
-
if (!workspaceProjects[app].targets?.['serve']) {
|
|
138
|
-
throw new Error(`Could not find "serve" target in "${app}" project.`);
|
|
139
|
-
}
|
|
140
|
-
else if (!workspaceProjects[app].targets?.['serve'].executor) {
|
|
141
|
-
throw new Error(`Could not find executor for "serve" target in "${app}" project.`);
|
|
142
|
-
}
|
|
143
|
-
const runOptions = {};
|
|
144
|
-
const [collection, executor] = workspaceProjects[app].targets['serve'].executor.split(':');
|
|
145
|
-
const isUsingModuleFederationDevServerExecutor = executor.includes('module-federation-dev-server');
|
|
146
|
-
const { schema } = (0, executor_utils_1.getExecutorInformation)(collection, executor, devkit_1.workspaceRoot);
|
|
147
|
-
if ((options.verbose && schema.additionalProperties) ||
|
|
148
|
-
'verbose' in schema.properties) {
|
|
149
|
-
runOptions.verbose = options.verbose;
|
|
150
|
-
}
|
|
151
|
-
if (isUsingModuleFederationDevServerExecutor) {
|
|
152
|
-
runOptions.isInitialHost = false;
|
|
153
|
-
}
|
|
154
|
-
const serve$ = (0, ngcli_adapter_1.scheduleTarget)(context.workspaceRoot, {
|
|
155
|
-
project: app,
|
|
156
|
-
target: 'serve',
|
|
157
|
-
configuration: context.target.configuration,
|
|
158
|
-
runOptions,
|
|
159
|
-
}, options.verbose).then((obs) => {
|
|
160
|
-
obs.toPromise().catch((err) => {
|
|
161
|
-
throw new Error(`Remote '${app}' failed to serve correctly due to the following: \r\n${err.toString()}`);
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
devRemotes$.push(serve$);
|
|
165
|
-
}
|
|
203
|
+
const staticRemotesIter$ = remotes.staticRemotes.length > 0
|
|
204
|
+
? startStaticRemotesFileServer(remotes, projectGraph, options, context)
|
|
205
|
+
: (0, rxjs_1.from)(Promise.resolve());
|
|
206
|
+
const devRemotes$ = startDevRemotes(remotes, workspaceProjects, options, context);
|
|
166
207
|
return devRemotes$.length > 0
|
|
167
|
-
? (0, rxjs_1.combineLatest)([...devRemotes$]).pipe((0, rxjs_1.concatMap)(() => currExecutor))
|
|
168
|
-
: currExecutor;
|
|
208
|
+
? (0, rxjs_1.combineLatest)([...devRemotes$, staticRemotesIter$]).pipe((0, rxjs_1.concatMap)(() => currExecutor))
|
|
209
|
+
: (0, rxjs_1.from)(staticRemotesIter$).pipe((0, rxjs_1.concatMap)(() => currExecutor));
|
|
169
210
|
}));
|
|
170
211
|
}
|
|
171
212
|
exports.executeModuleFederationDevServerBuilder = executeModuleFederationDevServerBuilder;
|
|
@@ -142,6 +142,10 @@
|
|
|
142
142
|
"parallel": {
|
|
143
143
|
"type": "number",
|
|
144
144
|
"description": "Max number of parallel processes for building static remotes"
|
|
145
|
+
},
|
|
146
|
+
"staticRemotesPort": {
|
|
147
|
+
"type": "number",
|
|
148
|
+
"description": "The port at which to serve the file-server for the static remotes."
|
|
145
149
|
}
|
|
146
150
|
},
|
|
147
151
|
"additionalProperties": false,
|
|
@@ -51,7 +51,7 @@ function executeModuleFederationDevSSRBuilder(schema, context) {
|
|
|
51
51
|
const runOptions = {};
|
|
52
52
|
if (options.verbose) {
|
|
53
53
|
const [collection, executor] = workspaceProjects[remote].targets[target].executor.split(':');
|
|
54
|
-
const { schema } = (0, executor_utils_1.getExecutorInformation)(collection, executor, devkit_1.workspaceRoot);
|
|
54
|
+
const { schema } = (0, executor_utils_1.getExecutorInformation)(collection, executor, devkit_1.workspaceRoot, workspaceProjects);
|
|
55
55
|
if (schema.additionalProperties || 'verbose' in schema.properties) {
|
|
56
56
|
runOptions.verbose = options.verbose;
|
|
57
57
|
}
|
|
@@ -79,6 +79,7 @@ function executeModuleFederationDevSSRBuilder(schema, context) {
|
|
|
79
79
|
target,
|
|
80
80
|
configuration: context.target.configuration,
|
|
81
81
|
runOptions,
|
|
82
|
+
projects: workspaceProjects,
|
|
82
83
|
}, options.verbose).then((obs) => obs
|
|
83
84
|
.pipe((0, operators_1.tap)((result) => {
|
|
84
85
|
result.success && res();
|
|
@@ -78,7 +78,11 @@ const nxWritePackageTransform = (options) => (0, transform_1.transformFromPromis
|
|
|
78
78
|
}
|
|
79
79
|
// Write a package.json in each secondary entry-point
|
|
80
80
|
// This is need for esbuild to secondary entry-points in dist correctly.
|
|
81
|
-
await (0, fs_1.writeFile)(path.join(ngEntryPoint.destinationPath, 'package.json'), JSON.stringify({
|
|
81
|
+
await (0, fs_1.writeFile)(path.join(ngEntryPoint.destinationPath, 'package.json'), JSON.stringify({
|
|
82
|
+
module: relativeUnixFromDestPath(angularVersion.major < 16
|
|
83
|
+
? destinationFiles.esm2020
|
|
84
|
+
: destinationFiles.esm2022),
|
|
85
|
+
}, undefined, 2));
|
|
82
86
|
}
|
|
83
87
|
devkit_1.logger.info(`Built ${ngEntryPoint.moduleId}`);
|
|
84
88
|
return graph;
|
|
@@ -3,9 +3,11 @@ import { Component<% if(viewEncapsulation) { %>, ViewEncapsulation<% } %> } from
|
|
|
3
3
|
@Component({
|
|
4
4
|
selector: '<%= rootSelector %>',<% if(!inlineTemplate) { %>
|
|
5
5
|
templateUrl: './app.component.html',<% } else { %>
|
|
6
|
-
template: `<% if(minimal) { %><h1>Welcome <%= appName %></h1><% } else { %><<%= nxWelcomeSelector %>></<%= nxWelcomeSelector %>><% } %> <% if(routing) { %><router-outlet></router-outlet><% } %>`,<% } %><% if(!inlineStyle) { %>
|
|
6
|
+
template: `<% if(minimal) { %><h1>Welcome <%= appName %></h1><% } else { %><<%= nxWelcomeSelector %>></<%= nxWelcomeSelector %>><% } %> <% if(routing) { %><router-outlet></router-outlet><% } %>`,<% } %><% if (angularMajorVersion < 17) { if(!inlineStyle) { %>
|
|
7
7
|
styleUrls: ['./app.component.<%= style %>'],<% } else { %>
|
|
8
|
-
styles: [
|
|
8
|
+
styles: [``],<% } %><% } else { if(!inlineStyle) { %>
|
|
9
|
+
styleUrl: './app.component.<%= style %>',<% } else { %>
|
|
10
|
+
styles: ``,<% } %><% } %><% if(viewEncapsulation) { %>
|
|
9
11
|
encapsulation: ViewEncapsulation.<%= viewEncapsulation %>,<% } %>
|
|
10
12
|
})
|
|
11
13
|
export class AppComponent {<% if(!minimal) { %>
|
package/src/generators/application/files/standalone-components/src/app/app.component.ts__tpl__
CHANGED
|
@@ -7,9 +7,11 @@ import { NxWelcomeComponent } from './nx-welcome.component';<% } %>
|
|
|
7
7
|
imports: [<% if(!minimal) { %>NxWelcomeComponent, <% } %><% if(routing) { %>RouterModule<% } %>],
|
|
8
8
|
selector: '<%= rootSelector %>',<% if(!inlineTemplate) { %>
|
|
9
9
|
templateUrl: './app.component.html',<% } else { %>
|
|
10
|
-
template: `<% if(minimal) { %><h1>Welcome <%= appName %></h1><% } else { %><<%= nxWelcomeSelector %>></<%= nxWelcomeSelector %>><% } %> <% if(routing) { %><router-outlet></router-outlet><% } %>`,<% } %><% if(!inlineStyle) { %>
|
|
10
|
+
template: `<% if(minimal) { %><h1>Welcome <%= appName %></h1><% } else { %><<%= nxWelcomeSelector %>></<%= nxWelcomeSelector %>><% } %> <% if(routing) { %><router-outlet></router-outlet><% } %>`,<% } %><% if (angularMajorVersion < 17) { if(!inlineStyle) { %>
|
|
11
11
|
styleUrls: ['./app.component.<%= style %>'],<% } else { %>
|
|
12
|
-
styles: [
|
|
12
|
+
styles: [``],<% } %><% } else { if(!inlineStyle) { %>
|
|
13
|
+
styleUrl: './app.component.<%= style %>',<% } else { %>
|
|
14
|
+
styles: ``,<% } %><% } %><% if(viewEncapsulation) { %>
|
|
13
15
|
encapsulation: ViewEncapsulation.<%= viewEncapsulation %>,<% } %>
|
|
14
16
|
})
|
|
15
17
|
export class AppComponent {<% if(!minimal) { %>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationConfig } from <% if (
|
|
1
|
+
import { ApplicationConfig } from <% if (angularMajorVersion >= 16) { %>'@angular/core';<% } else { %>'@angular/platform-browser';<% } %><% if (routing) { %>
|
|
2
2
|
import { provideRouter } from '@angular/router';
|
|
3
3
|
import { appRoutes } from './app.routes';<% } %>
|
|
4
4
|
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { bootstrapApplication } from '@angular/platform-browser';
|
|
2
2
|
import { appConfig } from './app/app.config';
|
|
3
|
-
import { AppComponent } from './app/app.component'
|
|
4
|
-
import { enableProdMode } from '@angular/core';
|
|
5
|
-
import { environment } from './environments/environment';
|
|
6
|
-
|
|
7
|
-
if(environment.production) {
|
|
8
|
-
enableProdMode();
|
|
9
|
-
}<% } %>
|
|
3
|
+
import { AppComponent } from './app/app.component';
|
|
10
4
|
|
|
11
5
|
bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err));
|
|
@@ -7,8 +7,8 @@ const create_ts_config_1 = require("../../utils/create-ts-config");
|
|
|
7
7
|
const test_runners_1 = require("../../../utils/test-runners");
|
|
8
8
|
const version_utils_1 = require("../../utils/version-utils");
|
|
9
9
|
async function createFiles(tree, options, rootOffset) {
|
|
10
|
-
const
|
|
11
|
-
const isUsingApplicationBuilder =
|
|
10
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
11
|
+
const isUsingApplicationBuilder = angularMajorVersion >= 17 && options.bundler === 'esbuild';
|
|
12
12
|
const substitutions = {
|
|
13
13
|
rootSelector: `${options.prefix}-root`,
|
|
14
14
|
appName: options.name,
|
|
@@ -21,7 +21,7 @@ async function createFiles(tree, options, rootOffset) {
|
|
|
21
21
|
minimal: options.minimal,
|
|
22
22
|
nxWelcomeSelector: `${options.prefix}-nx-welcome`,
|
|
23
23
|
rootTsConfig: (0, devkit_1.joinPathFragments)(rootOffset, (0, js_1.getRootTsConfigFileName)(tree)),
|
|
24
|
-
|
|
24
|
+
angularMajorVersion,
|
|
25
25
|
rootOffset,
|
|
26
26
|
isUsingApplicationBuilder,
|
|
27
27
|
tpl: '',
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.componentGeneratorInternal = exports.componentGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
+
const version_utils_1 = require("../utils/version-utils");
|
|
6
7
|
const lib_1 = require("./lib");
|
|
7
8
|
async function componentGenerator(tree, rawOptions) {
|
|
8
9
|
await componentGeneratorInternal(tree, {
|
|
@@ -13,6 +14,7 @@ async function componentGenerator(tree, rawOptions) {
|
|
|
13
14
|
exports.componentGenerator = componentGenerator;
|
|
14
15
|
async function componentGeneratorInternal(tree, rawOptions) {
|
|
15
16
|
const options = await (0, lib_1.normalizeOptions)(tree, rawOptions);
|
|
17
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
16
18
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), options.directory, {
|
|
17
19
|
name: options.name,
|
|
18
20
|
fileName: options.fileName,
|
|
@@ -26,6 +28,7 @@ async function componentGeneratorInternal(tree, rawOptions) {
|
|
|
26
28
|
viewEncapsulation: options.viewEncapsulation,
|
|
27
29
|
displayBlock: options.displayBlock,
|
|
28
30
|
selector: options.selector,
|
|
31
|
+
angularMajorVersion,
|
|
29
32
|
tpl: '',
|
|
30
33
|
});
|
|
31
34
|
if (options.skipTests) {
|
|
@@ -6,7 +6,7 @@ import { CommonModule } from '@angular/common';<% } %>
|
|
|
6
6
|
standalone: true,
|
|
7
7
|
imports: [CommonModule],<%}%><% if(inlineTemplate) { %>
|
|
8
8
|
template: `<p><%= name %> works!</p>`<% } else { %>
|
|
9
|
-
templateUrl: './<%= fileName %>.html'<% } if(inlineStyle) { %>,
|
|
9
|
+
templateUrl: './<%= fileName %>.html'<% } if (angularMajorVersion < 17) { if(inlineStyle) { %>,
|
|
10
10
|
styles: [<% if(displayBlock){ %>
|
|
11
11
|
`
|
|
12
12
|
:host {
|
|
@@ -14,7 +14,13 @@ import { CommonModule } from '@angular/common';<% } %>
|
|
|
14
14
|
}
|
|
15
15
|
`<% } %>
|
|
16
16
|
]<% } else if (style !== 'none') { %>,
|
|
17
|
-
styleUrls: ['./<%= fileName %>.<%= style %>']<% } %><% if(
|
|
17
|
+
styleUrls: ['./<%= fileName %>.<%= style %>']<% } %><% } else { if(inlineStyle) { %>,
|
|
18
|
+
styles: `<% if(displayBlock){ %>
|
|
19
|
+
:host {
|
|
20
|
+
display: block;
|
|
21
|
+
}
|
|
22
|
+
<% } %>`<% } else if (style !== 'none') { %>,
|
|
23
|
+
styleUrl: './<%= fileName %>.<%= style %>'<% } %><% } %><% if(!!viewEncapsulation) { %>,
|
|
18
24
|
encapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } if (changeDetection !== 'Default') { %>,
|
|
19
25
|
changeDetection: ChangeDetectionStrategy.<%= changeDetection %><% } %>
|
|
20
26
|
})
|
|
@@ -62,6 +62,7 @@ async function hostInternal(tree, schema) {
|
|
|
62
62
|
prefix: options.prefix,
|
|
63
63
|
typescriptConfiguration,
|
|
64
64
|
standalone: options.standalone,
|
|
65
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
65
66
|
});
|
|
66
67
|
let installTasks = [appInstallTask];
|
|
67
68
|
if (options.ssr) {
|
|
@@ -36,7 +36,7 @@ export function app(): express.Express {
|
|
|
36
36
|
// server.get('/api/**', (req, res) => { });
|
|
37
37
|
// Serve static files from /browser
|
|
38
38
|
// serve static files
|
|
39
|
-
server.
|
|
39
|
+
server.get('*.*', express.static(browserBundles, { maxAge: '1y' }));
|
|
40
40
|
server.use('/server', express.static(serverBundles, { maxAge: '1y' }));
|
|
41
41
|
|
|
42
42
|
// All regular routes use the Universal engine
|
|
@@ -28,7 +28,7 @@ export function app(): express.Express {
|
|
|
28
28
|
// Example Express Rest API endpoints
|
|
29
29
|
// server.get('/api/**', (req, res) => { });
|
|
30
30
|
// Serve static files from /browser
|
|
31
|
-
server.
|
|
31
|
+
server.get('*.*', express.static(browserBundles, { maxAge: '1y' }));
|
|
32
32
|
// Serve static files from /server
|
|
33
33
|
server.use('/server', express.static(serverBundles, { maxAge: '1y' }));
|
|
34
34
|
|
|
@@ -53,6 +53,7 @@ async function remoteInternal(tree, schema) {
|
|
|
53
53
|
standalone: options.standalone,
|
|
54
54
|
prefix: options.prefix,
|
|
55
55
|
typescriptConfiguration,
|
|
56
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
56
57
|
});
|
|
57
58
|
const installSwcHelpersTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
58
59
|
'@swc/helpers': versions_1.swcHelpersVersion,
|
|
@@ -2,6 +2,18 @@ import { ModuleFederationConfig } from '@nx/webpack';
|
|
|
2
2
|
|
|
3
3
|
const config: ModuleFederationConfig = {
|
|
4
4
|
name: '<%= name %>',<% if(type === 'host') { %>
|
|
5
|
+
/**
|
|
6
|
+
* To use a remote that does not exist in your current Nx Workspace
|
|
7
|
+
* You can use the tuple-syntax to define your remote
|
|
8
|
+
*
|
|
9
|
+
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
|
|
10
|
+
*
|
|
11
|
+
* You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
|
|
12
|
+
* following content:
|
|
13
|
+
*
|
|
14
|
+
* declare module 'my-external-remote';
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
5
17
|
remotes: [<% remotes.forEach(function(remote) { %>'<%= remote.remoteName %>',<% }); %>]<% } %><% if(type === 'remote') { %>
|
|
6
18
|
exposes: {<% if(standalone) { %>
|
|
7
19
|
'./Routes': '<%= projectRoot %>/src/app/remote-entry/entry.routes.ts',<% } else { %>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ES2020"
|
|
5
|
+
},
|
|
6
|
+
"include": [
|
|
7
|
+
"src/main.ts",
|
|
8
|
+
<% if(type === "remote") { %> "src/remote-entry/<% if(standalone) { %>entry.routes.ts", <% } else { %> entry.module.ts", <% } } %>
|
|
9
|
+
"webpack.config.ts",
|
|
10
|
+
"webpack.prod.config.ts"
|
|
11
|
+
]
|
|
12
|
+
}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
name: '<%= name %>',<% if(type === 'host') { %>
|
|
3
|
+
/**
|
|
4
|
+
* To use a remote that does not exist in your current Nx Workspace
|
|
5
|
+
* You can use the tuple-syntax to define your remote
|
|
6
|
+
*
|
|
7
|
+
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
|
|
8
|
+
*
|
|
9
|
+
* You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
|
|
10
|
+
* following content:
|
|
11
|
+
*
|
|
12
|
+
* declare module 'my-external-remote';
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
3
15
|
remotes: [<% remotes.forEach(function(remote) { %>'<%= remote.remoteName %>',<% }); %>]<% } %><% if(type === 'remote') { %>
|
|
4
16
|
exposes: {<% if(standalone) { %>
|
|
5
17
|
'./Routes': '<%= projectRoot %>/src/app/remote-entry/entry.routes.ts',<% } else { %>
|
|
6
18
|
'./Module': '<%= projectRoot %>/src/app/remote-entry/entry.module.ts',<% } %>
|
|
7
19
|
},<% } %>
|
|
8
|
-
}
|
|
20
|
+
}
|
|
@@ -23,5 +23,8 @@ function generateWebpackConfig(tree, options, appRoot, remotesWithPorts) {
|
|
|
23
23
|
projectRoot: appRoot,
|
|
24
24
|
standalone: options.standalone,
|
|
25
25
|
});
|
|
26
|
+
if (!options.setParserOptionsProject) {
|
|
27
|
+
tree.delete((0, devkit_1.joinPathFragments)(appRoot, 'tsconfig.lint.json'));
|
|
28
|
+
}
|
|
26
29
|
}
|
|
27
30
|
exports.generateWebpackConfig = generateWebpackConfig;
|
|
@@ -78,6 +78,11 @@
|
|
|
78
78
|
"type": "boolean",
|
|
79
79
|
"description": "Whether the module federation configuration and webpack configuration files should use TS.",
|
|
80
80
|
"default": true
|
|
81
|
+
},
|
|
82
|
+
"setParserOptionsProject": {
|
|
83
|
+
"type": "boolean",
|
|
84
|
+
"description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
|
|
85
|
+
"default": false
|
|
81
86
|
}
|
|
82
87
|
},
|
|
83
88
|
"required": ["appName", "mfType"],
|
|
@@ -5,10 +5,10 @@ const project_name_1 = require("@nx/cypress/src/utils/project-name");
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const stories_1 = require("../../stories/stories");
|
|
7
7
|
async function generateStories(tree, options) {
|
|
8
|
-
const project = (0, devkit_1.readProjectConfiguration)(tree, options.
|
|
9
|
-
const e2eProjectName = (0, project_name_1.getE2eProjectName)(options.
|
|
8
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
9
|
+
const e2eProjectName = (0, project_name_1.getE2eProjectName)(options.project, project.root, options.cypressDirectory);
|
|
10
10
|
await (0, stories_1.angularStoriesGenerator)(tree, {
|
|
11
|
-
name: options.
|
|
11
|
+
name: options.project,
|
|
12
12
|
generateCypressSpecs: options.configureCypress && options.generateCypressSpecs,
|
|
13
13
|
cypressProject: e2eProjectName,
|
|
14
14
|
ignorePaths: options.ignorePaths,
|
|
@@ -6,7 +6,7 @@ const versions_1 = require("../../../utils/versions");
|
|
|
6
6
|
async function generateStorybookConfiguration(tree, options) {
|
|
7
7
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/storybook', versions_1.nxVersion);
|
|
8
8
|
return await configurationGenerator(tree, {
|
|
9
|
-
|
|
9
|
+
project: options.project,
|
|
10
10
|
uiFramework: '@storybook/angular',
|
|
11
11
|
configureCypress: options.configureCypress,
|
|
12
12
|
linter: options.linter,
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
"cli": "nx",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
-
"
|
|
9
|
+
"project": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"aliases": ["
|
|
11
|
+
"aliases": ["name", "projectName"],
|
|
12
12
|
"description": "Project for which to generate Storybook configuration.",
|
|
13
13
|
"$default": {
|
|
14
14
|
"$source": "argv",
|
|
@@ -93,6 +93,6 @@
|
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
95
|
"additionalProperties": false,
|
|
96
|
-
"required": ["
|
|
96
|
+
"required": ["project"],
|
|
97
97
|
"examplesFile": "../../../docs/storybook-configuration-examples.md"
|
|
98
98
|
}
|
|
@@ -15,13 +15,18 @@ const UNIVERSAL_PACKAGES = [
|
|
|
15
15
|
* @nguniversal/express-engine
|
|
16
16
|
**/
|
|
17
17
|
const NGUNIVERSAL_PACKAGE_REGEXP = /@nguniversal\/(common(\/engine)?|express-engine)/g;
|
|
18
|
+
const serverExecutors = [
|
|
19
|
+
'@angular-devkit/build-angular:server',
|
|
20
|
+
'@nx/angular:webpack-server',
|
|
21
|
+
];
|
|
18
22
|
async function default_1(tree) {
|
|
19
23
|
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
20
24
|
if (!UNIVERSAL_PACKAGES.some((pkg) => packageJson.dependencies?.[pkg] || packageJson.devDependencies?.[pkg])) {
|
|
21
25
|
return;
|
|
22
26
|
}
|
|
23
27
|
const projects = await (0, projects_1.getProjectsFilteredByDependencies)(tree, [
|
|
24
|
-
'npm:@
|
|
28
|
+
'npm:@nguniversal/common',
|
|
29
|
+
'npm:@nguniversal/express-engine',
|
|
25
30
|
]);
|
|
26
31
|
for (const { project } of projects) {
|
|
27
32
|
if (project.projectType !== 'application') {
|
|
@@ -29,7 +34,7 @@ async function default_1(tree) {
|
|
|
29
34
|
}
|
|
30
35
|
const serverMainFiles = new Map();
|
|
31
36
|
for (const target of Object.values(project.targets ?? {})) {
|
|
32
|
-
if (target.executor
|
|
37
|
+
if (!serverExecutors.includes(target.executor)) {
|
|
33
38
|
continue;
|
|
34
39
|
}
|
|
35
40
|
const outputPath = project.targets.build?.options?.outputPath;
|
|
@@ -46,19 +51,24 @@ async function default_1(tree) {
|
|
|
46
51
|
const root = project.sourceRoot ?? `${project.root}/src`;
|
|
47
52
|
const tokensFilePath = `${root}/express.tokens.ts`;
|
|
48
53
|
(0, devkit_1.visitNotIgnoredFiles)(tree, root, (path) => {
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
if (!path.endsWith('.ts') || path.endsWith('.d.ts')) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
let content = tree.read(path, 'utf8');
|
|
58
|
+
if (!content.includes('@nguniversal/')) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
51
61
|
// Check if file is importing tokens
|
|
52
62
|
if (content.includes('@nguniversal/express-engine/tokens')) {
|
|
53
63
|
hasExpressTokens ||= true;
|
|
54
|
-
let tokensFileRelativePath = (0,
|
|
64
|
+
let tokensFileRelativePath = (0, devkit_1.normalizePath)((0, path_1.relative)((0, path_1.dirname)(path), tokensFilePath));
|
|
55
65
|
if (tokensFileRelativePath.charAt(0) !== '.') {
|
|
56
66
|
tokensFileRelativePath = './' + tokensFileRelativePath;
|
|
57
67
|
}
|
|
58
|
-
|
|
68
|
+
content = content.replaceAll('@nguniversal/express-engine/tokens', tokensFileRelativePath.slice(0, -3));
|
|
59
69
|
}
|
|
60
|
-
|
|
61
|
-
tree.write(path,
|
|
70
|
+
content = content.replaceAll(NGUNIVERSAL_PACKAGE_REGEXP, '@angular/ssr');
|
|
71
|
+
tree.write(path, content);
|
|
62
72
|
});
|
|
63
73
|
// Replace server file and add tokens file if needed
|
|
64
74
|
for (const [path, outputPath] of serverMainFiles.entries()) {
|
package/src/utils/mf/utils.js
CHANGED
|
@@ -30,6 +30,13 @@ function getFunctionDeterminateRemoteUrl(isServer = false) {
|
|
|
30
30
|
const target = 'serve';
|
|
31
31
|
const remoteEntry = isServer ? 'server/remoteEntry.js' : 'remoteEntry.mjs';
|
|
32
32
|
return function (remote) {
|
|
33
|
+
const mappedStaticRemotesFromEnv = process.env
|
|
34
|
+
.NX_MF_DEV_SERVER_STATIC_REMOTES
|
|
35
|
+
? JSON.parse(process.env.NX_MF_DEV_SERVER_STATIC_REMOTES)
|
|
36
|
+
: undefined;
|
|
37
|
+
if (mappedStaticRemotesFromEnv && mappedStaticRemotesFromEnv[remote]) {
|
|
38
|
+
return `${mappedStaticRemotesFromEnv[remote]}/${remoteEntry}`;
|
|
39
|
+
}
|
|
33
40
|
let remoteConfiguration = null;
|
|
34
41
|
try {
|
|
35
42
|
remoteConfiguration = (0, project_graph_1.readCachedProjectConfiguration)(remote);
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare const postcssPresetEnvVersion = "~7.5.0";
|
|
|
20
20
|
export declare const postcssUrlVersion = "~10.1.3";
|
|
21
21
|
export declare const autoprefixerVersion = "^10.4.0";
|
|
22
22
|
export declare const tsNodeVersion = "10.9.1";
|
|
23
|
-
export declare const jestPresetAngularVersion = "~13.1.
|
|
23
|
+
export declare const jestPresetAngularVersion = "~13.1.4";
|
|
24
24
|
export declare const typesNodeVersion = "16.11.7";
|
|
25
25
|
export declare const jasmineMarblesVersion = "^0.9.2";
|
|
26
26
|
export declare const jsoncEslintParserVersion = "^2.1.0";
|
package/src/utils/versions.js
CHANGED
|
@@ -23,7 +23,7 @@ exports.postcssPresetEnvVersion = '~7.5.0';
|
|
|
23
23
|
exports.postcssUrlVersion = '~10.1.3';
|
|
24
24
|
exports.autoprefixerVersion = '^10.4.0';
|
|
25
25
|
exports.tsNodeVersion = '10.9.1';
|
|
26
|
-
exports.jestPresetAngularVersion = '~13.1.
|
|
26
|
+
exports.jestPresetAngularVersion = '~13.1.4';
|
|
27
27
|
exports.typesNodeVersion = '16.11.7';
|
|
28
28
|
exports.jasmineMarblesVersion = '^0.9.2';
|
|
29
29
|
exports.jsoncEslintParserVersion = '^2.1.0';
|