@schematics/angular 20.2.2 → 21.0.0-next.1

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.
Files changed (53) hide show
  1. package/app-shell/index.d.ts +2 -1
  2. package/app-shell/index.js +16 -24
  3. package/application/index.js +9 -0
  4. package/application/schema.d.ts +2 -1
  5. package/application/schema.js +1 -0
  6. package/application/schema.json +6 -2
  7. package/collection.json +7 -0
  8. package/component/index.d.ts +2 -1
  9. package/component/index.js +45 -53
  10. package/config/.browserslistrc +5 -5
  11. package/config/index.d.ts +2 -1
  12. package/config/index.js +12 -19
  13. package/directive/index.d.ts +2 -1
  14. package/directive/index.js +20 -27
  15. package/migrations/migration-collection.json +2 -22
  16. package/module/index.d.ts +2 -1
  17. package/module/index.js +48 -50
  18. package/ng-new/schema.d.ts +2 -2
  19. package/ng-new/schema.js +1 -1
  20. package/ng-new/schema.json +2 -2
  21. package/package.json +4 -4
  22. package/pipe/index.d.ts +2 -2
  23. package/pipe/index.js +16 -18
  24. package/server/index.d.ts +2 -1
  25. package/server/index.js +67 -71
  26. package/service-worker/index.d.ts +2 -1
  27. package/service-worker/index.js +44 -81
  28. package/ssr/index.d.ts +2 -1
  29. package/ssr/index.js +32 -40
  30. package/tailwind/files/.postcssrc.json.template +5 -0
  31. package/{migrations/previous-style-guide/migration.d.ts → tailwind/index.d.ts} +5 -2
  32. package/tailwind/index.js +51 -0
  33. package/tailwind/schema.d.ts +7 -0
  34. package/tailwind/schema.js +4 -0
  35. package/tailwind/schema.json +15 -0
  36. package/utility/ast-utils.js +10 -7
  37. package/utility/latest-versions/package.json +2 -0
  38. package/utility/latest-versions.js +5 -5
  39. package/utility/project.d.ts +25 -0
  40. package/utility/project.js +30 -0
  41. package/utility/standalone/rules.js +2 -3
  42. package/web-worker/index.d.ts +2 -1
  43. package/web-worker/index.js +60 -70
  44. package/workspace/schema.d.ts +0 -1
  45. package/workspace/schema.js +0 -1
  46. package/workspace/schema.json +1 -1
  47. package/migrations/previous-style-guide/migration.js +0 -42
  48. package/migrations/replace-provide-server-rendering-import/migration.d.ts +0 -9
  49. package/migrations/replace-provide-server-rendering-import/migration.js +0 -98
  50. package/migrations/replace-provide-server-routing/migration.d.ts +0 -9
  51. package/migrations/replace-provide-server-routing/migration.js +0 -125
  52. package/migrations/update-module-resolution/migration.d.ts +0 -9
  53. package/migrations/update-module-resolution/migration.js +0 -52
@@ -99,7 +99,7 @@
99
99
  "style": {
100
100
  "description": "The type of stylesheet files to be created for components in the initial project.",
101
101
  "type": "string",
102
- "enum": ["css", "scss", "sass", "less"],
102
+ "enum": ["css", "scss", "sass", "less", "tailwind"],
103
103
  "x-user-analytics": "ep.ng_style"
104
104
  },
105
105
  "skipTests": {
@@ -126,7 +126,7 @@
126
126
  "packageManager": {
127
127
  "description": "The package manager used to install dependencies.",
128
128
  "type": "string",
129
- "enum": ["npm", "yarn", "pnpm", "cnpm", "bun"]
129
+ "enum": ["npm", "yarn", "pnpm", "bun"]
130
130
  },
131
131
  "standalone": {
132
132
  "description": "Creates an application based upon the standalone API, without NgModules.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "20.2.2",
3
+ "version": "21.0.0-next.1",
4
4
  "description": "Schematics specific to Angular",
5
5
  "homepage": "https://github.com/angular/angular-cli",
6
6
  "keywords": [
@@ -22,15 +22,15 @@
22
22
  },
23
23
  "schematics": "./collection.json",
24
24
  "dependencies": {
25
- "@angular-devkit/core": "20.2.2",
26
- "@angular-devkit/schematics": "20.2.2",
25
+ "@angular-devkit/core": "21.0.0-next.1",
26
+ "@angular-devkit/schematics": "21.0.0-next.1",
27
27
  "jsonc-parser": "3.3.1"
28
28
  },
29
29
  "repository": {
30
30
  "type": "git",
31
31
  "url": "https://github.com/angular/angular-cli.git"
32
32
  },
33
- "packageManager": "pnpm@10.15.1",
33
+ "packageManager": "pnpm@10.15.0",
34
34
  "engines": {
35
35
  "node": "^20.19.0 || ^22.12.0 || >=24.0.0",
36
36
  "npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
package/pipe/index.d.ts CHANGED
@@ -5,6 +5,6 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
- import { Rule } from '@angular-devkit/schematics';
9
8
  import { Schema as PipeOptions } from './schema';
10
- export default function (options: PipeOptions): Rule;
9
+ declare const _default: (options: PipeOptions) => import("@angular-devkit/schematics").Rule;
10
+ export default _default;
package/pipe/index.js CHANGED
@@ -7,28 +7,26 @@
7
7
  * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.default = default_1;
11
10
  const schematics_1 = require("@angular-devkit/schematics");
12
11
  const add_declaration_to_ng_module_1 = require("../utility/add-declaration-to-ng-module");
13
12
  const find_module_1 = require("../utility/find-module");
14
13
  const generate_from_files_1 = require("../utility/generate-from-files");
15
14
  const parse_name_1 = require("../utility/parse-name");
15
+ const project_1 = require("../utility/project");
16
16
  const validation_1 = require("../utility/validation");
17
17
  const workspace_1 = require("../utility/workspace");
18
- function default_1(options) {
19
- return async (host) => {
20
- options.path ??= await (0, workspace_1.createDefaultPath)(host, options.project);
21
- options.module = (0, find_module_1.findModuleFromOptions)(host, options);
22
- const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
23
- options.name = parsedPath.name;
24
- options.path = parsedPath.path;
25
- (0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
26
- return (0, schematics_1.chain)([
27
- (0, add_declaration_to_ng_module_1.addDeclarationToNgModule)({
28
- type: 'pipe',
29
- ...options,
30
- }),
31
- (0, generate_from_files_1.generateFromFiles)(options),
32
- ]);
33
- };
34
- }
18
+ exports.default = (0, project_1.createProjectSchematic)(async (options, { tree }) => {
19
+ options.path ??= await (0, workspace_1.createDefaultPath)(tree, options.project);
20
+ options.module = (0, find_module_1.findModuleFromOptions)(tree, options);
21
+ const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
22
+ options.name = parsedPath.name;
23
+ options.path = parsedPath.path;
24
+ (0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
25
+ return (0, schematics_1.chain)([
26
+ (0, add_declaration_to_ng_module_1.addDeclarationToNgModule)({
27
+ type: 'pipe',
28
+ ...options,
29
+ }),
30
+ (0, generate_from_files_1.generateFromFiles)(options),
31
+ ]);
32
+ });
package/server/index.d.ts CHANGED
@@ -7,4 +7,5 @@
7
7
  */
8
8
  import { Rule } from '@angular-devkit/schematics';
9
9
  import { Schema as ServerOptions } from './schema';
10
- export default function (options: ServerOptions): Rule;
10
+ declare const _default: (options: ServerOptions) => Rule;
11
+ export default _default;
package/server/index.js CHANGED
@@ -7,7 +7,6 @@
7
7
  * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.default = default_1;
11
10
  const core_1 = require("@angular-devkit/core");
12
11
  const schematics_1 = require("@angular-devkit/schematics");
13
12
  const node_path_1 = require("node:path");
@@ -17,6 +16,7 @@ const json_file_1 = require("../utility/json-file");
17
16
  const latest_versions_1 = require("../utility/latest-versions");
18
17
  const ng_ast_utils_1 = require("../utility/ng-ast-utils");
19
18
  const paths_1 = require("../utility/paths");
19
+ const project_1 = require("../utility/project");
20
20
  const project_targets_1 = require("../utility/project-targets");
21
21
  const app_component_1 = require("../utility/standalone/app_component");
22
22
  const util_1 = require("../utility/standalone/util");
@@ -132,74 +132,70 @@ function addDependencies(skipInstall) {
132
132
  ]);
133
133
  };
134
134
  }
135
- function default_1(options) {
136
- return async (host) => {
137
- const workspace = await (0, workspace_1.getWorkspace)(host);
138
- const clientProject = workspace.projects.get(options.project);
139
- if (clientProject?.extensions.projectType !== 'application') {
140
- throw new schematics_1.SchematicsException(`Server schematic requires a project type of "application".`);
141
- }
142
- const clientBuildTarget = clientProject.targets.get('build');
143
- if (!clientBuildTarget) {
144
- throw (0, project_targets_1.targetBuildNotFoundError)();
145
- }
146
- const usingApplicationBuilder = (0, project_targets_1.isUsingApplicationBuilder)(clientProject);
147
- if (clientProject.targets.has('server') ||
148
- (usingApplicationBuilder && clientBuildTarget.options?.server !== undefined)) {
149
- // Server has already been added.
150
- return;
151
- }
152
- const clientBuildOptions = clientBuildTarget.options;
153
- const browserEntryPoint = await (0, util_1.getMainFilePath)(host, options.project);
154
- const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(host, browserEntryPoint);
155
- const sourceRoot = clientProject.sourceRoot ?? (0, core_1.join)((0, core_1.normalize)(clientProject.root), 'src');
156
- let filesUrl = `./files/${usingApplicationBuilder ? 'application-builder/' : 'server-builder/'}`;
157
- filesUrl += isStandalone ? 'standalone-src' : 'ngmodule-src';
158
- const { componentName, componentImportPathInSameFile, moduleName, moduleImportPathInSameFile } = (0, app_component_1.resolveBootstrappedComponentData)(host, browserEntryPoint) || {
159
- componentName: 'App',
160
- componentImportPathInSameFile: './app/app',
161
- moduleName: 'AppModule',
162
- moduleImportPathInSameFile: './app/app.module',
163
- };
164
- const templateSource = (0, schematics_1.apply)((0, schematics_1.url)(filesUrl), [
165
- (0, schematics_1.applyTemplates)({
166
- ...schematics_1.strings,
167
- ...options,
168
- appComponentName: componentName,
169
- appComponentPath: componentImportPathInSameFile,
170
- appModuleName: moduleName,
171
- appModulePath: moduleImportPathInSameFile === null
172
- ? null
173
- : `./${node_path_1.posix.basename(moduleImportPathInSameFile)}`,
174
- }),
175
- (0, schematics_1.move)(sourceRoot),
176
- ]);
177
- const clientTsConfig = (0, core_1.normalize)(clientBuildOptions.tsConfig);
178
- const tsConfigExtends = (0, core_1.basename)(clientTsConfig);
179
- const tsConfigDirectory = (0, core_1.dirname)(clientTsConfig);
180
- return (0, schematics_1.chain)([
181
- (0, schematics_1.mergeWith)(templateSource),
182
- ...(usingApplicationBuilder
183
- ? [
184
- updateConfigFileApplicationBuilder(options),
185
- updateTsConfigFile(clientBuildOptions.tsConfig),
186
- ]
187
- : [
188
- (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files/server-builder/root'), [
189
- (0, schematics_1.applyTemplates)({
190
- ...schematics_1.strings,
191
- ...options,
192
- stripTsExtension: (s) => s.replace(/\.ts$/, ''),
193
- tsConfigExtends,
194
- hasLocalizePackage: !!(0, dependencies_1.getPackageJsonDependency)(host, '@angular/localize'),
195
- relativePathToWorkspaceRoot: (0, paths_1.relativePathToWorkspaceRoot)(tsConfigDirectory),
196
- }),
197
- (0, schematics_1.move)(tsConfigDirectory),
198
- ])),
199
- updateConfigFileBrowserBuilder(options, tsConfigDirectory),
200
- ]),
201
- addDependencies(options.skipInstall),
202
- (0, utility_1.addRootProvider)(options.project, ({ code, external }) => code `${external('provideClientHydration', '@angular/platform-browser')}(${external('withEventReplay', '@angular/platform-browser')}())`),
203
- ]);
135
+ exports.default = (0, project_1.createProjectSchematic)(async (options, { project, tree }) => {
136
+ if (project?.extensions.projectType !== 'application') {
137
+ throw new schematics_1.SchematicsException(`Server schematic requires a project type of "application".`);
138
+ }
139
+ const clientBuildTarget = project.targets.get('build');
140
+ if (!clientBuildTarget) {
141
+ throw (0, project_targets_1.targetBuildNotFoundError)();
142
+ }
143
+ const usingApplicationBuilder = (0, project_targets_1.isUsingApplicationBuilder)(project);
144
+ if (project.targets.has('server') ||
145
+ (usingApplicationBuilder && clientBuildTarget.options?.server !== undefined)) {
146
+ // Server has already been added.
147
+ return (0, schematics_1.noop)();
148
+ }
149
+ const clientBuildOptions = clientBuildTarget.options;
150
+ const browserEntryPoint = await (0, util_1.getMainFilePath)(tree, options.project);
151
+ const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(tree, browserEntryPoint);
152
+ const sourceRoot = project.sourceRoot ?? (0, core_1.join)((0, core_1.normalize)(project.root), 'src');
153
+ let filesUrl = `./files/${usingApplicationBuilder ? 'application-builder/' : 'server-builder/'}`;
154
+ filesUrl += isStandalone ? 'standalone-src' : 'ngmodule-src';
155
+ const { componentName, componentImportPathInSameFile, moduleName, moduleImportPathInSameFile } = (0, app_component_1.resolveBootstrappedComponentData)(tree, browserEntryPoint) || {
156
+ componentName: 'App',
157
+ componentImportPathInSameFile: './app/app',
158
+ moduleName: 'AppModule',
159
+ moduleImportPathInSameFile: './app/app.module',
204
160
  };
205
- }
161
+ const templateSource = (0, schematics_1.apply)((0, schematics_1.url)(filesUrl), [
162
+ (0, schematics_1.applyTemplates)({
163
+ ...schematics_1.strings,
164
+ ...options,
165
+ appComponentName: componentName,
166
+ appComponentPath: componentImportPathInSameFile,
167
+ appModuleName: moduleName,
168
+ appModulePath: moduleImportPathInSameFile === null
169
+ ? null
170
+ : `./${node_path_1.posix.basename(moduleImportPathInSameFile)}`,
171
+ }),
172
+ (0, schematics_1.move)(sourceRoot),
173
+ ]);
174
+ const clientTsConfig = (0, core_1.normalize)(clientBuildOptions.tsConfig);
175
+ const tsConfigExtends = (0, core_1.basename)(clientTsConfig);
176
+ const tsConfigDirectory = (0, core_1.dirname)(clientTsConfig);
177
+ return (0, schematics_1.chain)([
178
+ (0, schematics_1.mergeWith)(templateSource),
179
+ ...(usingApplicationBuilder
180
+ ? [
181
+ updateConfigFileApplicationBuilder(options),
182
+ updateTsConfigFile(clientBuildOptions.tsConfig),
183
+ ]
184
+ : [
185
+ (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files/server-builder/root'), [
186
+ (0, schematics_1.applyTemplates)({
187
+ ...schematics_1.strings,
188
+ ...options,
189
+ stripTsExtension: (s) => s.replace(/\.ts$/, ''),
190
+ tsConfigExtends,
191
+ hasLocalizePackage: !!(0, dependencies_1.getPackageJsonDependency)(tree, '@angular/localize'),
192
+ relativePathToWorkspaceRoot: (0, paths_1.relativePathToWorkspaceRoot)(tsConfigDirectory),
193
+ }),
194
+ (0, schematics_1.move)(tsConfigDirectory),
195
+ ])),
196
+ updateConfigFileBrowserBuilder(options, tsConfigDirectory),
197
+ ]),
198
+ addDependencies(options.skipInstall),
199
+ (0, utility_1.addRootProvider)(options.project, ({ code, external }) => code `${external('provideClientHydration', '@angular/platform-browser')}(${external('withEventReplay', '@angular/platform-browser')}())`),
200
+ ]);
201
+ });
@@ -7,4 +7,5 @@
7
7
  */
8
8
  import { Rule } from '@angular-devkit/schematics';
9
9
  import { Schema as ServiceWorkerOptions } from './schema';
10
- export default function (options: ServiceWorkerOptions): Rule;
10
+ declare const _default: (options: ServiceWorkerOptions) => Rule;
11
+ export default _default;
@@ -6,50 +6,20 @@
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
7
  * found in the LICENSE file at https://angular.dev/license
8
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 () {
26
- var ownKeys = function(o) {
27
- ownKeys = Object.getOwnPropertyNames || function (o) {
28
- var ar = [];
29
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
- return ar;
31
- };
32
- return ownKeys(o);
33
- };
34
- return function (mod) {
35
- if (mod && mod.__esModule) return mod;
36
- var result = {};
37
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
- __setModuleDefault(result, mod);
39
- return result;
40
- };
41
- })();
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
42
12
  Object.defineProperty(exports, "__esModule", { value: true });
43
- exports.default = default_1;
44
- const core_1 = require("@angular-devkit/core");
45
13
  const schematics_1 = require("@angular-devkit/schematics");
46
- const ts = __importStar(require("../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
14
+ const posix_1 = require("node:path/posix");
15
+ const typescript_1 = __importDefault(require("../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
47
16
  const utility_1 = require("../utility");
48
17
  const ast_utils_1 = require("../utility/ast-utils");
49
18
  const change_1 = require("../utility/change");
50
19
  const dependency_1 = require("../utility/dependency");
51
20
  const ng_ast_utils_1 = require("../utility/ng-ast-utils");
52
21
  const paths_1 = require("../utility/paths");
22
+ const project_1 = require("../utility/project");
53
23
  const project_targets_1 = require("../utility/project-targets");
54
24
  const app_config_1 = require("../utility/standalone/app_config");
55
25
  const util_1 = require("../utility/standalone/util");
@@ -71,7 +41,7 @@ function updateAppModule(mainPath) {
71
41
  addImport(host, modulePath, 'ServiceWorkerModule', '@angular/service-worker');
72
42
  addImport(host, modulePath, 'isDevMode', '@angular/core');
73
43
  // register SW in application module
74
- const importText = core_1.tags.stripIndent `
44
+ const importText = `
75
45
  ServiceWorkerModule.register('ngsw-worker.js', {
76
46
  enabled: !isDevMode(),
77
47
  // Register the ServiceWorker as soon as the application is stable
@@ -102,53 +72,46 @@ function addProvideServiceWorker(projectName, mainPath) {
102
72
  }
103
73
  function getTsSourceFile(host, path) {
104
74
  const content = host.readText(path);
105
- const source = ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true);
75
+ const source = typescript_1.default.createSourceFile(path, content, typescript_1.default.ScriptTarget.Latest, true);
106
76
  return source;
107
77
  }
108
- function default_1(options) {
109
- return async (host) => {
110
- const workspace = await (0, utility_1.readWorkspace)(host);
111
- const project = workspace.projects.get(options.project);
112
- if (!project) {
113
- throw new schematics_1.SchematicsException(`Invalid project name (${options.project})`);
114
- }
115
- if (project.extensions.projectType !== 'application') {
116
- throw new schematics_1.SchematicsException(`Service worker requires a project type of "application".`);
117
- }
118
- const buildTarget = project.targets.get('build');
119
- if (!buildTarget) {
120
- throw (0, project_targets_1.targetBuildNotFoundError)();
121
- }
122
- const buildOptions = buildTarget.options;
123
- const browserEntryPoint = await (0, util_1.getMainFilePath)(host, options.project);
124
- const ngswConfigPath = (0, core_1.join)((0, core_1.normalize)(project.root), 'ngsw-config.json');
125
- if (buildTarget.builder === workspace_models_1.Builders.Application ||
126
- buildTarget.builder === workspace_models_1.Builders.BuildApplication) {
127
- const productionConf = buildTarget.configurations?.production;
128
- if (productionConf) {
129
- productionConf.serviceWorker = ngswConfigPath;
130
- }
131
- }
132
- else {
133
- buildOptions.serviceWorker = true;
134
- buildOptions.ngswConfigPath = ngswConfigPath;
78
+ exports.default = (0, project_1.createProjectSchematic)(async (options, { project, workspace, tree }) => {
79
+ if (project.extensions.projectType !== 'application') {
80
+ throw new schematics_1.SchematicsException(`Service worker requires a project type of "application".`);
81
+ }
82
+ const buildTarget = project.targets.get('build');
83
+ if (!buildTarget) {
84
+ throw (0, project_targets_1.targetBuildNotFoundError)();
85
+ }
86
+ const buildOptions = buildTarget.options;
87
+ const browserEntryPoint = await (0, util_1.getMainFilePath)(tree, options.project);
88
+ const ngswConfigPath = (0, posix_1.join)(project.root, 'ngsw-config.json');
89
+ if (buildTarget.builder === workspace_models_1.Builders.Application ||
90
+ buildTarget.builder === workspace_models_1.Builders.BuildApplication) {
91
+ const productionConf = buildTarget.configurations?.production;
92
+ if (productionConf) {
93
+ productionConf.serviceWorker = ngswConfigPath;
135
94
  }
136
- await (0, utility_1.writeWorkspace)(host, workspace);
137
- return (0, schematics_1.chain)([
138
- addDependencies(),
139
- (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
140
- (0, schematics_1.applyTemplates)({
141
- ...options,
142
- relativePathToWorkspaceRoot: (0, paths_1.relativePathToWorkspaceRoot)(project.root),
143
- }),
144
- (0, schematics_1.move)(project.root),
145
- ])),
146
- (0, ng_ast_utils_1.isStandaloneApp)(host, browserEntryPoint)
147
- ? addProvideServiceWorker(options.project, browserEntryPoint)
148
- : updateAppModule(browserEntryPoint),
149
- ]);
150
- };
151
- }
95
+ }
96
+ else {
97
+ buildOptions.serviceWorker = true;
98
+ buildOptions.ngswConfigPath = ngswConfigPath;
99
+ }
100
+ await (0, utility_1.writeWorkspace)(tree, workspace);
101
+ return (0, schematics_1.chain)([
102
+ addDependencies(),
103
+ (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
104
+ (0, schematics_1.applyTemplates)({
105
+ ...options,
106
+ relativePathToWorkspaceRoot: (0, paths_1.relativePathToWorkspaceRoot)(project.root),
107
+ }),
108
+ (0, schematics_1.move)(project.root),
109
+ ])),
110
+ (0, ng_ast_utils_1.isStandaloneApp)(tree, browserEntryPoint)
111
+ ? addProvideServiceWorker(options.project, browserEntryPoint)
112
+ : updateAppModule(browserEntryPoint),
113
+ ]);
114
+ });
152
115
  function addImport(host, filePath, symbolName, moduleName) {
153
116
  const moduleSource = getTsSourceFile(host, filePath);
154
117
  const change = (0, ast_utils_1.insertImport)(moduleSource, filePath, symbolName, moduleName);
package/ssr/index.d.ts CHANGED
@@ -7,4 +7,5 @@
7
7
  */
8
8
  import { Rule } from '@angular-devkit/schematics';
9
9
  import { Schema as SSROptions } from './schema';
10
- export default function (options: SSROptions): Rule;
10
+ declare const _default: (options: SSROptions) => Rule;
11
+ export default _default;
package/ssr/index.js CHANGED
@@ -7,17 +7,16 @@
7
7
  * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.default = default_1;
11
10
  const core_1 = require("@angular-devkit/core");
12
11
  const schematics_1 = require("@angular-devkit/schematics");
13
- const node_path_1 = require("node:path");
12
+ const posix_1 = require("node:path/posix");
14
13
  const utility_1 = require("../utility");
15
14
  const json_file_1 = require("../utility/json-file");
16
15
  const latest_versions_1 = require("../utility/latest-versions");
17
16
  const ng_ast_utils_1 = require("../utility/ng-ast-utils");
17
+ const project_1 = require("../utility/project");
18
18
  const project_targets_1 = require("../utility/project-targets");
19
19
  const util_1 = require("../utility/standalone/util");
20
- const workspace_1 = require("../utility/workspace");
21
20
  const SERVE_SSR_TARGET_NAME = 'serve-ssr';
22
21
  const PRERENDER_TARGET_NAME = 'prerender';
23
22
  const DEFAULT_BROWSER_DIR = 'browser';
@@ -48,7 +47,7 @@ async function getApplicationBuilderOutputPaths(host, projectName) {
48
47
  }
49
48
  let { outputPath } = architectTarget.options;
50
49
  // Use default if not explicitly specified
51
- outputPath ??= node_path_1.posix.join('dist', projectName);
50
+ outputPath ??= (0, posix_1.join)('dist', projectName);
52
51
  const defaultDirs = {
53
52
  server: DEFAULT_SERVER_DIR,
54
53
  browser: DEFAULT_BROWSER_DIR,
@@ -78,7 +77,7 @@ function addScriptsRule({ project }, isUsingApplicationBuilder) {
78
77
  if (isUsingApplicationBuilder) {
79
78
  const { base, server } = await getApplicationBuilderOutputPaths(host, project);
80
79
  pkg.scripts ??= {};
81
- pkg.scripts[`serve:ssr:${project}`] = `node ${node_path_1.posix.join(base, server)}/server.mjs`;
80
+ pkg.scripts[`serve:ssr:${project}`] = `node ${(0, posix_1.join)(base, server)}/server.mjs`;
82
81
  }
83
82
  else {
84
83
  const serverDist = await getLegacyOutputPaths(host, project, 'server');
@@ -128,7 +127,7 @@ function updateApplicationBuilderWorkspaceConfigRule(projectSourceRoot, options,
128
127
  if (outputPath && (0, core_1.isJsonObject)(outputPath)) {
129
128
  if (outputPath.browser === '') {
130
129
  const base = outputPath.base;
131
- logger.warn(`The output location of the browser build has been updated from "${base}" to "${node_path_1.posix.join(base, DEFAULT_BROWSER_DIR)}".
130
+ logger.warn(`The output location of the browser build has been updated from "${base}" to "${(0, posix_1.join)(base, DEFAULT_BROWSER_DIR)}".
132
131
  You might need to adjust your deployment pipeline.`);
133
132
  if ((outputPath.media && outputPath.media !== DEFAULT_MEDIA_DIR) ||
134
133
  (outputPath.server && outputPath.server !== DEFAULT_SERVER_DIR)) {
@@ -144,7 +143,7 @@ function updateApplicationBuilderWorkspaceConfigRule(projectSourceRoot, options,
144
143
  outputPath,
145
144
  outputMode: 'server',
146
145
  ssr: {
147
- entry: (0, core_1.join)((0, core_1.normalize)(projectSourceRoot), 'server.ts'),
146
+ entry: (0, posix_1.join)(projectSourceRoot, 'server.ts'),
148
147
  },
149
148
  };
150
149
  });
@@ -158,7 +157,7 @@ function updateWebpackBuilderWorkspaceConfigRule(projectSourceRoot, options) {
158
157
  }
159
158
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
160
159
  const serverTarget = project.targets.get('server');
161
- (serverTarget.options ??= {}).main = node_path_1.posix.join(projectSourceRoot, 'server.ts');
160
+ (serverTarget.options ??= {}).main = (0, posix_1.join)(projectSourceRoot, 'server.ts');
162
161
  const serveSSRTarget = project.targets.get(SERVE_SSR_TARGET_NAME);
163
162
  if (serveSSRTarget) {
164
163
  return;
@@ -260,7 +259,7 @@ function addServerFile(projectSourceRoot, options, isStandalone) {
260
259
  : await getLegacyOutputPaths(host, projectName, 'build');
261
260
  return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)(`./files/${usingApplicationBuilder ? 'application-builder' : 'server-builder'}`), [
262
261
  (0, schematics_1.applyTemplates)({
263
- ...core_1.strings,
262
+ ...schematics_1.strings,
264
263
  ...options,
265
264
  browserDistDirectory,
266
265
  isStandalone,
@@ -269,34 +268,27 @@ function addServerFile(projectSourceRoot, options, isStandalone) {
269
268
  ]));
270
269
  };
271
270
  }
272
- function default_1(options) {
273
- return async (host, context) => {
274
- const browserEntryPoint = await (0, util_1.getMainFilePath)(host, options.project);
275
- const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(host, browserEntryPoint);
276
- const workspace = await (0, workspace_1.getWorkspace)(host);
277
- const clientProject = workspace.projects.get(options.project);
278
- if (!clientProject) {
279
- throw (0, project_targets_1.targetBuildNotFoundError)();
280
- }
281
- const usingApplicationBuilder = (0, project_targets_1.isUsingApplicationBuilder)(clientProject);
282
- const sourceRoot = clientProject.sourceRoot ?? node_path_1.posix.join(clientProject.root, 'src');
283
- return (0, schematics_1.chain)([
284
- (0, schematics_1.schematic)('server', {
285
- ...options,
286
- skipInstall: true,
287
- }),
288
- ...(usingApplicationBuilder
289
- ? [
290
- updateApplicationBuilderWorkspaceConfigRule(sourceRoot, options, context),
291
- updateApplicationBuilderTsConfigRule(options),
292
- ]
293
- : [
294
- updateWebpackBuilderServerTsConfigRule(options),
295
- updateWebpackBuilderWorkspaceConfigRule(sourceRoot, options),
296
- ]),
297
- addServerFile(sourceRoot, options, isStandalone),
298
- addScriptsRule(options, usingApplicationBuilder),
299
- addDependencies(options, usingApplicationBuilder),
300
- ]);
301
- };
302
- }
271
+ exports.default = (0, project_1.createProjectSchematic)(async (options, { project, tree, context }) => {
272
+ const browserEntryPoint = await (0, util_1.getMainFilePath)(tree, options.project);
273
+ const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(tree, browserEntryPoint);
274
+ const usingApplicationBuilder = (0, project_targets_1.isUsingApplicationBuilder)(project);
275
+ const sourceRoot = project.sourceRoot ?? (0, posix_1.join)(project.root, 'src');
276
+ return (0, schematics_1.chain)([
277
+ (0, schematics_1.schematic)('server', {
278
+ ...options,
279
+ skipInstall: true,
280
+ }),
281
+ ...(usingApplicationBuilder
282
+ ? [
283
+ updateApplicationBuilderWorkspaceConfigRule(sourceRoot, options, context),
284
+ updateApplicationBuilderTsConfigRule(options),
285
+ ]
286
+ : [
287
+ updateWebpackBuilderServerTsConfigRule(options),
288
+ updateWebpackBuilderWorkspaceConfigRule(sourceRoot, options),
289
+ ]),
290
+ addServerFile(sourceRoot, options, isStandalone),
291
+ addScriptsRule(options, usingApplicationBuilder),
292
+ addDependencies(options, usingApplicationBuilder),
293
+ ]);
294
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "plugins": {
3
+ "@tailwindcss/postcss": {}
4
+ }
5
+ }
@@ -5,5 +5,8 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
- import type { Rule } from '@angular-devkit/schematics';
9
- export default function (): Rule;
8
+ import { type Rule } from '@angular-devkit/schematics';
9
+ declare const _default: (options: {
10
+ project: string;
11
+ }) => Rule;
12
+ export default _default;