@schematics/angular 15.0.0-next.1 → 15.0.0-next.2

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.
@@ -15,10 +15,10 @@ declare const require: {
15
15
  };
16
16
 
17
17
  // First, initialize the Angular testing environment.
18
- getTestBed().initTestEnvironment(
19
- BrowserDynamicTestingModule,
20
- platformBrowserDynamicTesting(),
21
- );
18
+ getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
19
+ errorOnUnknownElements: true,
20
+ errorOnUnknownProperties: true
21
+ });
22
22
 
23
23
  // Then we find all the tests.
24
24
  const context = require.context('./', true, /\.spec\.ts$/);
@@ -16,10 +16,10 @@ declare const require: {
16
16
  };
17
17
 
18
18
  // First, initialize the Angular testing environment.
19
- getTestBed().initTestEnvironment(
20
- BrowserDynamicTestingModule,
21
- platformBrowserDynamicTesting(),
22
- );
19
+ getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
20
+ errorOnUnknownElements: true,
21
+ errorOnUnknownProperties: true
22
+ });
23
23
 
24
24
  // Then we find all the tests.
25
25
  const context = require.context('./', true, /\.spec\.ts$/);
@@ -4,6 +4,16 @@
4
4
  "version": "15.0.0",
5
5
  "factory": "./update-15/remove-browserslist-config",
6
6
  "description": "Remove Browserslist configuration files that matches the Angular CLI default configuration."
7
+ },
8
+ "remove-platform-server-exports": {
9
+ "version": "15.0.0",
10
+ "factory": "./update-15/remove-platform-server-exports",
11
+ "description": "Remove exported `@angular/platform-server` `renderModule` method. The `renderModule` method is now exported by the Angular CLI."
12
+ },
13
+ "update-typescript-target": {
14
+ "version": "15.0.0",
15
+ "factory": "./update-15/update-typescript-target",
16
+ "description": "Update TypeScript compiler `target` and set `useDefineForClassFields`. These changes are for IDE purposes as TypeScript compiler options `target` and `useDefineForClassFields` are set to `ES2022` and `false` respectively by the Angular CLI. To control ECMA version and features use the Browerslist configuration."
7
17
  }
8
18
  }
9
19
  }
@@ -0,0 +1,9 @@
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.io/license
7
+ */
8
+ import { Rule } from '@angular-devkit/schematics';
9
+ export default function (): Rule;
@@ -0,0 +1,102 @@
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.io/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
+ const ts = __importStar(require("../../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
34
+ function* visit(directory) {
35
+ for (const path of directory.subfiles) {
36
+ if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
37
+ const entry = directory.file(path);
38
+ if (entry) {
39
+ const content = entry.content;
40
+ if (content.includes('@angular/platform-server') && content.includes('renderModule')) {
41
+ const source = ts.createSourceFile(entry.path, content.toString().replace(/^\uFEFF/, ''), ts.ScriptTarget.Latest, true);
42
+ yield source;
43
+ }
44
+ }
45
+ }
46
+ }
47
+ for (const path of directory.subdirs) {
48
+ if (path === 'node_modules' || path.startsWith('.')) {
49
+ continue;
50
+ }
51
+ yield* visit(directory.dir(path));
52
+ }
53
+ }
54
+ function default_1() {
55
+ return (tree) => {
56
+ for (const sourceFile of visit(tree.root)) {
57
+ let recorder;
58
+ let printer;
59
+ ts.forEachChild(sourceFile, function analyze(node) {
60
+ if (!(ts.isExportDeclaration(node) &&
61
+ node.moduleSpecifier &&
62
+ ts.isStringLiteral(node.moduleSpecifier) &&
63
+ node.moduleSpecifier.text === '@angular/platform-server' &&
64
+ node.exportClause &&
65
+ ts.isNamedExports(node.exportClause))) {
66
+ // Not a @angular/platform-server named export.
67
+ return;
68
+ }
69
+ const exportClause = node.exportClause;
70
+ const newElements = [];
71
+ for (const element of exportClause.elements) {
72
+ if (element.name.text !== 'renderModule') {
73
+ newElements.push(element);
74
+ }
75
+ }
76
+ if (newElements.length === exportClause.elements.length) {
77
+ // No changes
78
+ return;
79
+ }
80
+ recorder !== null && recorder !== void 0 ? recorder : (recorder = tree.beginUpdate(sourceFile.fileName));
81
+ if (newElements.length) {
82
+ // Update named exports as there are leftovers.
83
+ const newExportClause = ts.factory.updateNamedExports(exportClause, newElements);
84
+ printer !== null && printer !== void 0 ? printer : (printer = ts.createPrinter());
85
+ const fix = printer.printNode(ts.EmitHint.Unspecified, newExportClause, sourceFile);
86
+ const index = exportClause.getStart();
87
+ const length = exportClause.getWidth();
88
+ recorder.remove(index, length).insertLeft(index, fix);
89
+ }
90
+ else {
91
+ // Delete export as no exports remain.
92
+ recorder.remove(node.getStart(), node.getWidth());
93
+ }
94
+ ts.forEachChild(node, analyze);
95
+ });
96
+ if (recorder) {
97
+ tree.commitUpdate(recorder);
98
+ }
99
+ }
100
+ };
101
+ }
102
+ exports.default = default_1;
@@ -0,0 +1,9 @@
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.io/license
7
+ */
8
+ import { Rule } from '@angular-devkit/schematics';
9
+ export default function (): Rule;
@@ -0,0 +1,68 @@
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.io/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ const json_file_1 = require("../../utility/json-file");
11
+ const workspace_1 = require("../../utility/workspace");
12
+ const workspace_models_1 = require("../../utility/workspace-models");
13
+ function default_1() {
14
+ return async (host) => {
15
+ // Workspace level tsconfig
16
+ updateTarget(host, 'tsconfig.json');
17
+ const workspace = await (0, workspace_1.getWorkspace)(host);
18
+ // Find all tsconfig which are refereces used by builders
19
+ for (const [, project] of workspace.projects) {
20
+ for (const [, target] of project.targets) {
21
+ // Update all other known CLI builders that use a tsconfig
22
+ const tsConfigs = [target.options || {}, ...Object.values(target.configurations || {})]
23
+ .filter((opt) => typeof (opt === null || opt === void 0 ? void 0 : opt.tsConfig) === 'string')
24
+ .map((opt) => opt.tsConfig);
25
+ const uniqueTsConfigs = [...new Set(tsConfigs)];
26
+ if (uniqueTsConfigs.length < 1) {
27
+ continue;
28
+ }
29
+ switch (target.builder) {
30
+ case workspace_models_1.Builders.Server:
31
+ case workspace_models_1.Builders.Karma:
32
+ case workspace_models_1.Builders.Browser:
33
+ case workspace_models_1.Builders.NgPackagr:
34
+ for (const tsConfig of uniqueTsConfigs) {
35
+ removeOrUpdateTarget(host, tsConfig);
36
+ }
37
+ break;
38
+ }
39
+ }
40
+ }
41
+ };
42
+ }
43
+ exports.default = default_1;
44
+ function removeOrUpdateTarget(host, tsConfigPath) {
45
+ const json = new json_file_1.JSONFile(host, tsConfigPath);
46
+ if (typeof json.get(['extends']) === 'string') {
47
+ json.remove(['compilerOptions', 'target']);
48
+ }
49
+ else {
50
+ updateTarget(host, tsConfigPath);
51
+ }
52
+ }
53
+ const ESNEXT_ES2022_REGEXP = /^es(?:next|2022)$/i;
54
+ function updateTarget(host, tsConfigPath) {
55
+ const json = new json_file_1.JSONFile(host, tsConfigPath);
56
+ const jsonPath = ['compilerOptions'];
57
+ const compilerOptions = json.get(jsonPath);
58
+ if (compilerOptions && typeof compilerOptions === 'object') {
59
+ const { target } = compilerOptions;
60
+ if (typeof target === 'string' && !ESNEXT_ES2022_REGEXP.test(target)) {
61
+ json.modify(jsonPath, {
62
+ ...compilerOptions,
63
+ 'target': 'ES2022',
64
+ 'useDefineForClassFields': false,
65
+ });
66
+ }
67
+ }
68
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "15.0.0-next.1",
3
+ "version": "15.0.0-next.2",
4
4
  "description": "Schematics specific to Angular",
5
5
  "homepage": "https://github.com/angular/angular-cli",
6
6
  "keywords": [
@@ -23,8 +23,8 @@
23
23
  },
24
24
  "schematics": "./collection.json",
25
25
  "dependencies": {
26
- "@angular-devkit/core": "15.0.0-next.1",
27
- "@angular-devkit/schematics": "15.0.0-next.1",
26
+ "@angular-devkit/core": "15.0.0-next.2",
27
+ "@angular-devkit/schematics": "15.0.0-next.2",
28
28
  "jsonc-parser": "3.2.0"
29
29
  },
30
30
  "repository": {
@@ -21,4 +21,3 @@ if (environment.production) {
21
21
  }
22
22
 
23
23
  export { <%= rootModuleClassName %> } from './app/<%= stripTsExtension(rootModuleFileName) %>';
24
- export { renderModule } from '@angular/platform-server';
@@ -16,10 +16,11 @@
16
16
  "experimentalDecorators": true,
17
17
  "moduleResolution": "node",
18
18
  "importHelpers": true,
19
- "target": "es2020",
20
- "module": "es2020",
19
+ "target": "ES2022",
20
+ "module": "ES2022",
21
+ "useDefineForClassFields": false,
21
22
  "lib": [
22
- "es2020",
23
+ "ES2022",
23
24
  "dom"
24
25
  ]
25
26
  },