@schematics/angular 19.0.0-next.1 → 19.0.0-next.11
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/files/module-files/src/app/app.component.spec.ts.template +3 -1
- package/application/files/module-files/src/app/app.component.ts.template +2 -1
- package/application/files/module-files/src/app/app.module.ts.template +2 -2
- package/application/files/module-files/src/main.ts.template +1 -2
- package/application/files/standalone-files/src/app/app.component.spec.ts.template +3 -1
- package/application/files/standalone-files/src/app/app.config.ts.template +4 -2
- package/application/index.js +2 -2
- package/application/schema.d.ts +4 -0
- package/application/schema.json +5 -0
- package/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template +4 -2
- package/component/index.js +1 -0
- package/component/schema.d.ts +4 -0
- package/component/schema.json +5 -0
- package/config/files/.browserslistrc.template +1 -0
- package/config/files/karma.conf.js.template +0 -1
- package/directive/files/__name@dasherize@if-flat__/__name@dasherize__.directive.ts.template +2 -1
- package/directive/index.js +1 -0
- package/library/files/README.md.template +49 -10
- package/migrations/migration-collection.json +5 -0
- package/migrations/update-ssr-imports/migration.d.ts +15 -0
- package/migrations/update-ssr-imports/migration.js +93 -0
- package/ng-new/index.js +1 -0
- package/ng-new/schema.d.ts +4 -0
- package/ng-new/schema.json +5 -0
- package/package.json +4 -4
- package/pipe/files/__name@dasherize@if-flat__/__name@dasherize__.pipe.ts.template +2 -1
- 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 +57 -42
- 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 +2 -2
- package/utility/latest-versions.js +2 -2
- package/workspace/files/README.md.template +41 -9
- package/workspace/files/__dot__editorconfig.template +1 -0
- package/workspace/files/tsconfig.json.template +1 -5
- /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/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2010-2024 Google LLC. https://angular.dev/license
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
|
10
10
|
furnished to do so, subject to the following conditions:
|
|
11
11
|
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
copies or substantial portions of the Software.
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
SOFTWARE.
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/app-shell/index.js
CHANGED
|
@@ -19,7 +19,6 @@ const change_1 = require("../utility/change");
|
|
|
19
19
|
const ng_ast_utils_1 = require("../utility/ng-ast-utils");
|
|
20
20
|
const util_1 = require("../utility/standalone/util");
|
|
21
21
|
const workspace_1 = require("../utility/workspace");
|
|
22
|
-
const workspace_models_1 = require("../utility/workspace-models");
|
|
23
22
|
const APP_SHELL_ROUTE = 'shell';
|
|
24
23
|
function getSourceFile(host, path) {
|
|
25
24
|
const content = host.readText(path);
|
|
@@ -106,59 +105,6 @@ function validateProject(mainPath) {
|
|
|
106
105
|
}
|
|
107
106
|
};
|
|
108
107
|
}
|
|
109
|
-
function addAppShellConfigToWorkspace(options) {
|
|
110
|
-
return (host, context) => {
|
|
111
|
-
return (0, workspace_1.updateWorkspace)((workspace) => {
|
|
112
|
-
const project = workspace.projects.get(options.project);
|
|
113
|
-
if (!project) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
const buildTarget = project.targets.get('build');
|
|
117
|
-
if (buildTarget?.builder === workspace_models_1.Builders.Application) {
|
|
118
|
-
// Application builder configuration.
|
|
119
|
-
const prodConfig = buildTarget.configurations?.production;
|
|
120
|
-
if (!prodConfig) {
|
|
121
|
-
throw new schematics_1.SchematicsException(`A "production" configuration is not defined for the "build" builder.`);
|
|
122
|
-
}
|
|
123
|
-
prodConfig.appShell = true;
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
// Webpack based builders configuration.
|
|
127
|
-
// Validation of targets is handled already in the main function.
|
|
128
|
-
// Duplicate keys means that we have configurations in both server and build builders.
|
|
129
|
-
const serverConfigKeys = project.targets.get('server')?.configurations ?? {};
|
|
130
|
-
const buildConfigKeys = project.targets.get('build')?.configurations ?? {};
|
|
131
|
-
const configurationNames = Object.keys({
|
|
132
|
-
...serverConfigKeys,
|
|
133
|
-
...buildConfigKeys,
|
|
134
|
-
});
|
|
135
|
-
const configurations = {};
|
|
136
|
-
for (const key of configurationNames) {
|
|
137
|
-
if (!serverConfigKeys[key]) {
|
|
138
|
-
context.logger.warn(`Skipped adding "${key}" configuration to "app-shell" target as it's missing from "server" target.`);
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
if (!buildConfigKeys[key]) {
|
|
142
|
-
context.logger.warn(`Skipped adding "${key}" configuration to "app-shell" target as it's missing from "build" target.`);
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
configurations[key] = {
|
|
146
|
-
browserTarget: `${options.project}:build:${key}`,
|
|
147
|
-
serverTarget: `${options.project}:server:${key}`,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
project.targets.add({
|
|
151
|
-
name: 'app-shell',
|
|
152
|
-
builder: workspace_models_1.Builders.AppShell,
|
|
153
|
-
defaultConfiguration: configurations['production'] ? 'production' : undefined,
|
|
154
|
-
options: {
|
|
155
|
-
route: APP_SHELL_ROUTE,
|
|
156
|
-
},
|
|
157
|
-
configurations,
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
108
|
function addRouterModule(mainPath) {
|
|
163
109
|
return (host) => {
|
|
164
110
|
const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, mainPath);
|
|
@@ -237,13 +183,12 @@ function addStandaloneServerRoute(options) {
|
|
|
237
183
|
if (!host.exists(configFilePath)) {
|
|
238
184
|
throw new schematics_1.SchematicsException(`Cannot find "${configFilePath}".`);
|
|
239
185
|
}
|
|
186
|
+
const recorder = host.beginUpdate(configFilePath);
|
|
240
187
|
let configSourceFile = getSourceFile(host, configFilePath);
|
|
241
188
|
if (!(0, ast_utils_1.isImported)(configSourceFile, 'ROUTES', '@angular/router')) {
|
|
242
189
|
const routesChange = (0, ast_utils_1.insertImport)(configSourceFile, configFilePath, 'ROUTES', '@angular/router');
|
|
243
|
-
const recorder = host.beginUpdate(configFilePath);
|
|
244
190
|
if (routesChange) {
|
|
245
191
|
(0, change_1.applyToUpdateRecorder)(recorder, [routesChange]);
|
|
246
|
-
host.commitUpdate(recorder);
|
|
247
192
|
}
|
|
248
193
|
}
|
|
249
194
|
configSourceFile = getSourceFile(host, configFilePath);
|
|
@@ -252,29 +197,59 @@ function addStandaloneServerRoute(options) {
|
|
|
252
197
|
throw new schematics_1.SchematicsException(`Cannot find the "providers" configuration in "${configFilePath}".`);
|
|
253
198
|
}
|
|
254
199
|
// Add route to providers literal.
|
|
255
|
-
const newProvidersLiteral = typescript_1.default.factory.updateArrayLiteralExpression(providersLiteral, [
|
|
256
|
-
...providersLiteral.elements,
|
|
257
|
-
typescript_1.default.factory.createObjectLiteralExpression([
|
|
258
|
-
typescript_1.default.factory.createPropertyAssignment('provide', typescript_1.default.factory.createIdentifier('ROUTES')),
|
|
259
|
-
typescript_1.default.factory.createPropertyAssignment('multi', typescript_1.default.factory.createIdentifier('true')),
|
|
260
|
-
typescript_1.default.factory.createPropertyAssignment('useValue', typescript_1.default.factory.createArrayLiteralExpression([
|
|
261
|
-
typescript_1.default.factory.createObjectLiteralExpression([
|
|
262
|
-
typescript_1.default.factory.createPropertyAssignment('path', typescript_1.default.factory.createIdentifier(`'${APP_SHELL_ROUTE}'`)),
|
|
263
|
-
typescript_1.default.factory.createPropertyAssignment('component', typescript_1.default.factory.createIdentifier('AppShellComponent')),
|
|
264
|
-
], true),
|
|
265
|
-
], true)),
|
|
266
|
-
], true),
|
|
267
|
-
]);
|
|
268
|
-
const recorder = host.beginUpdate(configFilePath);
|
|
269
200
|
recorder.remove(providersLiteral.getStart(), providersLiteral.getWidth());
|
|
270
|
-
const
|
|
271
|
-
|
|
201
|
+
const updatedProvidersString = [
|
|
202
|
+
...providersLiteral.elements.map((element) => ' ' + element.getText()),
|
|
203
|
+
` {
|
|
204
|
+
provide: ROUTES,
|
|
205
|
+
multi: true,
|
|
206
|
+
useValue: [{
|
|
207
|
+
path: '${APP_SHELL_ROUTE}',
|
|
208
|
+
component: AppShellComponent
|
|
209
|
+
}]
|
|
210
|
+
}\n `,
|
|
211
|
+
];
|
|
212
|
+
recorder.insertRight(providersLiteral.getStart(), `[\n${updatedProvidersString.join(',\n')}]`);
|
|
272
213
|
// Add AppShellComponent import
|
|
273
214
|
const appShellImportChange = (0, ast_utils_1.insertImport)(configSourceFile, configFilePath, 'AppShellComponent', './app-shell/app-shell.component');
|
|
274
215
|
(0, change_1.applyToUpdateRecorder)(recorder, [appShellImportChange]);
|
|
275
216
|
host.commitUpdate(recorder);
|
|
276
217
|
};
|
|
277
218
|
}
|
|
219
|
+
function addServerRoutingConfig(options) {
|
|
220
|
+
return async (host) => {
|
|
221
|
+
const workspace = await (0, workspace_1.getWorkspace)(host);
|
|
222
|
+
const project = workspace.projects.get(options.project);
|
|
223
|
+
if (!project) {
|
|
224
|
+
throw new schematics_1.SchematicsException(`Project name "${options.project}" doesn't not exist.`);
|
|
225
|
+
}
|
|
226
|
+
const configFilePath = (0, posix_1.join)(project.sourceRoot ?? 'src', 'app/app.routes.server.ts');
|
|
227
|
+
if (!host.exists(configFilePath)) {
|
|
228
|
+
throw new schematics_1.SchematicsException(`Cannot find "${configFilePath}".`);
|
|
229
|
+
}
|
|
230
|
+
const sourceFile = getSourceFile(host, configFilePath);
|
|
231
|
+
const nodes = (0, ast_utils_1.getSourceNodes)(sourceFile);
|
|
232
|
+
// Find the serverRoutes variable declaration
|
|
233
|
+
const serverRoutesNode = nodes.find((node) => typescript_1.default.isVariableDeclaration(node) &&
|
|
234
|
+
node.initializer &&
|
|
235
|
+
typescript_1.default.isArrayLiteralExpression(node.initializer) &&
|
|
236
|
+
node.type &&
|
|
237
|
+
typescript_1.default.isArrayTypeNode(node.type) &&
|
|
238
|
+
node.type.getText().includes('ServerRoute'));
|
|
239
|
+
if (!serverRoutesNode) {
|
|
240
|
+
throw new schematics_1.SchematicsException(`Cannot find the "ServerRoute" configuration in "${configFilePath}".`);
|
|
241
|
+
}
|
|
242
|
+
const recorder = host.beginUpdate(configFilePath);
|
|
243
|
+
const arrayLiteral = serverRoutesNode.initializer;
|
|
244
|
+
const firstElementPosition = arrayLiteral.elements[0]?.getStart() ?? arrayLiteral.getStart() + 1;
|
|
245
|
+
const newRouteString = `{
|
|
246
|
+
path: '${APP_SHELL_ROUTE}',
|
|
247
|
+
renderMode: RenderMode.AppShell
|
|
248
|
+
},\n`;
|
|
249
|
+
recorder.insertLeft(firstElementPosition, newRouteString);
|
|
250
|
+
host.commitUpdate(recorder);
|
|
251
|
+
};
|
|
252
|
+
}
|
|
278
253
|
function default_1(options) {
|
|
279
254
|
return async (tree) => {
|
|
280
255
|
const browserEntryPoint = await (0, util_1.getMainFilePath)(tree, options.project);
|
|
@@ -282,9 +257,9 @@ function default_1(options) {
|
|
|
282
257
|
return (0, schematics_1.chain)([
|
|
283
258
|
validateProject(browserEntryPoint),
|
|
284
259
|
(0, schematics_1.schematic)('server', options),
|
|
285
|
-
addAppShellConfigToWorkspace(options),
|
|
286
260
|
isStandalone ? (0, schematics_1.noop)() : addRouterModule(browserEntryPoint),
|
|
287
261
|
isStandalone ? addStandaloneServerRoute(options) : addServerRoutes(options),
|
|
262
|
+
addServerRoutingConfig(options),
|
|
288
263
|
(0, schematics_1.schematic)('component', {
|
|
289
264
|
name: 'app-shell',
|
|
290
265
|
module: 'app.module.server.ts',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
<% if(experimentalZoneless) { %>import { provideExperimentalZonelessChangeDetection } from '@angular/core';
|
|
2
|
+
<% } %>import { TestBed } from '@angular/core/testing';<% if (routing) { %>
|
|
2
3
|
import { RouterModule } from '@angular/router';<% } %>
|
|
3
4
|
import { AppComponent } from './app.component';
|
|
4
5
|
|
|
@@ -11,6 +12,7 @@ describe('AppComponent', () => {
|
|
|
11
12
|
declarations: [
|
|
12
13
|
AppComponent
|
|
13
14
|
],
|
|
15
|
+
<% if(experimentalZoneless) { %>providers: [provideExperimentalZonelessChangeDetection()]<% } %>
|
|
14
16
|
}).compileComponents();
|
|
15
17
|
});
|
|
16
18
|
|
|
@@ -9,7 +9,8 @@ import { Component } from '@angular/core';
|
|
|
9
9
|
%><router-outlet /><%
|
|
10
10
|
} %>
|
|
11
11
|
`,<% } else { %>
|
|
12
|
-
templateUrl: './app.component.html',<% }
|
|
12
|
+
templateUrl: './app.component.html',<% } %>
|
|
13
|
+
standalone: false,<% if(inlineStyle) { %>
|
|
13
14
|
styles: []<% } else { %>
|
|
14
15
|
styleUrl: './app.component.<%= style %>'<% } %>
|
|
15
16
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
1
|
+
import { NgModule<% if(experimentalZoneless) { %>, provideExperimentalZonelessChangeDetection<% } %> } from '@angular/core';
|
|
2
2
|
import { BrowserModule } from '@angular/platform-browser';
|
|
3
3
|
<% if (routing) { %>
|
|
4
4
|
import { AppRoutingModule } from './app-routing.module';<% } %>
|
|
@@ -12,7 +12,7 @@ import { AppComponent } from './app.component';
|
|
|
12
12
|
BrowserModule<% if (routing) { %>,
|
|
13
13
|
AppRoutingModule<% } %>
|
|
14
14
|
],
|
|
15
|
-
providers: [],
|
|
15
|
+
providers: [<% if (experimentalZoneless) { %>provideExperimentalZonelessChangeDetection()<% } %>],
|
|
16
16
|
bootstrap: [AppComponent]
|
|
17
17
|
})
|
|
18
18
|
export class AppModule { }
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
<% if(!!viewEncapsulation) { %>import { ViewEncapsulation } from '@angular/core';
|
|
2
2
|
<% }%>import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
3
|
-
|
|
4
3
|
import { AppModule } from './app/app.module';
|
|
5
4
|
|
|
6
5
|
platformBrowserDynamic().bootstrapModule(AppModule, {
|
|
7
|
-
ngZoneEventCoalescing: true
|
|
6
|
+
<% if(!experimentalZoneless) { %>ngZoneEventCoalescing: true,<% } %><% if(!!viewEncapsulation) { %>
|
|
8
7
|
defaultEncapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } %>
|
|
9
8
|
})
|
|
10
9
|
.catch(err => console.error(err));
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
<% if(experimentalZoneless) { %>import { provideExperimentalZonelessChangeDetection } from '@angular/core';
|
|
2
|
+
<% } %>import { TestBed } from '@angular/core/testing';
|
|
2
3
|
import { AppComponent } from './app.component';
|
|
3
4
|
|
|
4
5
|
describe('AppComponent', () => {
|
|
5
6
|
beforeEach(async () => {
|
|
6
7
|
await TestBed.configureTestingModule({
|
|
7
8
|
imports: [AppComponent],
|
|
9
|
+
<% if(experimentalZoneless) { %>providers: [provideExperimentalZonelessChangeDetection()]<% } %>
|
|
8
10
|
}).compileComponents();
|
|
9
11
|
});
|
|
10
12
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';<% if (routing) { %>
|
|
1
|
+
import { ApplicationConfig, <% if(!experimentalZoneless) { %>provideZoneChangeDetection<% } else { %>provideExperimentalZonelessChangeDetection<% } %> } from '@angular/core';<% if (routing) { %>
|
|
2
2
|
import { provideRouter } from '@angular/router';
|
|
3
3
|
|
|
4
4
|
import { routes } from './app.routes';<% } %>
|
|
5
5
|
|
|
6
6
|
export const appConfig: ApplicationConfig = {
|
|
7
|
-
providers: [
|
|
7
|
+
providers: [
|
|
8
|
+
<% if(experimentalZoneless) { %>provideExperimentalZonelessChangeDetection()<% } else { %>provideZoneChangeDetection({ eventCoalescing: true })<% } %><% if (routing) {%>, provideRouter(routes)<% } %>
|
|
9
|
+
]
|
|
8
10
|
};
|
package/application/index.js
CHANGED
|
@@ -198,7 +198,7 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
|
|
|
198
198
|
outputPath: `dist/${folderName}`,
|
|
199
199
|
index: `${sourceRoot}/index.html`,
|
|
200
200
|
browser: `${sourceRoot}/main.ts`,
|
|
201
|
-
polyfills: ['zone.js'],
|
|
201
|
+
polyfills: options.experimentalZoneless ? [] : ['zone.js'],
|
|
202
202
|
tsConfig: `${projectRoot}tsconfig.app.json`,
|
|
203
203
|
inlineStyleLanguage,
|
|
204
204
|
assets: [{ 'glob': '**/*', 'input': `${projectRoot}public` }],
|
|
@@ -238,7 +238,7 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
|
|
|
238
238
|
: {
|
|
239
239
|
builder: workspace_models_1.Builders.Karma,
|
|
240
240
|
options: {
|
|
241
|
-
polyfills: ['zone.js', 'zone.js/testing'],
|
|
241
|
+
polyfills: options.experimentalZoneless ? [] : ['zone.js', 'zone.js/testing'],
|
|
242
242
|
tsConfig: `${projectRoot}tsconfig.spec.json`,
|
|
243
243
|
inlineStyleLanguage,
|
|
244
244
|
assets: [{ 'glob': '**/*', 'input': `${projectRoot}public` }],
|
package/application/schema.d.ts
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* Generates a new basic application definition in the "projects" subfolder of the workspace.
|
|
3
3
|
*/
|
|
4
4
|
export interface Schema {
|
|
5
|
+
/**
|
|
6
|
+
* Create an application that does not utilize zone.js.
|
|
7
|
+
*/
|
|
8
|
+
experimentalZoneless?: boolean;
|
|
5
9
|
/**
|
|
6
10
|
* Include styles inline in the root component.ts file. Only CSS styles can be included
|
|
7
11
|
* inline. Default is false, meaning that an external styles file is created and referenced
|
package/application/schema.json
CHANGED
|
@@ -117,6 +117,11 @@
|
|
|
117
117
|
"type": "boolean",
|
|
118
118
|
"default": false,
|
|
119
119
|
"x-user-analytics": "ep.ng_ssr"
|
|
120
|
+
},
|
|
121
|
+
"experimentalZoneless": {
|
|
122
|
+
"description": "Create an application that does not utilize zone.js.",
|
|
123
|
+
"type": "boolean",
|
|
124
|
+
"default": false
|
|
120
125
|
}
|
|
121
126
|
},
|
|
122
127
|
"required": ["name"]
|
package/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template
CHANGED
|
@@ -3,7 +3,9 @@ import { <% if(changeDetection !== 'Default') { %>ChangeDetectionStrategy, <% }%
|
|
|
3
3
|
@Component({<% if(!skipSelector) {%>
|
|
4
4
|
selector: '<%= selector %>',<%}%><% if(standalone) {%>
|
|
5
5
|
standalone: true,
|
|
6
|
-
imports: [],<%}
|
|
6
|
+
imports: [],<%} else { %>
|
|
7
|
+
standalone: false,
|
|
8
|
+
<% }%><% if(inlineTemplate) { %>
|
|
7
9
|
template: `
|
|
8
10
|
<p>
|
|
9
11
|
<%= dasherize(name) %> works!
|
|
@@ -19,6 +21,6 @@ import { <% if(changeDetection !== 'Default') { %>ChangeDetectionStrategy, <% }%
|
|
|
19
21
|
encapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } if (changeDetection !== 'Default') { %>,
|
|
20
22
|
changeDetection: ChangeDetectionStrategy.<%= changeDetection %><% } %>
|
|
21
23
|
})
|
|
22
|
-
export class <%= classify(name) %><%= classify(type) %> {
|
|
24
|
+
export <% if(exportDefault) {%>default <%}%>class <%= classify(name) %><%= classify(type) %> {
|
|
23
25
|
|
|
24
26
|
}
|
package/component/index.js
CHANGED
|
@@ -42,6 +42,7 @@ function default_1(options) {
|
|
|
42
42
|
options.selector =
|
|
43
43
|
options.selector || buildSelector(options, (project && project.prefix) || '');
|
|
44
44
|
(0, validation_1.validateHtmlSelector)(options.selector);
|
|
45
|
+
(0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
|
|
45
46
|
const skipStyleFile = options.inlineStyle || options.style === schema_1.Style.None;
|
|
46
47
|
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
47
48
|
options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
|
package/component/schema.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ export interface Schema {
|
|
|
14
14
|
* The declaring NgModule exports this component.
|
|
15
15
|
*/
|
|
16
16
|
export?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Use default export for the component instead of a named export.
|
|
19
|
+
*/
|
|
20
|
+
exportDefault?: boolean;
|
|
17
21
|
/**
|
|
18
22
|
* Create the new files at the top level of the current project.
|
|
19
23
|
*/
|
package/component/schema.json
CHANGED
|
@@ -130,6 +130,11 @@
|
|
|
130
130
|
"type": "boolean",
|
|
131
131
|
"default": false,
|
|
132
132
|
"description": "The declaring NgModule exports this component."
|
|
133
|
+
},
|
|
134
|
+
"exportDefault": {
|
|
135
|
+
"type": "boolean",
|
|
136
|
+
"default": false,
|
|
137
|
+
"description": "Use default export for the component instead of a named export."
|
|
133
138
|
}
|
|
134
139
|
},
|
|
135
140
|
"required": ["name", "project"]
|
|
@@ -19,7 +19,6 @@ module.exports = function (config) {
|
|
|
19
19
|
// for example, you can disable the random execution with `random: false`
|
|
20
20
|
// or set a specific seed with `seed: 4321`
|
|
21
21
|
},
|
|
22
|
-
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
|
23
22
|
},
|
|
24
23
|
jasmineHtmlReporter: {
|
|
25
24
|
suppressAll: true // removes the duplicated traces
|
package/directive/index.js
CHANGED
|
@@ -40,6 +40,7 @@ function default_1(options) {
|
|
|
40
40
|
options.path = parsedPath.path;
|
|
41
41
|
options.selector = options.selector || buildSelector(options, project.prefix || '');
|
|
42
42
|
(0, validation_1.validateHtmlSelector)(options.selector);
|
|
43
|
+
(0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
|
|
43
44
|
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
44
45
|
options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
|
|
45
46
|
(0, schematics_1.applyTemplates)({
|
|
@@ -1,24 +1,63 @@
|
|
|
1
1
|
# <%= classify(name) %>
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version <%= angularLatestVersion %>.
|
|
4
4
|
|
|
5
5
|
## Code scaffolding
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
> Note: Don't forget to add `--project <%= name %>` or else it will be added to the default project in your `angular.json` file.
|
|
7
|
+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
```bash
|
|
10
|
+
ng generate component component-name
|
|
11
|
+
```
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
```bash
|
|
16
|
+
ng generate --help
|
|
17
|
+
```
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
## Building
|
|
20
|
+
|
|
21
|
+
To build the library, run:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
ng build <%= name %>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
28
|
+
|
|
29
|
+
### Publishing the Library
|
|
30
|
+
|
|
31
|
+
Once the project is built, you can publish your library by following these steps:
|
|
32
|
+
|
|
33
|
+
1. Navigate to the `dist` directory:
|
|
34
|
+
```bash
|
|
35
|
+
cd dist/<%= dasherize(name) %>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. Run the `npm publish` command to publish your library to the npm registry:
|
|
39
|
+
```bash
|
|
40
|
+
npm publish
|
|
41
|
+
```
|
|
17
42
|
|
|
18
43
|
## Running unit tests
|
|
19
44
|
|
|
20
|
-
|
|
45
|
+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
ng test
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Running end-to-end tests
|
|
52
|
+
|
|
53
|
+
For end-to-end (e2e) testing, run:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
ng e2e
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
|
21
60
|
|
|
22
|
-
##
|
|
61
|
+
## Additional Resources
|
|
23
62
|
|
|
24
|
-
|
|
63
|
+
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"version": "19.0.0",
|
|
12
12
|
"factory": "./update-workspace-config/migration",
|
|
13
13
|
"description": "Update the workspace configuration by replacing deprecated options in 'angular.json' for compatibility with the latest Angular CLI changes."
|
|
14
|
+
},
|
|
15
|
+
"update-ssr-imports": {
|
|
16
|
+
"version": "19.0.0",
|
|
17
|
+
"factory": "./update-ssr-imports/migration",
|
|
18
|
+
"description": "Update '@angular/ssr' import paths to use the new '/node' entry point when 'CommonEngine' is detected."
|
|
14
19
|
}
|
|
15
20
|
}
|
|
16
21
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { Rule } from '@angular-devkit/schematics';
|
|
9
|
+
/**
|
|
10
|
+
* Schematics rule that identifies and updates import declarations in TypeScript files.
|
|
11
|
+
* Specifically, it modifies imports of '@angular/ssr' by appending '/node' if the
|
|
12
|
+
* `CommonEngine` is used from the old entry point.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export default function (): Rule;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.default = default_1;
|
|
34
|
+
const ts = __importStar(require("../../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
|
35
|
+
function* visit(directory) {
|
|
36
|
+
for (const path of directory.subfiles) {
|
|
37
|
+
if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
|
|
38
|
+
const entry = directory.file(path);
|
|
39
|
+
if (entry) {
|
|
40
|
+
const content = entry.content;
|
|
41
|
+
if (content.includes('CommonEngine') && !content.includes('@angular/ssr/node')) {
|
|
42
|
+
const source = ts.createSourceFile(entry.path, content.toString().replace(/^\uFEFF/, ''), ts.ScriptTarget.Latest, true);
|
|
43
|
+
yield source;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
for (const path of directory.subdirs) {
|
|
49
|
+
if (path === 'node_modules' || path.startsWith('.')) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
yield* visit(directory.dir(path));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Schematics rule that identifies and updates import declarations in TypeScript files.
|
|
57
|
+
* Specifically, it modifies imports of '@angular/ssr' by appending '/node' if the
|
|
58
|
+
* `CommonEngine` is used from the old entry point.
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
function default_1() {
|
|
62
|
+
return (tree) => {
|
|
63
|
+
for (const sourceFile of visit(tree.root)) {
|
|
64
|
+
let recorder;
|
|
65
|
+
const allImportDeclarations = sourceFile.statements.filter((n) => ts.isImportDeclaration(n));
|
|
66
|
+
if (allImportDeclarations.length === 0) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const ssrImports = allImportDeclarations.filter((n) => ts.isStringLiteral(n.moduleSpecifier) && n.moduleSpecifier.text === '@angular/ssr');
|
|
70
|
+
for (const ssrImport of ssrImports) {
|
|
71
|
+
const ssrNamedBinding = getNamedImports(ssrImport);
|
|
72
|
+
if (ssrNamedBinding) {
|
|
73
|
+
const isUsingOldEntryPoint = ssrNamedBinding.elements.some((e) => e.name.text.startsWith('CommonEngine'));
|
|
74
|
+
if (!isUsingOldEntryPoint) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
recorder ??= tree.beginUpdate(sourceFile.fileName);
|
|
78
|
+
recorder.insertRight(ssrImport.moduleSpecifier.getEnd() - 1, '/node');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (recorder) {
|
|
82
|
+
tree.commitUpdate(recorder);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function getNamedImports(importDeclaration) {
|
|
88
|
+
const namedBindings = importDeclaration?.importClause?.namedBindings;
|
|
89
|
+
if (namedBindings && ts.isNamedImports(namedBindings)) {
|
|
90
|
+
return namedBindings;
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
package/ng-new/index.js
CHANGED
|
@@ -40,6 +40,7 @@ function default_1(options) {
|
|
|
40
40
|
minimal: options.minimal,
|
|
41
41
|
standalone: options.standalone,
|
|
42
42
|
ssr: options.ssr,
|
|
43
|
+
experimentalZoneless: options.experimentalZoneless,
|
|
43
44
|
};
|
|
44
45
|
return (0, schematics_1.chain)([
|
|
45
46
|
(0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.empty)(), [
|
package/ng-new/schema.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ export interface Schema {
|
|
|
16
16
|
* The directory name to create the workspace in.
|
|
17
17
|
*/
|
|
18
18
|
directory?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Create an application that does not utilize zone.js.
|
|
21
|
+
*/
|
|
22
|
+
experimentalZoneless?: boolean;
|
|
19
23
|
/**
|
|
20
24
|
* Include styles inline in the component TS file. By default, an external styles file is
|
|
21
25
|
* created and referenced in the component TypeScript file.
|
package/ng-new/schema.json
CHANGED
|
@@ -138,6 +138,11 @@
|
|
|
138
138
|
"description": "Creates an application with Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering) enabled.",
|
|
139
139
|
"type": "boolean",
|
|
140
140
|
"x-user-analytics": "ep.ng_ssr"
|
|
141
|
+
},
|
|
142
|
+
"experimentalZoneless": {
|
|
143
|
+
"description": "Create an application that does not utilize zone.js.",
|
|
144
|
+
"type": "boolean",
|
|
145
|
+
"default": false
|
|
141
146
|
}
|
|
142
147
|
},
|
|
143
148
|
"required": ["name", "version"]
|