@schematics/angular 8.0.0-rc.4 → 8.0.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.
@@ -137,6 +137,7 @@ function addAppToWorkspaceFile(options, appDir) {
137
137
  main: `${sourceRoot}/main.ts`,
138
138
  polyfills: `${sourceRoot}/polyfills.ts`,
139
139
  tsConfig: `${projectRoot}tsconfig.app.json`,
140
+ aot: !!options.enableIvy,
140
141
  assets: [
141
142
  `${sourceRoot}/favicon.ico`,
142
143
  `${sourceRoot}/assets`,
@@ -203,7 +204,7 @@ function addAppToWorkspaceFile(options, appDir) {
203
204
  scripts: [],
204
205
  },
205
206
  },
206
- lint: {
207
+ lint: options.minimal ? undefined : {
207
208
  builder: workspace_models_1.Builders.TsLint,
208
209
  options: {
209
210
  tsConfig: [
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", "worker"],
105
+ "aliases": ["web-worker"],
106
106
  "factory": "./web-worker",
107
107
  "schema": "./web-worker/schema.json",
108
108
  "description": "Create a Web Worker."
@@ -12,6 +12,7 @@
12
12
  ]
13
13
  },
14
14
  "angularCompilerOptions": {
15
+ "annotateForClosureCompiler": true,
15
16
  "skipTemplateCodegen": true,
16
17
  "strictMetadataEmit": true,
17
18
  "fullTemplateTypeCheck": true,
package/library/index.js CHANGED
@@ -70,7 +70,12 @@ function addDependenciesToPackageJson() {
70
70
  {
71
71
  type: dependencies_1.NodeDependencyType.Dev,
72
72
  name: 'ng-packagr',
73
- version: '^5.1.0',
73
+ version: latest_versions_1.latestVersions.ngPackagr,
74
+ },
75
+ {
76
+ type: dependencies_1.NodeDependencyType.Dev,
77
+ name: 'tsickle',
78
+ version: latest_versions_1.latestVersions.tsickle,
74
79
  },
75
80
  {
76
81
  type: dependencies_1.NodeDependencyType.Default,
@@ -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,55 +55,35 @@ 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
- tsConfigs.push(buildOptionsConfig.tsConfig);
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
- tsConfigs.push(testConfig.options.tsConfig);
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
- if (typeof project.sourceRoot === 'string') {
110
- // Move the CLI 7 style browserlist to root if it's there.
111
- const srcBrowsersList = core_1.join(core_1.normalize(project.sourceRoot), 'browserslist');
112
- if (tree.exists(srcBrowsersList) && !tree.exists(browserslistPath)) {
113
- // TODO: use rename instead.
114
- // This is a hacky workaround. We should be able to just rename it.
115
- // On unit tests the rename works fine but on real projects it fails with
116
- // ERROR! browserslist does not exist..
117
- // This seems to happen because we are both renaming and then commiting an update.
118
- // But it's fine if we read/create/delete. There's a bug somewhere.
119
- // tree.rename(srcBrowsersList, browserslistPath);
120
- const content = tree.read(srcBrowsersList);
121
- if (content) {
122
- tree.create(browserslistPath, content);
123
- tree.delete(srcBrowsersList);
124
- }
125
- }
69
+ // Move the CLI 7 style browserlist to root if it's there.
70
+ const sourceRoot = project.sourceRoot === 'string'
71
+ ? project.sourceRoot
72
+ : core_1.join(core_1.normalize(project.root), 'src');
73
+ const srcBrowsersList = core_1.join(core_1.normalize(sourceRoot), 'browserslist');
74
+ if (tree.exists(srcBrowsersList)) {
75
+ tree.rename(srcBrowsersList, browserslistPath);
126
76
  }
127
- if (!tree.exists(browserslistPath)) {
77
+ else if (!tree.exists(browserslistPath)) {
128
78
  tree.create(browserslistPath, browserslistContent);
129
79
  }
130
80
  }
131
81
  return tree;
132
82
  };
133
83
  }
134
- function getCompilerOptionsAstObject(host, tsConfigPath) {
135
- const buffer = host.read(tsConfigPath);
84
+ exports.updateES5Projects = updateES5Projects;
85
+ function updateTsConfig(tree, tsConfigPath) {
86
+ const buffer = tree.read(tsConfigPath);
136
87
  if (!buffer) {
137
88
  return;
138
89
  }
@@ -140,9 +91,46 @@ function getCompilerOptionsAstObject(host, tsConfigPath) {
140
91
  if (tsCfgAst.kind !== 'object') {
141
92
  return;
142
93
  }
94
+ const configExtends = json_utils_1.findPropertyInAstObject(tsCfgAst, 'extends');
95
+ const isExtendedConfig = configExtends && configExtends.kind === 'string';
143
96
  const compilerOptions = json_utils_1.findPropertyInAstObject(tsCfgAst, 'compilerOptions');
144
97
  if (!compilerOptions || compilerOptions.kind !== 'object') {
145
98
  return;
146
99
  }
147
- return compilerOptions;
100
+ const recorder = tree.beginUpdate(tsConfigPath);
101
+ if (isExtendedConfig) {
102
+ json_utils_1.removePropertyInAstObject(recorder, compilerOptions, 'target');
103
+ json_utils_1.removePropertyInAstObject(recorder, compilerOptions, 'module');
104
+ json_utils_1.removePropertyInAstObject(recorder, compilerOptions, 'downlevelIteration');
105
+ }
106
+ else {
107
+ const downlevelIteration = json_utils_1.findPropertyInAstObject(compilerOptions, 'downlevelIteration');
108
+ if (!downlevelIteration) {
109
+ json_utils_1.insertPropertyInAstObjectInOrder(recorder, compilerOptions, 'downlevelIteration', true, 4);
110
+ }
111
+ else if (!downlevelIteration.value) {
112
+ const { start, end } = downlevelIteration;
113
+ recorder.remove(start.offset, end.offset - start.offset);
114
+ recorder.insertLeft(start.offset, 'true');
115
+ }
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
- // normalize line endings to increase hash match chances
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.update(content);
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
@@ -84,7 +84,7 @@ function dropES2015PolyfillsFromFile(polyfillPath) {
84
84
  // no action required if no mention of core-js
85
85
  return;
86
86
  }
87
- const sourceFile = ts.createSourceFile(polyfillPath, content, ts.ScriptTarget.Latest, true);
87
+ const sourceFile = ts.createSourceFile(polyfillPath, content.replace(/^\uFEFF/, ''), ts.ScriptTarget.Latest, true);
88
88
  const imports = sourceFile.statements
89
89
  .filter(s => s.kind === ts.SyntaxKind.ImportDeclaration);
90
90
  if (imports.length === 0) {
@@ -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 update_builders_1 = require("./update-builders");
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
- update_builders_1.updateBuilders(),
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;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const dependencies_1 = require("../../utility/dependencies");
4
+ const latest_versions_1 = require("../../utility/latest-versions");
5
+ function updateDependencies() {
6
+ return (host) => {
7
+ const dependenciesToUpdate = {
8
+ '@angular-devkit/build-angular': latest_versions_1.latestVersions.DevkitBuildAngular,
9
+ '@angular-devkit/build-ng-packagr': latest_versions_1.latestVersions.DevkitBuildNgPackagr,
10
+ '@angular-devkit/build-webpack': latest_versions_1.latestVersions.DevkitBuildWebpack,
11
+ 'zone.js': latest_versions_1.latestVersions.ZoneJs,
12
+ 'tsickle': latest_versions_1.latestVersions.tsickle,
13
+ 'ng-packagr': latest_versions_1.latestVersions.ngPackagr,
14
+ // FIXME: change to ^2.3.2 as soon as it's released with the pr208 fix
15
+ 'web-animations-js': 'github:angular/web-animations-js#release_pr208',
16
+ };
17
+ for (const [name, version] of Object.entries(dependenciesToUpdate)) {
18
+ const current = dependencies_1.getPackageJsonDependency(host, name);
19
+ if (!current || current.version === version) {
20
+ continue;
21
+ }
22
+ dependencies_1.addPackageJsonDependency(host, {
23
+ type: current.type,
24
+ name,
25
+ version,
26
+ overwrite: true,
27
+ });
28
+ }
29
+ };
30
+ }
31
+ exports.updateDependencies = updateDependencies;
@@ -8,7 +8,7 @@ function* visit(directory) {
8
8
  if (entry) {
9
9
  const content = entry.content;
10
10
  if (content.includes('loadChildren')) {
11
- const source = ts.createSourceFile(entry.path, content.toString(), ts.ScriptTarget.Latest, true);
11
+ const source = ts.createSourceFile(entry.path, content.toString().replace(/^\uFEFF/, ''), ts.ScriptTarget.Latest, true);
12
12
  yield source;
13
13
  }
14
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "8.0.0-rc.4",
3
+ "version": "8.0.3",
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-rc.4",
18
- "@angular-devkit/schematics": "8.0.0-rc.4"
17
+ "@angular-devkit/core": "8.0.3",
18
+ "@angular-devkit/schematics": "8.0.3"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
@@ -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.getFullText(source) == identifier
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.getText(source);
253
+ const moduleId = paExpr.expression.text;
255
254
  return id === identifier && (angularImports[moduleId + '.'] === module);
256
255
  }
257
256
  return false;
@@ -13,4 +13,7 @@ export declare const latestVersions: {
13
13
  TsLib: string;
14
14
  DevkitBuildAngular: string;
15
15
  DevkitBuildNgPackagr: string;
16
+ DevkitBuildWebpack: string;
17
+ tsickle: string;
18
+ ngPackagr: string;
16
19
  };
@@ -9,12 +9,15 @@
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-rc.4',
12
+ Angular: '~8.0.1',
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-rc.4',
19
- DevkitBuildNgPackagr: '~0.800.0-rc.4',
18
+ DevkitBuildAngular: '~0.800.0',
19
+ DevkitBuildNgPackagr: '~0.800.0',
20
+ DevkitBuildWebpack: '~0.800.0',
21
+ tsickle: '^0.35.0',
22
+ ngPackagr: '^5.1.0',
20
23
  };
@@ -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, and aren't spec files.
54
- .filter(f => f.startsWith(options.name) && f.endsWith('.ts') && !f.endsWith('spec.ts'))
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) {
@@ -5,10 +5,11 @@
5
5
  "outDir": "./dist/out-tsc",
6
6
  "sourceMap": true,
7
7
  "declaration": false,
8
- "module": "esnext",
9
- "moduleResolution": "node",
8
+ "downlevelIteration": true,
10
9
  "emitDecoratorMetadata": true,
11
10
  "experimentalDecorators": true,
11
+ "module": "esnext",
12
+ "moduleResolution": "node",
12
13
  "importHelpers": true,
13
14
  "target": "es2015",
14
15
  "typeRoots": [
@@ -1 +0,0 @@
1
- export declare function updateBuilders(): (host: import("../../../../angular_devkit/schematics/src/tree/interface").Tree) => void;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const dependencies_1 = require("../../utility/dependencies");
4
- const latest_versions_1 = require("../../utility/latest-versions");
5
- function updateBuilders() {
6
- return (host) => {
7
- let current = dependencies_1.getPackageJsonDependency(host, '@angular-devkit/build-angular');
8
- if (current && current.version !== latest_versions_1.latestVersions.DevkitBuildAngular) {
9
- dependencies_1.addPackageJsonDependency(host, {
10
- type: current.type,
11
- name: '@angular-devkit/build-angular',
12
- version: latest_versions_1.latestVersions.DevkitBuildAngular,
13
- overwrite: true,
14
- });
15
- }
16
- current = dependencies_1.getPackageJsonDependency(host, '@angular-devkit/build-ng-packagr');
17
- if (current && current.version !== latest_versions_1.latestVersions.DevkitBuildNgPackagr) {
18
- dependencies_1.addPackageJsonDependency(host, {
19
- type: current.type,
20
- name: '@angular-devkit/build-ng-packagr',
21
- version: latest_versions_1.latestVersions.DevkitBuildNgPackagr,
22
- overwrite: true,
23
- });
24
- }
25
- current = dependencies_1.getPackageJsonDependency(host, 'zone.js');
26
- if (current && current.version !== latest_versions_1.latestVersions.ZoneJs) {
27
- dependencies_1.addPackageJsonDependency(host, {
28
- type: current.type,
29
- name: 'zone.js',
30
- version: latest_versions_1.latestVersions.ZoneJs,
31
- overwrite: true,
32
- });
33
- }
34
- };
35
- }
36
- exports.updateBuilders = updateBuilders;