@schematics/angular 19.0.0-next.0 → 19.0.0-next.10
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/LICENSE +5 -5
- package/app-shell/index.js +48 -73
- package/application/index.js +2 -2
- package/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template +1 -1
- package/component/index.js +1 -0
- package/component/schema.d.ts +4 -0
- package/component/schema.json +5 -0
- package/config/files/karma.conf.js.template +0 -1
- package/directive/index.js +1 -0
- package/migrations/migration-collection.json +11 -1
- package/migrations/update-ssr-imports/migration.d.ts +15 -0
- package/migrations/update-ssr-imports/migration.js +93 -0
- package/migrations/update-workspace-config/migration.d.ts +33 -0
- package/migrations/update-workspace-config/migration.js +77 -0
- package/package.json +4 -4
- package/server/files/application-builder/ngmodule-src/app/app.module.server.ts.template +13 -0
- package/server/files/application-builder/ngmodule-src/app/app.routes.server.ts.template +8 -0
- package/server/files/application-builder/standalone-src/app/app.config.server.ts.template +14 -0
- package/server/files/application-builder/standalone-src/app/app.routes.server.ts.template +8 -0
- package/server/files/server-builder/ngmodule-src/main.server.ts.template +1 -0
- package/server/files/server-builder/standalone-src/main.server.ts.template +7 -0
- package/server/index.js +17 -8
- package/service-worker/files/ngsw-config.json.template +1 -0
- package/ssr/files/application-builder/server.ts.template +36 -44
- package/ssr/files/server-builder/server.ts.template +2 -2
- package/ssr/index.js +17 -21
- package/third_party/github.com/Microsoft/TypeScript/lib/typescript.d.ts +244 -156
- package/third_party/github.com/Microsoft/TypeScript/lib/typescript.js +4617 -3454
- package/utility/latest-versions/package.json +3 -3
- package/utility/latest-versions.js +2 -2
- package/utility/workspace-models.d.ts +1 -5
- package/workspace/files/__dot__editorconfig.template +1 -0
- package/workspace/files/tsconfig.json.template +1 -7
- /package/server/files/{src → application-builder/ngmodule-src}/main.server.ts.template +0 -0
- /package/server/files/{standalone-src → application-builder/standalone-src}/main.server.ts.template +0 -0
- /package/server/files/{src → server-builder/ngmodule-src}/app/app.module.server.ts.template +0 -0
- /package/server/files/{root → server-builder/root}/tsconfig.server.json.template +0 -0
- /package/server/files/{standalone-src → server-builder/standalone-src}/app/app.config.server.ts.template +0 -0
package/server/index.js
CHANGED
|
@@ -83,11 +83,12 @@ function updateConfigFileApplicationBuilder(options) {
|
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
const buildTarget = project.targets.get('build');
|
|
86
|
-
if (buildTarget
|
|
87
|
-
|
|
86
|
+
if (!buildTarget) {
|
|
87
|
+
return;
|
|
88
88
|
}
|
|
89
89
|
buildTarget.options ??= {};
|
|
90
90
|
buildTarget.options['server'] = node_path_1.posix.join(project.sourceRoot ?? node_path_1.posix.join(project.root, 'src'), serverMainEntryName);
|
|
91
|
+
buildTarget.options['outputMode'] = 'static';
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
94
|
function updateTsConfigFile(tsConfigPath) {
|
|
@@ -111,6 +112,10 @@ function addDependencies(skipInstall) {
|
|
|
111
112
|
}
|
|
112
113
|
const install = skipInstall ? utility_1.InstallBehavior.None : utility_1.InstallBehavior.Auto;
|
|
113
114
|
return (0, schematics_1.chain)([
|
|
115
|
+
(0, utility_1.addDependency)('@angular/ssr', latest_versions_1.latestVersions.AngularSSR, {
|
|
116
|
+
type: utility_1.DependencyType.Default,
|
|
117
|
+
install,
|
|
118
|
+
}),
|
|
114
119
|
(0, utility_1.addDependency)('@angular/platform-server', coreDep.version, {
|
|
115
120
|
type: utility_1.DependencyType.Default,
|
|
116
121
|
install,
|
|
@@ -123,7 +128,7 @@ function addDependencies(skipInstall) {
|
|
|
123
128
|
};
|
|
124
129
|
}
|
|
125
130
|
function default_1(options) {
|
|
126
|
-
return async (host
|
|
131
|
+
return async (host) => {
|
|
127
132
|
const workspace = await (0, workspace_1.getWorkspace)(host);
|
|
128
133
|
const clientProject = workspace.projects.get(options.project);
|
|
129
134
|
if (clientProject?.extensions.projectType !== 'application') {
|
|
@@ -133,7 +138,8 @@ function default_1(options) {
|
|
|
133
138
|
if (!clientBuildTarget) {
|
|
134
139
|
throw (0, project_targets_1.targetBuildNotFoundError)();
|
|
135
140
|
}
|
|
136
|
-
const isUsingApplicationBuilder = clientBuildTarget.builder === workspace_models_1.Builders.Application
|
|
141
|
+
const isUsingApplicationBuilder = clientBuildTarget.builder === workspace_models_1.Builders.Application ||
|
|
142
|
+
clientBuildTarget.builder === workspace_models_1.Builders.BuildApplication;
|
|
137
143
|
if (clientProject.targets.has('server') ||
|
|
138
144
|
(isUsingApplicationBuilder && clientBuildTarget.options?.server !== undefined)) {
|
|
139
145
|
// Server has already been added.
|
|
@@ -142,12 +148,15 @@ function default_1(options) {
|
|
|
142
148
|
const clientBuildOptions = clientBuildTarget.options;
|
|
143
149
|
const browserEntryPoint = await (0, util_1.getMainFilePath)(host, options.project);
|
|
144
150
|
const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(host, browserEntryPoint);
|
|
145
|
-
const
|
|
151
|
+
const sourceRoot = clientProject.sourceRoot ?? (0, core_1.join)((0, core_1.normalize)(clientProject.root), 'src');
|
|
152
|
+
let filesUrl = `./files/${isUsingApplicationBuilder ? 'application-builder/' : 'server-builder/'}`;
|
|
153
|
+
filesUrl += isStandalone ? 'standalone-src' : 'ngmodule-src';
|
|
154
|
+
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)(filesUrl), [
|
|
146
155
|
(0, schematics_1.applyTemplates)({
|
|
147
156
|
...schematics_1.strings,
|
|
148
157
|
...options,
|
|
149
158
|
}),
|
|
150
|
-
(0, schematics_1.move)(
|
|
159
|
+
(0, schematics_1.move)(sourceRoot),
|
|
151
160
|
]);
|
|
152
161
|
const clientTsConfig = (0, core_1.normalize)(clientBuildOptions.tsConfig);
|
|
153
162
|
const tsConfigExtends = (0, core_1.basename)(clientTsConfig);
|
|
@@ -160,7 +169,7 @@ function default_1(options) {
|
|
|
160
169
|
updateTsConfigFile(clientBuildOptions.tsConfig),
|
|
161
170
|
]
|
|
162
171
|
: [
|
|
163
|
-
(0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files/root'), [
|
|
172
|
+
(0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files/server-builder/root'), [
|
|
164
173
|
(0, schematics_1.applyTemplates)({
|
|
165
174
|
...schematics_1.strings,
|
|
166
175
|
...options,
|
|
@@ -174,7 +183,7 @@ function default_1(options) {
|
|
|
174
183
|
updateConfigFileBrowserBuilder(options, tsConfigDirectory),
|
|
175
184
|
]),
|
|
176
185
|
addDependencies(options.skipInstall),
|
|
177
|
-
(0, utility_1.addRootProvider)(options.project, ({ code, external }) => code `${external('provideClientHydration', '@angular/platform-browser')}()`),
|
|
186
|
+
(0, utility_1.addRootProvider)(options.project, ({ code, external }) => code `${external('provideClientHydration', '@angular/platform-browser')}(${external('withEventReplay', '@angular/platform-browser')}())`),
|
|
178
187
|
]);
|
|
179
188
|
};
|
|
180
189
|
}
|
|
@@ -1,57 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
AngularNodeAppEngine,
|
|
3
|
+
createNodeRequestHandler,
|
|
4
|
+
isMainModule,
|
|
5
|
+
writeResponseToNodeResponse,
|
|
6
|
+
} from '@angular/ssr/node';
|
|
3
7
|
import express from 'express';
|
|
8
|
+
import { dirname, resolve } from 'node:path';
|
|
4
9
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { dirname, join, resolve } from 'node:path';
|
|
6
|
-
import <% if (isStandalone) { %>bootstrap<% } else { %>AppServerModule<% } %> from './src/main.server';
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const server = express();
|
|
11
|
-
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
|
|
12
|
-
const browserDistFolder = resolve(serverDistFolder, '../<%= browserDistDirectory %>');
|
|
13
|
-
const indexHtml = join(serverDistFolder, 'index.server.html');
|
|
11
|
+
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const browserDistFolder = resolve(serverDistFolder, '../<%= browserDistDirectory %>');
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
const app = express();
|
|
15
|
+
const angularApp = new AngularNodeAppEngine();
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// Example Express Rest API endpoints
|
|
18
|
+
// app.get('/api/**', (req, res) => { });
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
// Serve static files from /<%= browserDistDirectory %>
|
|
21
|
+
app.get(
|
|
22
|
+
'**',
|
|
23
|
+
express.static(browserDistFolder, {
|
|
24
24
|
maxAge: '1y',
|
|
25
25
|
index: 'index.html',
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return server;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function run(): void {
|
|
26
|
+
setHeaders: (res) => {
|
|
27
|
+
const headers = angularApp.getPrerenderHeaders(res.req);
|
|
28
|
+
for (const [key, value] of headers) {
|
|
29
|
+
res.setHeader(key, value);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
app.get('**', (req, res, next) => {
|
|
36
|
+
angularApp
|
|
37
|
+
.render(req)
|
|
38
|
+
.then((response) => (response ? writeResponseToNodeResponse(response, res) : next()))
|
|
39
|
+
.catch(next);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (isMainModule(import.meta.url)) {
|
|
48
43
|
const port = process.env['PORT'] || 4000;
|
|
49
|
-
|
|
50
|
-
// Start up the Node server
|
|
51
|
-
const server = app();
|
|
52
|
-
server.listen(port, () => {
|
|
44
|
+
app.listen(port, () => {
|
|
53
45
|
console.log(`Node Express server listening on http://localhost:${port}`);
|
|
54
46
|
});
|
|
55
47
|
}
|
|
56
48
|
|
|
57
|
-
|
|
49
|
+
export default createNodeRequestHandler(app);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import 'zone.js/node';
|
|
2
2
|
|
|
3
3
|
import { APP_BASE_HREF } from '@angular/common';
|
|
4
|
-
import { CommonEngine } from '@angular/ssr';
|
|
4
|
+
import { CommonEngine } from '@angular/ssr/node';
|
|
5
5
|
import * as express from 'express';
|
|
6
6
|
import { existsSync } from 'node:fs';
|
|
7
7
|
import { join } from 'node:path';
|
|
8
|
-
import <% if (isStandalone) { %>bootstrap<% } else { %>AppServerModule<% } %> from './
|
|
8
|
+
import <% if (isStandalone) { %>bootstrap<% } else { %>AppServerModule<% } %> from './main.server';
|
|
9
9
|
|
|
10
10
|
// The Express app is exported so that it can be used by serverless Functions.
|
|
11
11
|
export function app(): express.Express {
|
package/ssr/index.js
CHANGED
|
@@ -108,15 +108,14 @@ function updateApplicationBuilderTsConfigRule(options) {
|
|
|
108
108
|
// No tsconfig path
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
111
|
+
const json = new json_file_1.JSONFile(host, tsConfigPath);
|
|
112
|
+
const filesPath = ['files'];
|
|
113
|
+
const files = new Set(json.get(filesPath) ?? []);
|
|
114
|
+
files.add('src/server.ts');
|
|
115
|
+
json.modify(filesPath, [...files]);
|
|
117
116
|
};
|
|
118
117
|
}
|
|
119
|
-
function updateApplicationBuilderWorkspaceConfigRule(
|
|
118
|
+
function updateApplicationBuilderWorkspaceConfigRule(projectSourceRoot, options, { logger }) {
|
|
120
119
|
return (0, utility_1.updateWorkspace)((workspace) => {
|
|
121
120
|
const buildTarget = workspace.projects.get(options.project)?.targets.get('build');
|
|
122
121
|
if (!buildTarget) {
|
|
@@ -140,14 +139,14 @@ function updateApplicationBuilderWorkspaceConfigRule(projectRoot, options, { log
|
|
|
140
139
|
buildTarget.options = {
|
|
141
140
|
...buildTarget.options,
|
|
142
141
|
outputPath,
|
|
143
|
-
|
|
142
|
+
outputMode: 'server',
|
|
144
143
|
ssr: {
|
|
145
|
-
entry: (0, core_1.join)((0, core_1.normalize)(
|
|
144
|
+
entry: (0, core_1.join)((0, core_1.normalize)(projectSourceRoot), 'server.ts'),
|
|
146
145
|
},
|
|
147
146
|
};
|
|
148
147
|
});
|
|
149
148
|
}
|
|
150
|
-
function updateWebpackBuilderWorkspaceConfigRule(options) {
|
|
149
|
+
function updateWebpackBuilderWorkspaceConfigRule(projectSourceRoot, options) {
|
|
151
150
|
return (0, utility_1.updateWorkspace)((workspace) => {
|
|
152
151
|
const projectName = options.project;
|
|
153
152
|
const project = workspace.projects.get(projectName);
|
|
@@ -156,7 +155,7 @@ function updateWebpackBuilderWorkspaceConfigRule(options) {
|
|
|
156
155
|
}
|
|
157
156
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
158
157
|
const serverTarget = project.targets.get('server');
|
|
159
|
-
(serverTarget.options ??= {}).main =
|
|
158
|
+
(serverTarget.options ??= {}).main = node_path_1.posix.join(projectSourceRoot, 'server.ts');
|
|
160
159
|
const serveSSRTarget = project.targets.get(SERVE_SSR_TARGET_NAME);
|
|
161
160
|
if (serveSSRTarget) {
|
|
162
161
|
return;
|
|
@@ -216,7 +215,7 @@ function updateWebpackBuilderServerTsConfigRule(options) {
|
|
|
216
215
|
}
|
|
217
216
|
const tsConfig = new json_file_1.JSONFile(host, tsConfigPath);
|
|
218
217
|
const filesAstNode = tsConfig.get(['files']);
|
|
219
|
-
const serverFilePath = 'server.ts';
|
|
218
|
+
const serverFilePath = 'src/server.ts';
|
|
220
219
|
if (Array.isArray(filesAstNode) && !filesAstNode.some(({ text }) => text === serverFilePath)) {
|
|
221
220
|
tsConfig.modify(['files'], [...filesAstNode, serverFilePath]);
|
|
222
221
|
}
|
|
@@ -225,10 +224,6 @@ function updateWebpackBuilderServerTsConfigRule(options) {
|
|
|
225
224
|
function addDependencies({ skipInstall }, isUsingApplicationBuilder) {
|
|
226
225
|
const install = skipInstall ? utility_1.InstallBehavior.None : utility_1.InstallBehavior.Auto;
|
|
227
226
|
const rules = [
|
|
228
|
-
(0, utility_1.addDependency)('@angular/ssr', latest_versions_1.latestVersions.AngularSSR, {
|
|
229
|
-
type: utility_1.DependencyType.Default,
|
|
230
|
-
install,
|
|
231
|
-
}),
|
|
232
227
|
(0, utility_1.addDependency)('express', latest_versions_1.latestVersions['express'], {
|
|
233
228
|
type: utility_1.DependencyType.Default,
|
|
234
229
|
install,
|
|
@@ -246,7 +241,7 @@ function addDependencies({ skipInstall }, isUsingApplicationBuilder) {
|
|
|
246
241
|
}
|
|
247
242
|
return (0, schematics_1.chain)(rules);
|
|
248
243
|
}
|
|
249
|
-
function addServerFile(options, isStandalone) {
|
|
244
|
+
function addServerFile(projectSourceRoot, options, isStandalone) {
|
|
250
245
|
return async (host) => {
|
|
251
246
|
const projectName = options.project;
|
|
252
247
|
const workspace = await (0, utility_1.readWorkspace)(host);
|
|
@@ -265,7 +260,7 @@ function addServerFile(options, isStandalone) {
|
|
|
265
260
|
browserDistDirectory,
|
|
266
261
|
isStandalone,
|
|
267
262
|
}),
|
|
268
|
-
(0, schematics_1.move)(
|
|
263
|
+
(0, schematics_1.move)(projectSourceRoot),
|
|
269
264
|
]));
|
|
270
265
|
};
|
|
271
266
|
}
|
|
@@ -279,6 +274,7 @@ function default_1(options) {
|
|
|
279
274
|
throw (0, project_targets_1.targetBuildNotFoundError)();
|
|
280
275
|
}
|
|
281
276
|
const isUsingApplicationBuilder = usingApplicationBuilder(clientProject);
|
|
277
|
+
const sourceRoot = clientProject.sourceRoot ?? node_path_1.posix.join(clientProject.root, 'src');
|
|
282
278
|
return (0, schematics_1.chain)([
|
|
283
279
|
(0, schematics_1.schematic)('server', {
|
|
284
280
|
...options,
|
|
@@ -286,14 +282,14 @@ function default_1(options) {
|
|
|
286
282
|
}),
|
|
287
283
|
...(isUsingApplicationBuilder
|
|
288
284
|
? [
|
|
289
|
-
updateApplicationBuilderWorkspaceConfigRule(
|
|
285
|
+
updateApplicationBuilderWorkspaceConfigRule(sourceRoot, options, context),
|
|
290
286
|
updateApplicationBuilderTsConfigRule(options),
|
|
291
287
|
]
|
|
292
288
|
: [
|
|
293
289
|
updateWebpackBuilderServerTsConfigRule(options),
|
|
294
|
-
updateWebpackBuilderWorkspaceConfigRule(options),
|
|
290
|
+
updateWebpackBuilderWorkspaceConfigRule(sourceRoot, options),
|
|
295
291
|
]),
|
|
296
|
-
addServerFile(options, isStandalone),
|
|
292
|
+
addServerFile(sourceRoot, options, isStandalone),
|
|
297
293
|
addScriptsRule(options, isUsingApplicationBuilder),
|
|
298
294
|
addDependencies(options, isUsingApplicationBuilder),
|
|
299
295
|
]);
|