@schematics/angular 8.0.0-rc.4 → 8.0.0
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/collection.json +1 -1
- package/library/files/tsconfig.lib.json.template +1 -0
- package/library/index.js +5 -0
- package/migrations/update-8/differential-loading.js +35 -47
- package/migrations/update-8/drop-es6-polyfills.js +3 -3
- package/migrations/update-8/index.js +2 -2
- package/migrations/update-8/update-dependencies.d.ts +1 -0
- package/migrations/update-8/{update-builders.js → update-dependencies.js} +13 -2
- package/package.json +3 -3
- package/utility/ast-utils.js +2 -3
- package/utility/latest-versions.js +3 -3
- package/web-worker/index.js +4 -2
- package/migrations/update-8/update-builders.d.ts +0 -1
package/collection.json
CHANGED
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"description": "Generate a library project for Angular."
|
|
103
103
|
},
|
|
104
104
|
"webWorker": {
|
|
105
|
-
"aliases": ["web-worker"
|
|
105
|
+
"aliases": ["web-worker"],
|
|
106
106
|
"factory": "./web-worker",
|
|
107
107
|
"schema": "./web-worker/schema.json",
|
|
108
108
|
"description": "Create a Web Worker."
|
package/library/index.js
CHANGED
|
@@ -72,6 +72,11 @@ function addDependenciesToPackageJson() {
|
|
|
72
72
|
name: 'ng-packagr',
|
|
73
73
|
version: '^5.1.0',
|
|
74
74
|
},
|
|
75
|
+
{
|
|
76
|
+
type: dependencies_1.NodeDependencyType.Dev,
|
|
77
|
+
name: 'tsickle',
|
|
78
|
+
version: '^0.35.0',
|
|
79
|
+
},
|
|
75
80
|
{
|
|
76
81
|
type: dependencies_1.NodeDependencyType.Default,
|
|
77
82
|
name: 'tslib',
|
|
@@ -23,38 +23,9 @@ Firefox ESR
|
|
|
23
23
|
not dead
|
|
24
24
|
not IE 9-11 # For IE 9-11 support, remove 'not'.`;
|
|
25
25
|
function updateES5Projects() {
|
|
26
|
-
return (host) => {
|
|
27
|
-
const tsConfigPath = '/tsconfig.json';
|
|
28
|
-
const compilerOptions = getCompilerOptionsAstObject(host, tsConfigPath);
|
|
29
|
-
if (!compilerOptions) {
|
|
30
|
-
return host;
|
|
31
|
-
}
|
|
32
|
-
const recorder = host.beginUpdate(tsConfigPath);
|
|
33
|
-
const scriptTarget = json_utils_1.findPropertyInAstObject(compilerOptions, 'target');
|
|
34
|
-
if (!scriptTarget) {
|
|
35
|
-
json_utils_1.insertPropertyInAstObjectInOrder(recorder, compilerOptions, 'target', 'es2015', 4);
|
|
36
|
-
}
|
|
37
|
-
else if (scriptTarget.value !== 'es2015') {
|
|
38
|
-
const { start, end } = scriptTarget;
|
|
39
|
-
recorder.remove(start.offset, end.offset - start.offset);
|
|
40
|
-
recorder.insertLeft(start.offset, '"es2015"');
|
|
41
|
-
}
|
|
42
|
-
const scriptModule = json_utils_1.findPropertyInAstObject(compilerOptions, 'module');
|
|
43
|
-
if (!scriptModule) {
|
|
44
|
-
json_utils_1.insertPropertyInAstObjectInOrder(recorder, compilerOptions, 'module', 'esnext', 4);
|
|
45
|
-
}
|
|
46
|
-
else if (scriptModule.value !== 'esnext') {
|
|
47
|
-
const { start, end } = scriptModule;
|
|
48
|
-
recorder.remove(start.offset, end.offset - start.offset);
|
|
49
|
-
recorder.insertLeft(start.offset, '"esnext"');
|
|
50
|
-
}
|
|
51
|
-
host.commitUpdate(recorder);
|
|
52
|
-
return updateProjects;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
exports.updateES5Projects = updateES5Projects;
|
|
56
|
-
function updateProjects() {
|
|
57
26
|
return (tree) => {
|
|
27
|
+
// update workspace tsconfig
|
|
28
|
+
updateTsConfig(tree, '/tsconfig.json');
|
|
58
29
|
const angularConfigContent = tree.read('angular.json') || tree.read('.angular.json');
|
|
59
30
|
if (!angularConfigContent) {
|
|
60
31
|
return;
|
|
@@ -84,26 +55,15 @@ function updateProjects() {
|
|
|
84
55
|
// Skip projects who's build builder is not build-angular:browser
|
|
85
56
|
continue;
|
|
86
57
|
}
|
|
87
|
-
const tsConfigs = [];
|
|
88
58
|
const buildOptionsConfig = architect.build.options;
|
|
89
59
|
if (core_1.isJsonObject(buildOptionsConfig) && typeof buildOptionsConfig.tsConfig === 'string') {
|
|
90
|
-
|
|
60
|
+
updateTsConfig(tree, buildOptionsConfig.tsConfig);
|
|
91
61
|
}
|
|
92
62
|
const testConfig = architect.test;
|
|
93
63
|
if (core_1.isJsonObject(testConfig)
|
|
94
64
|
&& core_1.isJsonObject(testConfig.options)
|
|
95
65
|
&& typeof testConfig.options.tsConfig === 'string') {
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
for (const tsConfig of tsConfigs) {
|
|
99
|
-
const compilerOptions = getCompilerOptionsAstObject(tree, tsConfig);
|
|
100
|
-
if (!compilerOptions) {
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
const recorder = tree.beginUpdate(tsConfig);
|
|
104
|
-
json_utils_1.removePropertyInAstObject(recorder, compilerOptions, 'target');
|
|
105
|
-
json_utils_1.removePropertyInAstObject(recorder, compilerOptions, 'module');
|
|
106
|
-
tree.commitUpdate(recorder);
|
|
66
|
+
updateTsConfig(tree, testConfig.options.tsConfig);
|
|
107
67
|
}
|
|
108
68
|
const browserslistPath = core_1.join(core_1.normalize(project.root), 'browserslist');
|
|
109
69
|
if (typeof project.sourceRoot === 'string') {
|
|
@@ -131,8 +91,9 @@ function updateProjects() {
|
|
|
131
91
|
return tree;
|
|
132
92
|
};
|
|
133
93
|
}
|
|
134
|
-
|
|
135
|
-
|
|
94
|
+
exports.updateES5Projects = updateES5Projects;
|
|
95
|
+
function updateTsConfig(tree, tsConfigPath) {
|
|
96
|
+
const buffer = tree.read(tsConfigPath);
|
|
136
97
|
if (!buffer) {
|
|
137
98
|
return;
|
|
138
99
|
}
|
|
@@ -140,9 +101,36 @@ function getCompilerOptionsAstObject(host, tsConfigPath) {
|
|
|
140
101
|
if (tsCfgAst.kind !== 'object') {
|
|
141
102
|
return;
|
|
142
103
|
}
|
|
104
|
+
const configExtends = json_utils_1.findPropertyInAstObject(tsCfgAst, 'extends');
|
|
105
|
+
const isExtendedConfig = configExtends && configExtends.kind === 'string';
|
|
143
106
|
const compilerOptions = json_utils_1.findPropertyInAstObject(tsCfgAst, 'compilerOptions');
|
|
144
107
|
if (!compilerOptions || compilerOptions.kind !== 'object') {
|
|
145
108
|
return;
|
|
146
109
|
}
|
|
147
|
-
|
|
110
|
+
const recorder = tree.beginUpdate(tsConfigPath);
|
|
111
|
+
if (isExtendedConfig) {
|
|
112
|
+
json_utils_1.removePropertyInAstObject(recorder, compilerOptions, 'target');
|
|
113
|
+
json_utils_1.removePropertyInAstObject(recorder, compilerOptions, 'module');
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
const scriptTarget = json_utils_1.findPropertyInAstObject(compilerOptions, 'target');
|
|
117
|
+
if (!scriptTarget) {
|
|
118
|
+
json_utils_1.insertPropertyInAstObjectInOrder(recorder, compilerOptions, 'target', 'es2015', 4);
|
|
119
|
+
}
|
|
120
|
+
else if (scriptTarget.value !== 'es2015') {
|
|
121
|
+
const { start, end } = scriptTarget;
|
|
122
|
+
recorder.remove(start.offset, end.offset - start.offset);
|
|
123
|
+
recorder.insertLeft(start.offset, '"es2015"');
|
|
124
|
+
}
|
|
125
|
+
const scriptModule = json_utils_1.findPropertyInAstObject(compilerOptions, 'module');
|
|
126
|
+
if (!scriptModule) {
|
|
127
|
+
json_utils_1.insertPropertyInAstObjectInOrder(recorder, compilerOptions, 'module', 'esnext', 4);
|
|
128
|
+
}
|
|
129
|
+
else if (scriptModule.value !== 'esnext') {
|
|
130
|
+
const { start, end } = scriptModule;
|
|
131
|
+
recorder.remove(start.offset, end.offset - start.offset);
|
|
132
|
+
recorder.insertLeft(start.offset, '"esnext"');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
tree.commitUpdate(recorder);
|
|
148
136
|
}
|
|
@@ -64,11 +64,11 @@ function dropES2015PolyfillsFromFile(polyfillPath) {
|
|
|
64
64
|
if (!source) {
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
const content = source.toString().replace(/\r\n|\r/g, '\n');
|
|
67
|
+
const content = source.toString();
|
|
69
68
|
// Check if file is unmodified, if so then replace and return
|
|
70
69
|
const hash = crypto_1.createHash('md5');
|
|
71
|
-
hash
|
|
70
|
+
// normalize line endings to increase hash match chances
|
|
71
|
+
hash.update(content.replace(/\r\n|\r/g, '\n'));
|
|
72
72
|
const digest = hash.digest('hex');
|
|
73
73
|
if (knownPolyfillHashes.includes(digest)) {
|
|
74
74
|
// Replace with new project polyfills file
|
|
@@ -13,7 +13,7 @@ const codelyzer_5_1 = require("./codelyzer-5");
|
|
|
13
13
|
const differential_loading_1 = require("./differential-loading");
|
|
14
14
|
const drop_es6_polyfills_1 = require("./drop-es6-polyfills");
|
|
15
15
|
const remove_angular_http_1 = require("./remove-angular-http");
|
|
16
|
-
const
|
|
16
|
+
const update_dependencies_1 = require("./update-dependencies");
|
|
17
17
|
var update_lazy_module_paths_1 = require("./update-lazy-module-paths");
|
|
18
18
|
exports.updateLazyModulePaths = update_lazy_module_paths_1.updateLazyModulePaths;
|
|
19
19
|
function default_1() {
|
|
@@ -23,7 +23,7 @@ function default_1() {
|
|
|
23
23
|
codelyzer_5_1.updatePackageJson(),
|
|
24
24
|
drop_es6_polyfills_1.dropES2015Polyfills(),
|
|
25
25
|
differential_loading_1.updateES5Projects(),
|
|
26
|
-
|
|
26
|
+
update_dependencies_1.updateDependencies(),
|
|
27
27
|
remove_angular_http_1.removeAngularHttp(),
|
|
28
28
|
(tree, context) => {
|
|
29
29
|
const packageChanges = tree.actions.some(a => a.path.endsWith('/package.json'));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function updateDependencies(): (host: import("../../../../angular_devkit/schematics/src/tree/interface").Tree) => void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const dependencies_1 = require("../../utility/dependencies");
|
|
4
4
|
const latest_versions_1 = require("../../utility/latest-versions");
|
|
5
|
-
function
|
|
5
|
+
function updateDependencies() {
|
|
6
6
|
return (host) => {
|
|
7
7
|
let current = dependencies_1.getPackageJsonDependency(host, '@angular-devkit/build-angular');
|
|
8
8
|
if (current && current.version !== latest_versions_1.latestVersions.DevkitBuildAngular) {
|
|
@@ -31,6 +31,17 @@ function updateBuilders() {
|
|
|
31
31
|
overwrite: true,
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
+
// FIXME: change to ^2.3.2 as soon as it's released with the pr208 fix
|
|
35
|
+
const webAnimationsJsVersion = 'github:angular/web-animations-js#release_pr208';
|
|
36
|
+
current = dependencies_1.getPackageJsonDependency(host, 'web-animations-js');
|
|
37
|
+
if (current && current.version !== webAnimationsJsVersion) {
|
|
38
|
+
dependencies_1.addPackageJsonDependency(host, {
|
|
39
|
+
type: current.type,
|
|
40
|
+
name: 'web-animations-js',
|
|
41
|
+
version: webAnimationsJsVersion,
|
|
42
|
+
overwrite: true,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
34
45
|
};
|
|
35
46
|
}
|
|
36
|
-
exports.
|
|
47
|
+
exports.updateDependencies = updateDependencies;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schematics/angular",
|
|
3
|
-
"version": "8.0.0
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Schematics specific to Angular",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
],
|
|
15
15
|
"schematics": "./collection.json",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@angular-devkit/core": "8.0.0
|
|
18
|
-
"@angular-devkit/schematics": "8.0.0
|
|
17
|
+
"@angular-devkit/core": "8.0.0",
|
|
18
|
+
"@angular-devkit/schematics": "8.0.0"
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
package/utility/ast-utils.js
CHANGED
|
@@ -240,8 +240,7 @@ function getDecoratorMetadata(source, identifier, module) {
|
|
|
240
240
|
.filter(expr => {
|
|
241
241
|
if (expr.expression.kind == ts.SyntaxKind.Identifier) {
|
|
242
242
|
const id = expr.expression;
|
|
243
|
-
return id.
|
|
244
|
-
&& angularImports[id.getFullText(source)] === module;
|
|
243
|
+
return id.text == identifier && angularImports[id.text] === module;
|
|
245
244
|
}
|
|
246
245
|
else if (expr.expression.kind == ts.SyntaxKind.PropertyAccessExpression) {
|
|
247
246
|
// This covers foo.NgModule when importing * as foo.
|
|
@@ -251,7 +250,7 @@ function getDecoratorMetadata(source, identifier, module) {
|
|
|
251
250
|
return false;
|
|
252
251
|
}
|
|
253
252
|
const id = paExpr.name.text;
|
|
254
|
-
const moduleId = paExpr.expression.
|
|
253
|
+
const moduleId = paExpr.expression.text;
|
|
255
254
|
return id === identifier && (angularImports[moduleId + '.'] === module);
|
|
256
255
|
}
|
|
257
256
|
return false;
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.latestVersions = {
|
|
11
11
|
// These versions should be kept up to date with latest Angular peer dependencies.
|
|
12
|
-
Angular: '~8.0.0
|
|
12
|
+
Angular: '~8.0.0',
|
|
13
13
|
RxJs: '~6.4.0',
|
|
14
14
|
ZoneJs: '~0.9.1',
|
|
15
15
|
TypeScript: '~3.4.3',
|
|
16
16
|
TsLib: '^1.9.0',
|
|
17
17
|
// The versions below must be manually updated when making a new devkit release.
|
|
18
|
-
DevkitBuildAngular: '~0.800.0
|
|
19
|
-
DevkitBuildNgPackagr: '~0.800.0
|
|
18
|
+
DevkitBuildAngular: '~0.800.0',
|
|
19
|
+
DevkitBuildNgPackagr: '~0.800.0',
|
|
20
20
|
};
|
package/web-worker/index.js
CHANGED
|
@@ -49,9 +49,11 @@ function addSnippet(options) {
|
|
|
49
49
|
if (options.path === undefined) {
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
+
const fileRegExp = new RegExp(`^${options.name}.*\.ts`);
|
|
52
53
|
const siblingModules = host.getDir(options.path).subfiles
|
|
53
|
-
// Find all files that start with the same name, are ts files,
|
|
54
|
-
|
|
54
|
+
// Find all files that start with the same name, are ts files,
|
|
55
|
+
// and aren't spec or module files.
|
|
56
|
+
.filter(f => fileRegExp.test(f) && !/(module|spec)\.ts$/.test(f))
|
|
55
57
|
// Sort alphabetically for consistency.
|
|
56
58
|
.sort();
|
|
57
59
|
if (siblingModules.length === 0) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function updateBuilders(): (host: import("../../../../angular_devkit/schematics/src/tree/interface").Tree) => void;
|