@schematics/angular 15.0.0-next.1 → 15.0.0-next.3
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/application/files/src/main.ts.template +2 -6
- package/application/files/tsconfig.app.json.template +1 -2
- package/application/files/tsconfig.spec.json.template +0 -4
- package/application/index.js +3 -10
- package/library/files/tsconfig.lib.json.template +0 -1
- package/library/files/tsconfig.spec.json.template +0 -3
- package/library/index.js +1 -1
- package/migrations/migration-collection.json +20 -0
- package/migrations/update-15/remove-platform-server-exports.d.ts +9 -0
- package/migrations/update-15/remove-platform-server-exports.js +102 -0
- package/migrations/update-15/update-karma-main-file.d.ts +9 -0
- package/migrations/update-15/update-karma-main-file.js +106 -0
- package/migrations/update-15/update-typescript-target.d.ts +9 -0
- package/migrations/update-15/update-typescript-target.js +68 -0
- package/migrations/update-15/update-workspace-config.d.ts +9 -0
- package/migrations/update-15/update-workspace-config.js +26 -0
- package/package.json +3 -3
- package/service-worker/index.js +13 -33
- package/universal/files/src/__main@stripTsExtension__.ts.template +1 -9
- package/utility/ast-utils.d.ts +0 -6
- package/utility/ast-utils.js +1 -38
- package/workspace/files/tsconfig.json.template +4 -3
- package/application/files/src/environments/environment.prod.ts.template +0 -3
- package/application/files/src/environments/environment.ts.template +0 -16
- package/application/files/src/polyfills.ts.template +0 -53
- package/application/files/src/test.ts.template +0 -26
- package/library/files/src/test.ts.template +0 -27
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
<% if(!!viewEncapsulation) { %>import { ViewEncapsulation } from '@angular/core';<% }%>
|
|
2
2
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
3
3
|
|
|
4
4
|
import { AppModule } from './app/app.module';
|
|
5
|
-
import { environment } from './environments/environment';
|
|
6
5
|
|
|
7
|
-
if (environment.production) {
|
|
8
|
-
enableProdMode();
|
|
9
|
-
}
|
|
10
6
|
<% if(!!viewEncapsulation) { %>
|
|
11
7
|
platformBrowserDynamic().bootstrapModule(AppModule, {
|
|
12
8
|
defaultEncapsulation: ViewEncapsulation.<%= viewEncapsulation %>
|
|
@@ -15,4 +11,4 @@ platformBrowserDynamic().bootstrapModule(AppModule, {
|
|
|
15
11
|
<% } else { %>
|
|
16
12
|
platformBrowserDynamic().bootstrapModule(AppModule)
|
|
17
13
|
.catch(err => console.error(err));
|
|
18
|
-
<% } %>
|
|
14
|
+
<% } %>
|
package/application/index.js
CHANGED
|
@@ -127,7 +127,7 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
|
|
|
127
127
|
outputPath: `dist/${folderName}`,
|
|
128
128
|
index: `${sourceRoot}/index.html`,
|
|
129
129
|
main: `${sourceRoot}/main.ts`,
|
|
130
|
-
polyfills:
|
|
130
|
+
polyfills: ['zone.js'],
|
|
131
131
|
tsConfig: `${projectRoot}tsconfig.app.json`,
|
|
132
132
|
inlineStyleLanguage,
|
|
133
133
|
assets: [`${sourceRoot}/favicon.ico`, `${sourceRoot}/assets`],
|
|
@@ -137,12 +137,6 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
|
|
|
137
137
|
configurations: {
|
|
138
138
|
production: {
|
|
139
139
|
budgets,
|
|
140
|
-
fileReplacements: [
|
|
141
|
-
{
|
|
142
|
-
replace: `${sourceRoot}/environments/environment.ts`,
|
|
143
|
-
with: `${sourceRoot}/environments/environment.prod.ts`,
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
140
|
outputHashing: 'all',
|
|
147
141
|
},
|
|
148
142
|
development: {
|
|
@@ -179,8 +173,7 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
|
|
|
179
173
|
: {
|
|
180
174
|
builder: workspace_models_1.Builders.Karma,
|
|
181
175
|
options: {
|
|
182
|
-
|
|
183
|
-
polyfills: `${sourceRoot}/polyfills.ts`,
|
|
176
|
+
polyfills: ['zone.js', 'zone.js/testing'],
|
|
184
177
|
tsConfig: `${projectRoot}tsconfig.spec.json`,
|
|
185
178
|
karmaConfig: `${projectRoot}karma.conf.js`,
|
|
186
179
|
inlineStyleLanguage,
|
|
@@ -199,7 +192,7 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
|
|
|
199
192
|
});
|
|
200
193
|
}
|
|
201
194
|
function minimalPathFilter(path) {
|
|
202
|
-
const toRemoveList = /(
|
|
195
|
+
const toRemoveList = /(tsconfig.spec.json|karma.conf.js).template$/;
|
|
203
196
|
return !toRemoveList.test(path);
|
|
204
197
|
}
|
|
205
198
|
function default_1(options) {
|
package/library/index.js
CHANGED
|
@@ -86,8 +86,8 @@ function addLibToWorkspaceFile(options, projectRoot, projectName) {
|
|
|
86
86
|
test: {
|
|
87
87
|
builder: workspace_models_1.Builders.Karma,
|
|
88
88
|
options: {
|
|
89
|
-
main: `${projectRoot}/src/test.ts`,
|
|
90
89
|
tsConfig: `${projectRoot}/tsconfig.spec.json`,
|
|
90
|
+
polyfills: ['zone.js', 'zone.js/testing'],
|
|
91
91
|
karmaConfig: `${projectRoot}/karma.conf.js`,
|
|
92
92
|
},
|
|
93
93
|
},
|
|
@@ -4,6 +4,26 @@
|
|
|
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."
|
|
17
|
+
},
|
|
18
|
+
"update-workspace-config": {
|
|
19
|
+
"version": "15.0.0",
|
|
20
|
+
"factory": "./update-15/update-workspace-config",
|
|
21
|
+
"description": "Remove options from 'angular.json' that are no longer supported by the official builders."
|
|
22
|
+
},
|
|
23
|
+
"update-karma-main-file": {
|
|
24
|
+
"version": "15.0.0",
|
|
25
|
+
"factory": "./update-15/update-karma-main-file",
|
|
26
|
+
"description": "Remove no longer needed require calls in Karma builder main file."
|
|
7
27
|
}
|
|
8
28
|
}
|
|
9
29
|
}
|
|
@@ -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,106 @@
|
|
|
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
|
+
const utility_1 = require("../../utility");
|
|
35
|
+
const workspace_1 = require("../../utility/workspace");
|
|
36
|
+
const workspace_models_1 = require("../../utility/workspace-models");
|
|
37
|
+
function default_1() {
|
|
38
|
+
return async (host) => {
|
|
39
|
+
for (const file of await findTestMainFiles(host)) {
|
|
40
|
+
updateTestFile(host, file);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
exports.default = default_1;
|
|
45
|
+
async function findTestMainFiles(host) {
|
|
46
|
+
const testFiles = new Set();
|
|
47
|
+
const workspace = await (0, utility_1.readWorkspace)(host);
|
|
48
|
+
// find all test.ts files.
|
|
49
|
+
for (const project of workspace.projects.values()) {
|
|
50
|
+
for (const target of project.targets.values()) {
|
|
51
|
+
if (target.builder !== workspace_models_1.Builders.Karma) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
for (const [, options] of (0, workspace_1.allTargetOptions)(target)) {
|
|
55
|
+
if (typeof options.main === 'string') {
|
|
56
|
+
testFiles.add(options.main);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return testFiles;
|
|
62
|
+
}
|
|
63
|
+
function updateTestFile(host, file) {
|
|
64
|
+
const content = host.readText(file);
|
|
65
|
+
if (!content.includes('require.context')) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const sourceFile = ts.createSourceFile(file, content.replace(/^\uFEFF/, ''), ts.ScriptTarget.Latest, true);
|
|
69
|
+
const usedVariableNames = new Set();
|
|
70
|
+
const recorder = host.beginUpdate(sourceFile.fileName);
|
|
71
|
+
ts.forEachChild(sourceFile, (node) => {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
if (ts.isVariableStatement(node)) {
|
|
74
|
+
const variableDeclaration = node.declarationList.declarations[0];
|
|
75
|
+
if ((_a = ts.getModifiers(node)) === null || _a === void 0 ? void 0 : _a.some((m) => m.kind === ts.SyntaxKind.DeclareKeyword)) {
|
|
76
|
+
// `declare const require`
|
|
77
|
+
if (variableDeclaration.name.getText() !== 'require') {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// `const context = require.context('./', true, /\.spec\.ts$/);`
|
|
83
|
+
if (!((_b = variableDeclaration.initializer) === null || _b === void 0 ? void 0 : _b.getText().startsWith('require.context'))) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// add variable name as used.
|
|
87
|
+
usedVariableNames.add(variableDeclaration.name.getText());
|
|
88
|
+
}
|
|
89
|
+
// Delete node.
|
|
90
|
+
recorder.remove(node.getFullStart(), node.getFullWidth());
|
|
91
|
+
}
|
|
92
|
+
if (usedVariableNames.size &&
|
|
93
|
+
ts.isExpressionStatement(node) && // context.keys().map(context);
|
|
94
|
+
ts.isCallExpression(node.expression) && // context.keys().map(context);
|
|
95
|
+
ts.isPropertyAccessExpression(node.expression.expression) && // context.keys().map
|
|
96
|
+
ts.isCallExpression(node.expression.expression.expression) && // context.keys()
|
|
97
|
+
ts.isPropertyAccessExpression(node.expression.expression.expression.expression) && // context.keys
|
|
98
|
+
ts.isIdentifier(node.expression.expression.expression.expression.expression) && // context
|
|
99
|
+
usedVariableNames.has(node.expression.expression.expression.expression.expression.getText())) {
|
|
100
|
+
// `context.keys().map(context);`
|
|
101
|
+
// `context.keys().forEach(context);`
|
|
102
|
+
recorder.remove(node.getFullStart(), node.getFullWidth());
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
host.commitUpdate(recorder);
|
|
106
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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,26 @@
|
|
|
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 workspace_1 = require("../../utility/workspace");
|
|
11
|
+
const workspace_models_1 = require("../../utility/workspace-models");
|
|
12
|
+
function default_1() {
|
|
13
|
+
return (0, workspace_1.updateWorkspace)((workspace) => {
|
|
14
|
+
for (const project of workspace.projects.values()) {
|
|
15
|
+
for (const target of project.targets.values()) {
|
|
16
|
+
if (target.builder !== workspace_models_1.Builders.Server) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
for (const [, options] of (0, workspace_1.allTargetOptions)(target)) {
|
|
20
|
+
delete options.bundleDependencies;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.default = default_1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schematics/angular",
|
|
3
|
-
"version": "15.0.0-next.
|
|
3
|
+
"version": "15.0.0-next.3",
|
|
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.
|
|
27
|
-
"@angular-devkit/schematics": "15.0.0-next.
|
|
26
|
+
"@angular-devkit/core": "15.0.0-next.3",
|
|
27
|
+
"@angular-devkit/schematics": "15.0.0-next.3",
|
|
28
28
|
"jsonc-parser": "3.2.0"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
package/service-worker/index.js
CHANGED
|
@@ -62,47 +62,18 @@ function updateAppModule(mainPath) {
|
|
|
62
62
|
context.logger.debug('Updating appmodule');
|
|
63
63
|
const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, mainPath);
|
|
64
64
|
context.logger.debug(`module path: ${modulePath}`);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
let importModule = 'ServiceWorkerModule';
|
|
68
|
-
let importPath = '@angular/service-worker';
|
|
69
|
-
if (!(0, ast_utils_1.isImported)(moduleSource, importModule, importPath)) {
|
|
70
|
-
const change = (0, ast_utils_1.insertImport)(moduleSource, modulePath, importModule, importPath);
|
|
71
|
-
if (change) {
|
|
72
|
-
const recorder = host.beginUpdate(modulePath);
|
|
73
|
-
(0, change_1.applyToUpdateRecorder)(recorder, [change]);
|
|
74
|
-
host.commitUpdate(recorder);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// add import for environments
|
|
78
|
-
// import { environment } from '../environments/environment';
|
|
79
|
-
moduleSource = getTsSourceFile(host, modulePath);
|
|
80
|
-
const environmentExportName = (0, ast_utils_1.getEnvironmentExportName)(moduleSource);
|
|
81
|
-
// if environemnt import already exists then use the found one
|
|
82
|
-
// otherwise use the default name
|
|
83
|
-
importModule = environmentExportName || 'environment';
|
|
84
|
-
// TODO: dynamically find environments relative path
|
|
85
|
-
importPath = '../environments/environment';
|
|
86
|
-
if (!environmentExportName) {
|
|
87
|
-
// if environment import was not found then insert the new one
|
|
88
|
-
// with default path and default export name
|
|
89
|
-
const change = (0, ast_utils_1.insertImport)(moduleSource, modulePath, importModule, importPath);
|
|
90
|
-
if (change) {
|
|
91
|
-
const recorder = host.beginUpdate(modulePath);
|
|
92
|
-
(0, change_1.applyToUpdateRecorder)(recorder, [change]);
|
|
93
|
-
host.commitUpdate(recorder);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
65
|
+
addImport(host, modulePath, 'ServiceWorkerModule', '@angular/service-worker');
|
|
66
|
+
addImport(host, modulePath, 'isDevMode', '@angular/core');
|
|
96
67
|
// register SW in application module
|
|
97
68
|
const importText = core_1.tags.stripIndent `
|
|
98
69
|
ServiceWorkerModule.register('ngsw-worker.js', {
|
|
99
|
-
enabled:
|
|
70
|
+
enabled: !isDevMode(),
|
|
100
71
|
// Register the ServiceWorker as soon as the application is stable
|
|
101
72
|
// or after 30 seconds (whichever comes first).
|
|
102
73
|
registrationStrategy: 'registerWhenStable:30000'
|
|
103
74
|
})
|
|
104
75
|
`;
|
|
105
|
-
moduleSource = getTsSourceFile(host, modulePath);
|
|
76
|
+
const moduleSource = getTsSourceFile(host, modulePath);
|
|
106
77
|
const metadataChanges = (0, ast_utils_1.addSymbolToNgModuleMetadata)(moduleSource, modulePath, 'imports', importText);
|
|
107
78
|
if (metadataChanges) {
|
|
108
79
|
const recorder = host.beginUpdate(modulePath);
|
|
@@ -157,3 +128,12 @@ function default_1(options) {
|
|
|
157
128
|
};
|
|
158
129
|
}
|
|
159
130
|
exports.default = default_1;
|
|
131
|
+
function addImport(host, filePath, symbolName, moduleName) {
|
|
132
|
+
const moduleSource = getTsSourceFile(host, filePath);
|
|
133
|
+
const change = (0, ast_utils_1.insertImport)(moduleSource, filePath, symbolName, moduleName);
|
|
134
|
+
if (change) {
|
|
135
|
+
const recorder = host.beginUpdate(filePath);
|
|
136
|
+
(0, change_1.applyToUpdateRecorder)(recorder, [change]);
|
|
137
|
+
host.commitUpdate(recorder);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -12,13 +12,5 @@ import '@angular/platform-server/init';
|
|
|
12
12
|
*/
|
|
13
13
|
import '@angular/localize/init';
|
|
14
14
|
|
|
15
|
-
<% } %>
|
|
16
|
-
|
|
17
|
-
import { environment } from './environments/environment';
|
|
18
|
-
|
|
19
|
-
if (environment.production) {
|
|
20
|
-
enableProdMode();
|
|
21
|
-
}
|
|
22
|
-
|
|
15
|
+
<% } %>
|
|
23
16
|
export { <%= rootModuleClassName %> } from './app/<%= stripTsExtension(rootModuleFileName) %>';
|
|
24
|
-
export { renderModule } from '@angular/platform-server';
|
package/utility/ast-utils.d.ts
CHANGED
|
@@ -86,12 +86,6 @@ export declare function addBootstrapToModule(source: ts.SourceFile, modulePath:
|
|
|
86
86
|
* Determine if an import already exists.
|
|
87
87
|
*/
|
|
88
88
|
export declare function isImported(source: ts.SourceFile, classifiedName: string, importPath: string): boolean;
|
|
89
|
-
/**
|
|
90
|
-
* This function returns the name of the environment export
|
|
91
|
-
* whether this export is aliased or not. If the environment file
|
|
92
|
-
* is not imported, then it will return `null`.
|
|
93
|
-
*/
|
|
94
|
-
export declare function getEnvironmentExportName(source: ts.SourceFile): string | null;
|
|
95
89
|
/**
|
|
96
90
|
* Returns the RouterModule declaration from NgModule metadata, if any.
|
|
97
91
|
*/
|
package/utility/ast-utils.js
CHANGED
|
@@ -30,7 +30,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.addRouteDeclarationToModule = exports.getRouterModuleDeclaration = exports.
|
|
33
|
+
exports.addRouteDeclarationToModule = exports.getRouterModuleDeclaration = exports.isImported = exports.addBootstrapToModule = exports.addExportToModule = exports.addProviderToModule = exports.addImportToModule = exports.addDeclarationToModule = exports.addSymbolToNgModuleMetadata = exports.getMetadataField = exports.getDecoratorMetadata = exports.insertAfterLastOccurrence = exports.findNode = exports.getSourceNodes = exports.findNodes = exports.insertImport = void 0;
|
|
34
34
|
const core_1 = require("@angular-devkit/core");
|
|
35
35
|
const ts = __importStar(require("../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
|
36
36
|
const change_1 = require("./change");
|
|
@@ -423,43 +423,6 @@ function isImported(source, classifiedName, importPath) {
|
|
|
423
423
|
return matchingNodes.length > 0;
|
|
424
424
|
}
|
|
425
425
|
exports.isImported = isImported;
|
|
426
|
-
/**
|
|
427
|
-
* This function returns the name of the environment export
|
|
428
|
-
* whether this export is aliased or not. If the environment file
|
|
429
|
-
* is not imported, then it will return `null`.
|
|
430
|
-
*/
|
|
431
|
-
function getEnvironmentExportName(source) {
|
|
432
|
-
// Initial value is `null` as we don't know yet if the user
|
|
433
|
-
// has imported `environment` into the root module or not.
|
|
434
|
-
let environmentExportName = null;
|
|
435
|
-
const allNodes = getSourceNodes(source);
|
|
436
|
-
allNodes
|
|
437
|
-
.filter(ts.isImportDeclaration)
|
|
438
|
-
.filter((declaration) => declaration.moduleSpecifier.kind === ts.SyntaxKind.StringLiteral &&
|
|
439
|
-
declaration.importClause !== undefined)
|
|
440
|
-
.map((declaration) =>
|
|
441
|
-
// If `importClause` property is defined then the first
|
|
442
|
-
// child will be `NamedImports` object (or `namedBindings`).
|
|
443
|
-
declaration.importClause.getChildAt(0))
|
|
444
|
-
// Find those `NamedImports` object that contains `environment` keyword
|
|
445
|
-
// in its text. E.g. `{ environment as env }`.
|
|
446
|
-
.filter(ts.isNamedImports)
|
|
447
|
-
.filter((namedImports) => namedImports.getText().includes('environment'))
|
|
448
|
-
.forEach((namedImports) => {
|
|
449
|
-
for (const specifier of namedImports.elements) {
|
|
450
|
-
// `propertyName` is defined if the specifier
|
|
451
|
-
// has an aliased import.
|
|
452
|
-
const name = specifier.propertyName || specifier.name;
|
|
453
|
-
// Find specifier that contains `environment` keyword in its text.
|
|
454
|
-
// Whether it's `environment` or `environment as env`.
|
|
455
|
-
if (name.text.includes('environment')) {
|
|
456
|
-
environmentExportName = specifier.name.text;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
});
|
|
460
|
-
return environmentExportName;
|
|
461
|
-
}
|
|
462
|
-
exports.getEnvironmentExportName = getEnvironmentExportName;
|
|
463
426
|
/**
|
|
464
427
|
* Returns the RouterModule declaration from NgModule metadata, if any.
|
|
465
428
|
*/
|
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
"experimentalDecorators": true,
|
|
17
17
|
"moduleResolution": "node",
|
|
18
18
|
"importHelpers": true,
|
|
19
|
-
"target": "
|
|
20
|
-
"module": "
|
|
19
|
+
"target": "ES2022",
|
|
20
|
+
"module": "ES2022",
|
|
21
|
+
"useDefineForClassFields": false,
|
|
21
22
|
"lib": [
|
|
22
|
-
"
|
|
23
|
+
"ES2022",
|
|
23
24
|
"dom"
|
|
24
25
|
]
|
|
25
26
|
},
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// This file can be replaced during build by using the `fileReplacements` array.
|
|
2
|
-
// `ng build` replaces `environment.ts` with `environment.prod.ts`.
|
|
3
|
-
// The list of file replacements can be found in `angular.json`.
|
|
4
|
-
|
|
5
|
-
export const environment = {
|
|
6
|
-
production: false
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
* For easier debugging in development mode, you can import the following file
|
|
11
|
-
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
|
|
12
|
-
*
|
|
13
|
-
* This import should be commented out in production mode because it will have a negative impact
|
|
14
|
-
* on performance if an error is thrown.
|
|
15
|
-
*/
|
|
16
|
-
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file includes polyfills needed by Angular and is loaded before the app.
|
|
3
|
-
* You can add your own extra polyfills to this file.
|
|
4
|
-
*
|
|
5
|
-
* This file is divided into 2 sections:
|
|
6
|
-
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
|
|
7
|
-
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
|
|
8
|
-
* file.
|
|
9
|
-
*
|
|
10
|
-
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
|
|
11
|
-
* automatically update themselves. This includes recent versions of Safari, Chrome (including
|
|
12
|
-
* Opera), Edge on the desktop, and iOS and Chrome on mobile.
|
|
13
|
-
*
|
|
14
|
-
* Learn more in https://angular.io/guide/browser-support
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/***************************************************************************************************
|
|
18
|
-
* BROWSER POLYFILLS
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* By default, zone.js will patch all possible macroTask and DomEvents
|
|
23
|
-
* user can disable parts of macroTask/DomEvents patch by setting following flags
|
|
24
|
-
* because those flags need to be set before `zone.js` being loaded, and webpack
|
|
25
|
-
* will put import in the top of bundle, so user need to create a separate file
|
|
26
|
-
* in this directory (for example: zone-flags.ts), and put the following flags
|
|
27
|
-
* into that file, and then add the following code before importing zone.js.
|
|
28
|
-
* import './zone-flags';
|
|
29
|
-
*
|
|
30
|
-
* The flags allowed in zone-flags.ts are listed here.
|
|
31
|
-
*
|
|
32
|
-
* The following flags will work for all browsers.
|
|
33
|
-
*
|
|
34
|
-
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
|
|
35
|
-
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
|
|
36
|
-
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
|
|
37
|
-
*
|
|
38
|
-
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
|
|
39
|
-
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
|
40
|
-
*
|
|
41
|
-
* (window as any).__Zone_enable_cross_context_check = true;
|
|
42
|
-
*
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
/***************************************************************************************************
|
|
46
|
-
* Zone JS is required by default for Angular itself.
|
|
47
|
-
*/
|
|
48
|
-
import 'zone.js'; // Included with Angular CLI.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/***************************************************************************************************
|
|
52
|
-
* APPLICATION IMPORTS
|
|
53
|
-
*/
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
|
2
|
-
|
|
3
|
-
import 'zone.js/testing';
|
|
4
|
-
import { getTestBed } from '@angular/core/testing';
|
|
5
|
-
import {
|
|
6
|
-
BrowserDynamicTestingModule,
|
|
7
|
-
platformBrowserDynamicTesting
|
|
8
|
-
} from '@angular/platform-browser-dynamic/testing';
|
|
9
|
-
|
|
10
|
-
declare const require: {
|
|
11
|
-
context(path: string, deep?: boolean, filter?: RegExp): {
|
|
12
|
-
<T>(id: string): T;
|
|
13
|
-
keys(): string[];
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// First, initialize the Angular testing environment.
|
|
18
|
-
getTestBed().initTestEnvironment(
|
|
19
|
-
BrowserDynamicTestingModule,
|
|
20
|
-
platformBrowserDynamicTesting(),
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
// Then we find all the tests.
|
|
24
|
-
const context = require.context('./', true, /\.spec\.ts$/);
|
|
25
|
-
// And load the modules.
|
|
26
|
-
context.keys().forEach(context);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
|
2
|
-
|
|
3
|
-
import 'zone.js';
|
|
4
|
-
import 'zone.js/testing';
|
|
5
|
-
import { getTestBed } from '@angular/core/testing';
|
|
6
|
-
import {
|
|
7
|
-
BrowserDynamicTestingModule,
|
|
8
|
-
platformBrowserDynamicTesting
|
|
9
|
-
} from '@angular/platform-browser-dynamic/testing';
|
|
10
|
-
|
|
11
|
-
declare const require: {
|
|
12
|
-
context(path: string, deep?: boolean, filter?: RegExp): {
|
|
13
|
-
<T>(id: string): T;
|
|
14
|
-
keys(): string[];
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// First, initialize the Angular testing environment.
|
|
19
|
-
getTestBed().initTestEnvironment(
|
|
20
|
-
BrowserDynamicTestingModule,
|
|
21
|
-
platformBrowserDynamicTesting(),
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
// Then we find all the tests.
|
|
25
|
-
const context = require.context('./', true, /\.spec\.ts$/);
|
|
26
|
-
// And load the modules.
|
|
27
|
-
context.keys().forEach(context);
|