diff --git a/integration/angular_cli/e2e/tsconfig.json b/integration/angular_cli/e2e/tsconfig.json index 6b87cc425b4d..c92199cfd63f 100644 --- a/integration/angular_cli/e2e/tsconfig.json +++ b/integration/angular_cli/e2e/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig.base.json", + "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/e2e", "module": "commonjs", diff --git a/integration/angular_cli/tsconfig.app.json b/integration/angular_cli/tsconfig.app.json index 44795bd55a31..f758d9820d53 100644 --- a/integration/angular_cli/tsconfig.app.json +++ b/integration/angular_cli/tsconfig.app.json @@ -1,5 +1,5 @@ { - "extends": "./tsconfig.base.json", + "extends": "./tsconfig.json", "compilerOptions": { "outDir": "./out-tsc/app", "types": [] diff --git a/integration/angular_cli/tsconfig.base.json b/integration/angular_cli/tsconfig.base.json deleted file mode 100644 index 5015054494d9..000000000000 --- a/integration/angular_cli/tsconfig.base.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compileOnSave": false, - "compilerOptions": { - "baseUrl": "./", - "outDir": "./dist/out-tsc", - "sourceMap": true, - "declaration": false, - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "target": "es2015", - "module": "es2020", - "typeRoots": [ - "node_modules/@types" - ], - "lib": [ - "es2017", - "dom" - ] - }, - "angularCompilerOptions": { - "enableIvy": true, - "disableTypeScriptVersionCheck": true - } -} diff --git a/integration/angular_cli/tsconfig.json b/integration/angular_cli/tsconfig.json index 6444c9b8ff97..5015054494d9 100644 --- a/integration/angular_cli/tsconfig.json +++ b/integration/angular_cli/tsconfig.json @@ -1,13 +1,25 @@ -// This tsConfig file is used by editors and TypeScript’s language server to improve development experience. -// Note: This should not be used to perform a compilation. { - "files": [], - "references": [ - { - "path": "./tsconfig.app.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] + "compileOnSave": false, + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist/out-tsc", + "sourceMap": true, + "declaration": false, + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "target": "es2015", + "module": "es2020", + "typeRoots": [ + "node_modules/@types" + ], + "lib": [ + "es2017", + "dom" + ] + }, + "angularCompilerOptions": { + "enableIvy": true, + "disableTypeScriptVersionCheck": true + } } diff --git a/integration/angular_cli/tsconfig.spec.json b/integration/angular_cli/tsconfig.spec.json index 2fabc273a346..04463b7811d2 100644 --- a/integration/angular_cli/tsconfig.spec.json +++ b/integration/angular_cli/tsconfig.spec.json @@ -1,5 +1,5 @@ { - "extends": "./tsconfig.base.json", + "extends": "./tsconfig.json", "compilerOptions": { "outDir": "./out-tsc/spec", "types": [ diff --git a/packages/angular/cli/commands/version-impl.ts b/packages/angular/cli/commands/version-impl.ts index e6cb877e1337..a840cd3955a1 100644 --- a/packages/angular/cli/commands/version-impl.ts +++ b/packages/angular/cli/commands/version-impl.ts @@ -194,7 +194,7 @@ export class VersionCommand extends Command { private getIvyWorkspace(): string { try { - const content = fs.readFileSync(path.resolve(this.workspace.root, 'tsconfig.base.json'), 'utf-8'); + const content = fs.readFileSync(path.resolve(this.workspace.root, 'tsconfig.json'), 'utf-8'); const tsConfig = parseJson(content, JsonParseMode.Loose); if (!isJsonObject(tsConfig)) { return ''; diff --git a/packages/angular_devkit/build_angular/src/browser/specs/allow-js_spec.ts b/packages/angular_devkit/build_angular/src/browser/specs/allow-js_spec.ts index 3e41281d152d..4e447355493b 100644 --- a/packages/angular_devkit/build_angular/src/browser/specs/allow-js_spec.ts +++ b/packages/angular_devkit/build_angular/src/browser/specs/allow-js_spec.ts @@ -29,7 +29,7 @@ describe('Browser Builder allow js', () => { }); host.replaceInFile( - 'tsconfig.base.json', + 'tsconfig.json', '"target": "es2015"', '"target": "es5", "allowJs": true', ); @@ -54,7 +54,7 @@ describe('Browser Builder allow js', () => { }); host.replaceInFile( - 'tsconfig.base.json', + 'tsconfig.json', '"target": "es2015"', '"target": "es5", "allowJs": true', ); @@ -81,7 +81,7 @@ describe('Browser Builder allow js', () => { }); host.replaceInFile( - 'tsconfig.base.json', + 'tsconfig.json', '"target": "es2015"', '"target": "es5", "allowJs": true', ); diff --git a/packages/angular_devkit/build_angular/src/browser/specs/common-js-warning_spec.ts b/packages/angular_devkit/build_angular/src/browser/specs/common-js-warning_spec.ts index 5cb273669acf..b427ad19e9a2 100644 --- a/packages/angular_devkit/build_angular/src/browser/specs/common-js-warning_spec.ts +++ b/packages/angular_devkit/build_angular/src/browser/specs/common-js-warning_spec.ts @@ -79,7 +79,7 @@ describe('Browser Builder commonjs warning', () => { }); it('should not show warning in JIT for templateUrl and styleUrl when using paths', async () => { - host.replaceInFile('tsconfig.base.json', /"baseUrl": ".\/",/, ` + host.replaceInFile('tsconfig.json', /"baseUrl": ".\/",/, ` "baseUrl": "./", "paths": { "@app/*": [ diff --git a/packages/angular_devkit/build_angular/src/browser/specs/differential_loading_spec.ts b/packages/angular_devkit/build_angular/src/browser/specs/differential_loading_spec.ts index 256989c700fe..8a0f5cbdd7f4 100644 --- a/packages/angular_devkit/build_angular/src/browser/specs/differential_loading_spec.ts +++ b/packages/angular_devkit/build_angular/src/browser/specs/differential_loading_spec.ts @@ -65,7 +65,7 @@ describe('Browser Builder with differential loading', () => { it('emits all the neccessary files for target of ES2016', async () => { host.replaceInFile( - 'tsconfig.base.json', + 'tsconfig.json', '"target": "es2015",', `"target": "es2016",`, ); @@ -107,7 +107,7 @@ describe('Browser Builder with differential loading', () => { it('emits all the neccessary files for target of ESNext', async () => { host.replaceInFile( - 'tsconfig.base.json', + 'tsconfig.json', '"target": "es2015",', `"target": "esnext",`, ); diff --git a/packages/angular_devkit/build_angular/src/browser/specs/optimization-level_spec.ts b/packages/angular_devkit/build_angular/src/browser/specs/optimization-level_spec.ts index 5f350cc6cf1f..f5025f2d9dcb 100644 --- a/packages/angular_devkit/build_angular/src/browser/specs/optimization-level_spec.ts +++ b/packages/angular_devkit/build_angular/src/browser/specs/optimization-level_spec.ts @@ -27,7 +27,7 @@ describe('Browser Builder optimization level', () => { }); it('tsconfig target changes optimizations to use ES2015', async () => { - host.replaceInFile('tsconfig.base.json', '"target": "es5"', '"target": "es2015"'); + host.replaceInFile('tsconfig.json', '"target": "es5"', '"target": "es2015"'); const overrides = { optimization: true }; const { files } = await browserBuild(architect, host, target, overrides); diff --git a/packages/angular_devkit/build_angular/src/browser/specs/resolve-json-module_spec.ts b/packages/angular_devkit/build_angular/src/browser/specs/resolve-json-module_spec.ts index c6ca2e7c9558..373ac3419984 100644 --- a/packages/angular_devkit/build_angular/src/browser/specs/resolve-json-module_spec.ts +++ b/packages/angular_devkit/build_angular/src/browser/specs/resolve-json-module_spec.ts @@ -29,7 +29,7 @@ describe('Browser Builder resolve json module', () => { }); host.replaceInFile( - 'tsconfig.base.json', + 'tsconfig.json', '"target": "es2015"', '"target": "es5", "resolveJsonModule": true', ); diff --git a/packages/angular_devkit/build_angular/src/browser/specs/tsconfig-paths_spec.ts b/packages/angular_devkit/build_angular/src/browser/specs/tsconfig-paths_spec.ts index 882550dc586b..8e31ff766798 100644 --- a/packages/angular_devkit/build_angular/src/browser/specs/tsconfig-paths_spec.ts +++ b/packages/angular_devkit/build_angular/src/browser/specs/tsconfig-paths_spec.ts @@ -22,7 +22,7 @@ describe('Browser Builder tsconfig paths', () => { it('works', async () => { host.replaceInFile('src/app/app.module.ts', './app.component', '@root/app/app.component'); - host.replaceInFile('tsconfig.base.json', /"baseUrl": ".\/",/, ` + host.replaceInFile('tsconfig.json', /"baseUrl": ".\/",/, ` "baseUrl": "./", "paths": { "@root/*": [ @@ -40,7 +40,7 @@ describe('Browser Builder tsconfig paths', () => { 'src/app/shared/meaning.ts': 'export var meaning = 42;', 'src/app/shared/index.ts': `export * from './meaning'`, }); - host.replaceInFile('tsconfig.base.json', /"baseUrl": ".\/",/, ` + host.replaceInFile('tsconfig.json', /"baseUrl": ".\/",/, ` "baseUrl": "./", "paths": { "@shared": [ diff --git a/packages/angular_devkit/build_angular/src/browser/specs/web-worker_spec.ts b/packages/angular_devkit/build_angular/src/browser/specs/web-worker_spec.ts index 17c3e71a7cde..2837699a3773 100644 --- a/packages/angular_devkit/build_angular/src/browser/specs/web-worker_spec.ts +++ b/packages/angular_devkit/build_angular/src/browser/specs/web-worker_spec.ts @@ -57,7 +57,7 @@ describe('Browser Builder Web Worker support', () => { // tests, and integration with other build targets. './src/tsconfig.worker.json': ` { - "extends": "../tsconfig.base.json", + "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/worker", "lib": [ @@ -73,7 +73,7 @@ describe('Browser Builder Web Worker support', () => { // Alter the app tsconfig to not include *.worker.ts files. './src/tsconfig.app.json': ` { - "extends": "../tsconfig.base.json", + "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/worker", "types": [] diff --git a/packages/angular_devkit/build_angular/src/karma/code-coverage_spec.ts b/packages/angular_devkit/build_angular/src/karma/code-coverage_spec.ts index 8a2e2f350e28..5514beddd702 100644 --- a/packages/angular_devkit/build_angular/src/karma/code-coverage_spec.ts +++ b/packages/angular_devkit/build_angular/src/karma/code-coverage_spec.ts @@ -87,7 +87,7 @@ describe('Karma Builder code coverage', () => { host.writeMultipleFiles(files); - host.replaceInFile('tsconfig.base.json', /"baseUrl": ".\/",/, ` + host.replaceInFile('tsconfig.json', /"baseUrl": ".\/",/, ` "baseUrl": "./", "paths": { "my-lib": [ diff --git a/packages/angular_devkit/build_angular/src/karma/works_spec.ts b/packages/angular_devkit/build_angular/src/karma/works_spec.ts index 287777f7423f..ad749f97fb1e 100644 --- a/packages/angular_devkit/build_angular/src/karma/works_spec.ts +++ b/packages/angular_devkit/build_angular/src/karma/works_spec.ts @@ -41,7 +41,7 @@ describe('Karma Builder', () => { }); it('supports ES2015 target', async () => { - host.replaceInFile('tsconfig.base.json', '"target": "es5"', '"target": "es2015"'); + host.replaceInFile('tsconfig.json', '"target": "es5"', '"target": "es2015"'); const run = await architect.scheduleTarget(karmaTargetSpec); diff --git a/packages/angular_devkit/build_angular/src/test-utils.ts b/packages/angular_devkit/build_angular/src/test-utils.ts index 9f8e478fb2cb..9a1ae6f738f9 100644 --- a/packages/angular_devkit/build_angular/src/test-utils.ts +++ b/packages/angular_devkit/build_angular/src/test-utils.ts @@ -55,7 +55,7 @@ export async function createArchitect(workspaceRoot: Path) { // Set AOT compilation to use VE if needed. if (veEnabled) { - host.replaceInFile('tsconfig.base.json', `"enableIvy": true,`, `"enableIvy": false,`); + host.replaceInFile('tsconfig.json', `"enableIvy": true,`, `"enableIvy": false,`); } return { diff --git a/packages/angular_devkit/build_angular/test/hello-world-app/e2e/tsconfig.e2e.json b/packages/angular_devkit/build_angular/test/hello-world-app/e2e/tsconfig.e2e.json index 6b87cc425b4d..c92199cfd63f 100644 --- a/packages/angular_devkit/build_angular/test/hello-world-app/e2e/tsconfig.e2e.json +++ b/packages/angular_devkit/build_angular/test/hello-world-app/e2e/tsconfig.e2e.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig.base.json", + "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/e2e", "module": "commonjs", diff --git a/packages/angular_devkit/build_angular/test/hello-world-app/src/tsconfig.app.json b/packages/angular_devkit/build_angular/test/hello-world-app/src/tsconfig.app.json index 0f688b32598a..f761e8b2c4fc 100644 --- a/packages/angular_devkit/build_angular/test/hello-world-app/src/tsconfig.app.json +++ b/packages/angular_devkit/build_angular/test/hello-world-app/src/tsconfig.app.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig.base.json", + "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/app", "types": [] diff --git a/packages/angular_devkit/build_angular/test/hello-world-app/src/tsconfig.spec.json b/packages/angular_devkit/build_angular/test/hello-world-app/src/tsconfig.spec.json index 184fbee5e5fa..dba226c49414 100644 --- a/packages/angular_devkit/build_angular/test/hello-world-app/src/tsconfig.spec.json +++ b/packages/angular_devkit/build_angular/test/hello-world-app/src/tsconfig.spec.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig.base.json", + "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/spec", "types": [ diff --git a/packages/angular_devkit/build_angular/test/hello-world-app/tsconfig.base.json b/packages/angular_devkit/build_angular/test/hello-world-app/tsconfig.base.json deleted file mode 100644 index 5015054494d9..000000000000 --- a/packages/angular_devkit/build_angular/test/hello-world-app/tsconfig.base.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compileOnSave": false, - "compilerOptions": { - "baseUrl": "./", - "outDir": "./dist/out-tsc", - "sourceMap": true, - "declaration": false, - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "target": "es2015", - "module": "es2020", - "typeRoots": [ - "node_modules/@types" - ], - "lib": [ - "es2017", - "dom" - ] - }, - "angularCompilerOptions": { - "enableIvy": true, - "disableTypeScriptVersionCheck": true - } -} diff --git a/packages/angular_devkit/build_angular/test/hello-world-app/tsconfig.json b/packages/angular_devkit/build_angular/test/hello-world-app/tsconfig.json index c41356ea00a8..5015054494d9 100644 --- a/packages/angular_devkit/build_angular/test/hello-world-app/tsconfig.json +++ b/packages/angular_devkit/build_angular/test/hello-world-app/tsconfig.json @@ -1,19 +1,25 @@ -// This tsConfig file is used by editors and TypeScript’s language server to improve development experience. -// Note: This should not be used to perform a compilation. { - "files": [], - "references": [ - { - "path": "./src/tsconfig.app.json" - }, - { - "path": "./src/tsconfig.spec.json" - }, - { - "path": "./src/tsconfig.server.json" - }, - { - "path": "./e2e/tsconfig.e2e.json" - } - ] + "compileOnSave": false, + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist/out-tsc", + "sourceMap": true, + "declaration": false, + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "target": "es2015", + "module": "es2020", + "typeRoots": [ + "node_modules/@types" + ], + "lib": [ + "es2017", + "dom" + ] + }, + "angularCompilerOptions": { + "enableIvy": true, + "disableTypeScriptVersionCheck": true + } } diff --git a/packages/angular_devkit/build_ng_packagr/src/build/index_spec.ts b/packages/angular_devkit/build_ng_packagr/src/build/index_spec.ts index 01f8edd7a25c..c06fcab9422b 100644 --- a/packages/angular_devkit/build_ng_packagr/src/build/index_spec.ts +++ b/packages/angular_devkit/build_ng_packagr/src/build/index_spec.ts @@ -50,7 +50,7 @@ describe('NgPackagr Builder', () => { // Set AOT compilation to use VE if needed. if (veEnabled) { - host.replaceInFile('tsconfig.base.json', `"enableIvy": true,`, `"enableIvy": false,`); + host.replaceInFile('tsconfig.json', `"enableIvy": true,`, `"enableIvy": false,`); } }); diff --git a/packages/angular_devkit/build_ng_packagr/test/ng-packaged/projects/lib/tsconfig.lib.json b/packages/angular_devkit/build_ng_packagr/test/ng-packaged/projects/lib/tsconfig.lib.json index cc9fb168b02b..0af783fbaf1e 100644 --- a/packages/angular_devkit/build_ng_packagr/test/ng-packaged/projects/lib/tsconfig.lib.json +++ b/packages/angular_devkit/build_ng_packagr/test/ng-packaged/projects/lib/tsconfig.lib.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "../../tsconfig.json", "compilerOptions": { "target": "es2015", "declaration": true, diff --git a/packages/angular_devkit/build_ng_packagr/test/ng-packaged/projects/lib/tsconfig.spec.json b/packages/angular_devkit/build_ng_packagr/test/ng-packaged/projects/lib/tsconfig.spec.json index f684a8b06dfe..f1c08bf277d3 100644 --- a/packages/angular_devkit/build_ng_packagr/test/ng-packaged/projects/lib/tsconfig.spec.json +++ b/packages/angular_devkit/build_ng_packagr/test/ng-packaged/projects/lib/tsconfig.spec.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "../../out-tsc/spec", "types": [ diff --git a/packages/angular_devkit/build_ng_packagr/test/ng-packaged/tsconfig.base.json b/packages/angular_devkit/build_ng_packagr/test/ng-packaged/tsconfig.base.json deleted file mode 100644 index 2c5d470a7258..000000000000 --- a/packages/angular_devkit/build_ng_packagr/test/ng-packaged/tsconfig.base.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compileOnSave": false, - "compilerOptions": { - "baseUrl": "./", - "outDir": "./dist/out-tsc", - "sourceMap": true, - "declaration": false, - "moduleResolution": "node", - "experimentalDecorators": true, - "target": "es2015", - "module": "es2020", - "typeRoots": [ - "node_modules/@types" - ], - "lib": [ - "es2017", - "dom" - ] - }, - "angularCompilerOptions": { - "enableIvy": true, - "disableTypeScriptVersionCheck": true - } -} diff --git a/packages/angular_devkit/build_ng_packagr/test/ng-packaged/tsconfig.json b/packages/angular_devkit/build_ng_packagr/test/ng-packaged/tsconfig.json index 3706a3e29ba4..2c5d470a7258 100644 --- a/packages/angular_devkit/build_ng_packagr/test/ng-packaged/tsconfig.json +++ b/packages/angular_devkit/build_ng_packagr/test/ng-packaged/tsconfig.json @@ -1,13 +1,24 @@ -// This tsConfig file is used by editors and TypeScript’s language server to improve development experience. -// Note: This should not be used to perform a compilation. { - "files": [], - "references": [ - { - "path": "./projects/lib/tsconfig.lib.json" - }, - { - "path": "./projects/lib/tsconfig.spec.json" - } - ] + "compileOnSave": false, + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist/out-tsc", + "sourceMap": true, + "declaration": false, + "moduleResolution": "node", + "experimentalDecorators": true, + "target": "es2015", + "module": "es2020", + "typeRoots": [ + "node_modules/@types" + ], + "lib": [ + "es2017", + "dom" + ] + }, + "angularCompilerOptions": { + "enableIvy": true, + "disableTypeScriptVersionCheck": true + } } diff --git a/packages/schematics/angular/application/files/tsconfig.app.json.template b/packages/schematics/angular/application/files/tsconfig.app.json.template index ce0c741bc766..1966d893bf6d 100644 --- a/packages/schematics/angular/application/files/tsconfig.app.json.template +++ b/packages/schematics/angular/application/files/tsconfig.app.json.template @@ -1,6 +1,6 @@ /* To learn more about this file see: https://angular.io/config/tsconfig. */ { - "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.base.json", + "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.json", "compilerOptions": { "outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/app", "types": [] diff --git a/packages/schematics/angular/application/files/tsconfig.spec.json.template b/packages/schematics/angular/application/files/tsconfig.spec.json.template index 0a9cf6eac5e1..0e856e624157 100644 --- a/packages/schematics/angular/application/files/tsconfig.spec.json.template +++ b/packages/schematics/angular/application/files/tsconfig.spec.json.template @@ -1,6 +1,6 @@ /* To learn more about this file see: https://angular.io/config/tsconfig. */ { - "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.base.json", + "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.json", "compilerOptions": { "outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/spec", "types": [ diff --git a/packages/schematics/angular/application/index.ts b/packages/schematics/angular/application/index.ts index 42224728a615..62286f986f2d 100644 --- a/packages/schematics/angular/application/index.ts +++ b/packages/schematics/angular/application/index.ts @@ -35,7 +35,6 @@ import { JSONFile } from '../utility/json-file'; import { latestVersions } from '../utility/latest-versions'; import { applyLintFix } from '../utility/lint-fix'; import { relativePathToWorkspaceRoot } from '../utility/paths'; -import { addTsConfigProjectReferences, verifyBaseTsConfigExists } from '../utility/tsconfig'; import { validateProjectName } from '../utility/validation'; import { getWorkspace, updateWorkspace } from '../utility/workspace'; import { Builders, ProjectType } from '../utility/workspace-models'; @@ -280,7 +279,6 @@ export default function (options: ApplicationOptions): Rule { } validateProjectName(options.name); - verifyBaseTsConfigExists(host); const appRootSelector = `${options.prefix}-root`; const componentOptions: Partial = !options.minimal ? @@ -363,10 +361,6 @@ export default function (options: ApplicationOptions): Rule { }), move(sourceDir), ]), MergeStrategy.Overwrite), - addTsConfigProjectReferences([ - join(appDir, 'tsconfig.app.json'), - ... options.minimal ? [] : [join(appDir, 'tsconfig.spec.json')], - ]), options.minimal ? noop() : schematic('e2e', e2eOptions), options.skipPackageJson ? noop() : addDependenciesToPackageJson(options), options.lintFix ? applyLintFix(appDir) : noop(), diff --git a/packages/schematics/angular/application/index_spec.ts b/packages/schematics/angular/application/index_spec.ts index 149e00b16569..ed4a3c241d7b 100644 --- a/packages/schematics/angular/application/index_spec.ts +++ b/packages/schematics/angular/application/index_spec.ts @@ -80,28 +80,6 @@ describe('Application Schematic', () => { expect(workspace.defaultProject).toBe('foo'); }); - it('should add references in solution style tsconfig', async () => { - const tree = await schematicRunner.runSchematicAsync('application', defaultOptions, workspaceTree) - .toPromise(); - - const { references } = readJsonFile(tree, '/tsconfig.json'); - expect(references).toEqual([ - { path: './projects/foo/tsconfig.app.json' }, - { path: './projects/foo/tsconfig.spec.json' }, - ]); - }); - - it('minimal=true should add correct reference in tsconfig', async () => { - const options = { ...defaultOptions, minimal: true }; - const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree) - .toPromise(); - - const { references } = readJsonFile(tree, '/tsconfig.json'); - expect(references).toEqual([ - { path: './projects/foo/tsconfig.app.json' }, - ]); - }); - it('should set the prefix to app if none is set', async () => { const options = { ...defaultOptions }; @@ -166,7 +144,7 @@ describe('Application Schematic', () => { .toPromise(); const { files, extends: _extends } = readJsonFile(tree, '/projects/foo/tsconfig.app.json'); expect(files).toEqual(['src/main.ts', 'src/polyfills.ts']); - expect(_extends).toBe('../../tsconfig.base.json'); + expect(_extends).toBe('../../tsconfig.json'); }); it('should set the right paths in the tsconfig.spec.json', async () => { @@ -174,7 +152,7 @@ describe('Application Schematic', () => { .toPromise(); const { files, extends: _extends } = readJsonFile(tree, '/projects/foo/tsconfig.spec.json'); expect(files).toEqual(['src/test.ts', 'src/polyfills.ts']); - expect(_extends).toBe('../../tsconfig.base.json'); + expect(_extends).toBe('../../tsconfig.json'); }); it('should set the right path and prefix in the tslint file', async () => { @@ -401,9 +379,9 @@ describe('Application Schematic', () => { const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree) .toPromise(); const appTsConfig = readJsonFile(tree, '/tsconfig.app.json'); - expect(appTsConfig.extends).toEqual('./tsconfig.base.json'); + expect(appTsConfig.extends).toEqual('./tsconfig.json'); const specTsConfig = readJsonFile(tree, '/tsconfig.spec.json'); - expect(specTsConfig.extends).toEqual('./tsconfig.base.json'); + expect(specTsConfig.extends).toEqual('./tsconfig.json'); expect(specTsConfig.files).toEqual(['src/test.ts', 'src/polyfills.ts']); }); @@ -447,9 +425,9 @@ describe('Application Schematic', () => { expect(buildOpt.tsConfig).toEqual('foo/tsconfig.app.json'); const appTsConfig = readJsonFile(tree, '/foo/tsconfig.app.json'); - expect(appTsConfig.extends).toEqual('../tsconfig.base.json'); + expect(appTsConfig.extends).toEqual('../tsconfig.json'); const specTsConfig = readJsonFile(tree, '/foo/tsconfig.spec.json'); - expect(specTsConfig.extends).toEqual('../tsconfig.base.json'); + expect(specTsConfig.extends).toEqual('../tsconfig.json'); }); }); diff --git a/packages/schematics/angular/e2e/files/tsconfig.json.template b/packages/schematics/angular/e2e/files/tsconfig.json.template index 458498a6dd24..61594f0058f0 100644 --- a/packages/schematics/angular/e2e/files/tsconfig.json.template +++ b/packages/schematics/angular/e2e/files/tsconfig.json.template @@ -1,6 +1,6 @@ /* To learn more about this file see: https://angular.io/config/tsconfig. */ { - "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.base.json", + "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.json", "compilerOptions": { "outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/e2e", "module": "commonjs", diff --git a/packages/schematics/angular/e2e/index.ts b/packages/schematics/angular/e2e/index.ts index 0789b7743d59..cee30a5e37f6 100644 --- a/packages/schematics/angular/e2e/index.ts +++ b/packages/schematics/angular/e2e/index.ts @@ -18,7 +18,6 @@ import { url, } from '@angular-devkit/schematics'; import { relativePathToWorkspaceRoot } from '../utility/paths'; -import { verifyBaseTsConfigExists } from '../utility/tsconfig'; import { getWorkspace, updateWorkspace } from '../utility/workspace'; import { Builders } from '../utility/workspace-models'; import { Schema as E2eOptions } from './schema'; @@ -32,8 +31,6 @@ export default function (options: E2eOptions): Rule { throw new SchematicsException(`Project name "${appProject}" doesn't not exist.`); } - verifyBaseTsConfigExists(host); - const root = join(normalize(project.root), 'e2e'); project.targets.add({ diff --git a/packages/schematics/angular/library/files/tsconfig.lib.json.template b/packages/schematics/angular/library/files/tsconfig.lib.json.template index b26d9cbbe755..f3c3f4aa6429 100644 --- a/packages/schematics/angular/library/files/tsconfig.lib.json.template +++ b/packages/schematics/angular/library/files/tsconfig.lib.json.template @@ -1,6 +1,6 @@ /* To learn more about this file see: https://angular.io/config/tsconfig. */ { - "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.base.json", + "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.json", "compilerOptions": { "outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/lib", "target": "es2015", diff --git a/packages/schematics/angular/library/files/tsconfig.spec.json.template b/packages/schematics/angular/library/files/tsconfig.spec.json.template index 955316623e81..2108b9b916f1 100644 --- a/packages/schematics/angular/library/files/tsconfig.spec.json.template +++ b/packages/schematics/angular/library/files/tsconfig.spec.json.template @@ -1,6 +1,6 @@ /* To learn more about this file see: https://angular.io/config/tsconfig. */ { - "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.base.json", + "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.json", "compilerOptions": { "outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/spec", "types": [ diff --git a/packages/schematics/angular/library/index.ts b/packages/schematics/angular/library/index.ts index 2ed7ef293354..f4df981b2c4e 100644 --- a/packages/schematics/angular/library/index.ts +++ b/packages/schematics/angular/library/index.ts @@ -25,7 +25,6 @@ import { NodeDependencyType, addPackageJsonDependency } from '../utility/depende import { latestVersions } from '../utility/latest-versions'; import { applyLintFix } from '../utility/lint-fix'; import { relativePathToWorkspaceRoot } from '../utility/paths'; -import { addTsConfigProjectReferences, verifyBaseTsConfigExists } from '../utility/tsconfig'; import { validateProjectName } from '../utility/validation'; import { getWorkspace, updateWorkspace } from '../utility/workspace'; import { Builders, ProjectType } from '../utility/workspace-models'; @@ -59,9 +58,9 @@ function updateJsonFile(host: Tree, path: string, callback: UpdateJsonFn): function updateTsConfig(packageName: string, ...paths: string[]) { return (host: Tree) => { - if (!host.exists('tsconfig.base.json')) { return host; } + if (!host.exists('tsconfig.json')) { return host; } - return updateJsonFile(host, 'tsconfig.base.json', (tsconfig: TsConfigPartialType) => { + return updateJsonFile(host, 'tsconfig.json', (tsconfig: TsConfigPartialType) => { if (!tsconfig.compilerOptions.paths) { tsconfig.compilerOptions.paths = {}; } @@ -174,7 +173,6 @@ export default function (options: LibraryOptions): Rule { const prefix = options.prefix; validateProjectName(options.name); - verifyBaseTsConfigExists(host); // If scoped project (i.e. "@foo/bar"), convert projectDir to "foo/bar". const projectName = options.name; @@ -240,10 +238,6 @@ export default function (options: LibraryOptions): Rule { path: sourceDir, project: options.name, }), - addTsConfigProjectReferences([ - `${projectRoot}/tsconfig.lib.json`, - `${projectRoot}/tsconfig.spec.json`, - ]), options.lintFix ? applyLintFix(sourceDir) : noop(), (_tree: Tree, context: SchematicContext) => { if (!options.skipPackageJson && !options.skipInstall) { diff --git a/packages/schematics/angular/library/index_spec.ts b/packages/schematics/angular/library/index_spec.ts index b19cc568d7f7..5bde4951e5b2 100644 --- a/packages/schematics/angular/library/index_spec.ts +++ b/packages/schematics/angular/library/index_spec.ts @@ -202,11 +202,11 @@ describe('Library Schematic', () => { }); }); - describe(`update tsconfig.base.json`, () => { + describe(`update tsconfig.json`, () => { it(`should add paths mapping to empty tsconfig`, async () => { const tree = await schematicRunner.runSchematicAsync('library', defaultOptions, workspaceTree).toPromise(); - const tsConfigJson = getJsonFileContent(tree, 'tsconfig.base.json'); + const tsConfigJson = getJsonFileContent(tree, 'tsconfig.json'); expect(tsConfigJson.compilerOptions.paths.foo).toBeTruthy(); expect(tsConfigJson.compilerOptions.paths.foo.length).toEqual(2); expect(tsConfigJson.compilerOptions.paths.foo[0]).toEqual('dist/foo/foo'); @@ -214,7 +214,7 @@ describe('Library Schematic', () => { }); it(`should append to existing paths mappings`, async () => { - workspaceTree.overwrite('tsconfig.base.json', JSON.stringify({ + workspaceTree.overwrite('tsconfig.json', JSON.stringify({ compilerOptions: { paths: { 'unrelated': ['./something/else.ts'], @@ -224,7 +224,7 @@ describe('Library Schematic', () => { })); const tree = await schematicRunner.runSchematicAsync('library', defaultOptions, workspaceTree).toPromise(); - const tsConfigJson = getJsonFileContent(tree, 'tsconfig.base.json'); + const tsConfigJson = getJsonFileContent(tree, 'tsconfig.json'); expect(tsConfigJson.compilerOptions.paths.foo).toBeTruthy(); expect(tsConfigJson.compilerOptions.paths.foo.length).toEqual(3); expect(tsConfigJson.compilerOptions.paths.foo[1]).toEqual('dist/foo/foo'); @@ -237,7 +237,7 @@ describe('Library Schematic', () => { skipTsConfig: true, }, workspaceTree).toPromise(); - const tsConfigJson = getJsonFileContent(tree, 'tsconfig.base.json'); + const tsConfigJson = getJsonFileContent(tree, 'tsconfig.json'); expect(tsConfigJson.compilerOptions.paths).toBeUndefined(); }); }); @@ -266,12 +266,12 @@ describe('Library Schematic', () => { expect(pkgJson.name).toEqual(scopedName); const tsConfigJson = getJsonFileContent(tree, '/projects/myscope/mylib/tsconfig.spec.json'); - expect(tsConfigJson.extends).toEqual('../../../tsconfig.base.json'); + expect(tsConfigJson.extends).toEqual('../../../tsconfig.json'); const cfg = JSON.parse(tree.readContent('/angular.json')); expect(cfg.projects['@myscope/mylib']).toBeDefined(); - const rootTsCfg = getJsonFileContent(tree, '/tsconfig.base.json'); + const rootTsCfg = getJsonFileContent(tree, '/tsconfig.json'); expect(rootTsCfg.compilerOptions.paths['@myscope/mylib']).toEqual(['dist/myscope/mylib/myscope-mylib', 'dist/myscope/mylib']); const karmaConf = getFileContent(tree, '/projects/myscope/mylib/karma.conf.js'); @@ -316,9 +316,9 @@ describe('Library Schematic', () => { expect(buildOpt.tsConfig).toEqual('foo/tsconfig.lib.json'); const appTsConfig = getJsonFileContent(tree, '/foo/tsconfig.lib.json'); - expect(appTsConfig.extends).toEqual('../tsconfig.base.json'); + expect(appTsConfig.extends).toEqual('../tsconfig.json'); const specTsConfig = getJsonFileContent(tree, '/foo/tsconfig.spec.json'); - expect(specTsConfig.extends).toEqual('../tsconfig.base.json'); + expect(specTsConfig.extends).toEqual('../tsconfig.json'); }); it(`should add 'production' configuration`, async () => { @@ -328,16 +328,4 @@ describe('Library Schematic', () => { const workspace = JSON.parse(tree.readContent('/angular.json')); expect(workspace.projects.foo.architect.build.configurations.production).toBeDefined(); }); - - it('should add reference in solution style tsconfig', async () => { - const tree = await schematicRunner.runSchematicAsync('library', defaultOptions, workspaceTree) - .toPromise(); - - // tslint:disable-next-line:no-any - const { references } = getJsonFileContent(tree, '/tsconfig.json'); - expect(references).toEqual([ - { path: './projects/foo/tsconfig.lib.json' }, - { path: './projects/foo/tsconfig.spec.json' }, - ]); - }); }); diff --git a/packages/schematics/angular/library/schema.json b/packages/schematics/angular/library/schema.json index 427c8ffc0a69..9008d8aad44d 100644 --- a/packages/schematics/angular/library/schema.json +++ b/packages/schematics/angular/library/schema.json @@ -41,7 +41,7 @@ "skipTsConfig": { "type": "boolean", "default": false, - "description": "When true, does not update \"tsconfig.base.json\" to add a path mapping for the new library. The path mapping is needed to use the library in an app, but can be disabled here to simplify development." + "description": "When true, does not update \"tsconfig.json\" to add a path mapping for the new library. The path mapping is needed to use the library in an app, but can be disabled here to simplify development." }, "lintFix": { "type": "boolean", diff --git a/packages/schematics/angular/migrations/migration-collection.json b/packages/schematics/angular/migrations/migration-collection.json index df85b3b8a2ff..e7391de19469 100644 --- a/packages/schematics/angular/migrations/migration-collection.json +++ b/packages/schematics/angular/migrations/migration-collection.json @@ -90,11 +90,6 @@ "factory": "./update-10/update-libraries-tslib", "description": "Update library projects to use tslib version 2 as a direct dependency. Read more about this here: https://v10.angular.io/guide/migration-update-libraries-tslib" }, - "solution-style-tsconfig": { - "version": "10.0.0-beta.7", - "factory": "./update-10/solution-style-tsconfig", - "description": "Add \"Solution Style\" TypeScript configuration file support. This improves developer experience using editors powered by TypeScript’s language server. Read more about this here: https://v10.angular.io/guide/migration-solution-style-tsconfig" - }, "update-workspace-dependencies": { "version": "10.0.0-rc.2", "factory": "./update-10/update-dependencies", @@ -104,6 +99,11 @@ "version": "10.0.1", "factory": "./update-10/update-module-and-target-compiler-options", "description": "Update 'module' and 'target' TypeScript compiler options. Read more about this here: https://v10.angular.io/guide/migration-update-module-and-target-compiler-options" + }, + "remove-solution-style-tsconfig": { + "version": "10.1.0-next.5", + "factory": "./update-10/remove-solution-style-tsconfig", + "description": "Removing \"Solution Style\" TypeScript configuration file support." } } } diff --git a/packages/schematics/angular/migrations/update-10/remove-solution-style-tsconfig.ts b/packages/schematics/angular/migrations/update-10/remove-solution-style-tsconfig.ts new file mode 100644 index 000000000000..3dc86ee9f873 --- /dev/null +++ b/packages/schematics/angular/migrations/update-10/remove-solution-style-tsconfig.ts @@ -0,0 +1,75 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +import { Path, dirname, join, normalize, resolve } from '@angular-devkit/core'; +import { DirEntry, Rule } from '@angular-devkit/schematics'; +import { JSONFile } from '../../utility/json-file'; + +function* visitExtendedJsonFiles(directory: DirEntry): IterableIterator { + for (const path of directory.subfiles) { + if (!path.endsWith('.json')) { + continue; + } + + const entry = directory.file(path); + const content = entry?.content.toString(); + if (content?.includes('tsconfig.base.json')) { + yield join(directory.path, path); + } + } + + for (const path of directory.subdirs) { + if (path === 'node_modules' || path.startsWith('.')) { + continue; + } + + yield* visitExtendedJsonFiles(directory.dir(path)); + } +} + +export default function (): Rule { + return (host, context) => { + const logger = context.logger; + + const tsConfig = new JSONFile(host, 'tsconfig.json'); + const files = tsConfig.get(['files']); + if (!(Array.isArray(files) && files.length === 0)) { + logger.info('Migration has already been executed.'); + + return; + } + + if (host.exists('tsconfig.base.json')) { + host.overwrite('tsconfig.json', host.read('tsconfig.base.json') || ''); + host.delete('tsconfig.base.json'); + } + + // Iterate over all tsconfig files and change the extends from 'tsconfig.base.json' to 'tsconfig.json'. + const extendsJsonPath = ['extends']; + for (const path of visitExtendedJsonFiles(host.root)) { + const tsConfigDir = dirname(normalize(path)); + let tsConfigJson; + + try { + tsConfigJson = new JSONFile(host, path); + const extendsValue = tsConfigJson.get(extendsJsonPath); + + if (typeof extendsValue === 'string' && '/tsconfig.base.json' === resolve(tsConfigDir, normalize(extendsValue))) { + // tsconfig extends the workspace tsconfig path. + tsConfig.modify(extendsJsonPath, extendsValue.replace('tsconfig.base.json', 'tsconfig.json')); + } + } catch (error) { + logger.warn( + `${error.message || error}\n` + + 'If this is a TypeScript configuration file you will need to update the "extends" value manually.', + ); + + continue; + } + } + }; +} diff --git a/packages/schematics/angular/migrations/update-10/solution-style-tsconfig_spec.ts b/packages/schematics/angular/migrations/update-10/remove-solution-style-tsconfig_spec.ts similarity index 72% rename from packages/schematics/angular/migrations/update-10/solution-style-tsconfig_spec.ts rename to packages/schematics/angular/migrations/update-10/remove-solution-style-tsconfig_spec.ts index af9dd21ff549..04b452e77485 100644 --- a/packages/schematics/angular/migrations/update-10/solution-style-tsconfig_spec.ts +++ b/packages/schematics/angular/migrations/update-10/remove-solution-style-tsconfig_spec.ts @@ -10,8 +10,8 @@ import { EmptyTree } from '@angular-devkit/schematics'; import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing'; import { Builders, ProjectType, WorkspaceSchema } from '../../utility/workspace-models'; -describe('Migration to create "Solution Style" tsconfig', () => { - const schematicName = 'solution-style-tsconfig'; +describe('Migration to remove "Solution Style" tsconfig', () => { + const schematicName = 'remove-solution-style-tsconfig'; const schematicRunner = new SchematicTestRunner( 'migrations', @@ -70,65 +70,48 @@ describe('Migration to create "Solution Style" tsconfig', () => { // Create tsconfigs const compilerOptions = { target: 'es2015' }; - createJsonFile(tree, 'tsconfig.json', { compilerOptions }); + createJsonFile(tree, 'tsconfig.json', { files: [] }); + createJsonFile(tree, 'tsconfig.base.json', { compilerOptions }); createJsonFile(tree, 'tsconfig.common.json', { compilerOptions }); createJsonFile(tree, 'src/tsconfig.json', { extends: './../tsconfig.json', compilerOptions }); - createJsonFile(tree, 'src/tsconfig.tsc.json', { extends: './tsconfig.json', compilerOptions }); + createJsonFile(tree, 'src/tsconfig.base.json', { extends: './../tsconfig.json', compilerOptions }); + createJsonFile(tree, 'src/tsconfig.tsc.json', { extends: './tsconfig.base.json', compilerOptions }); createJsonFile(tree, 'src/tsconfig.app.json', { extends: './../tsconfig.common.json', compilerOptions }); createJsonFile(tree, 'src/tsconfig.spec.json', { extends: './../tsconfig.json', compilerOptions }); createJsonFile(tree, 'src/tsconfig.worker.json', { extends: './../tsconfig.json', compilerOptions }); }); - it(`should rename 'tsconfig.json' to 'tsconfig.base.json'`, async () => { + it(`should rename 'tsconfig.base.json' to 'tsconfig.json'`, async () => { const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise(); - expect(newTree.exists('tsconfig.base.json')).toBeTrue(); + expect(readJsonFile(newTree, 'tsconfig.json')['compilerOptions']).toBeTruthy(); + expect(newTree.exists('tsconfig.base.json')).toBeFalse(); }); - it(`should update extends from 'tsconfig.json' to 'tsconfig.base.json'`, async () => { + it(`should update extends from 'tsconfig.base.json' to 'tsconfig.json'`, async () => { const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise(); - expect(readJsonFile(newTree, 'src/tsconfig.json').extends).toEqual('./../tsconfig.base.json'); - expect(readJsonFile(newTree, 'src/tsconfig.spec.json').extends).toEqual('./../tsconfig.base.json'); - expect(readJsonFile(newTree, 'src/tsconfig.worker.json').extends).toEqual('./../tsconfig.base.json'); + expect(readJsonFile(newTree, 'src/tsconfig.spec.json').extends).toEqual('./../tsconfig.json'); + expect(readJsonFile(newTree, 'src/tsconfig.worker.json').extends).toEqual('./../tsconfig.json'); }); it('should not update extends if not extended the root tsconfig', async () => { const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise(); - expect(readJsonFile(newTree, 'src/tsconfig.tsc.json').extends).toEqual('./tsconfig.json'); - }); - - it('should add project referenced to root level tsconfig', async () => { - const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise(); - - expect(readJsonFile(newTree, 'tsconfig.json')).toEqual({ - files: [], - references: [ - { - path: './src/tsconfig.app.json', - }, - { - path: './src/tsconfig.worker.json', - }, - { - path: './src/tsconfig.spec.json', - }, - ], - }); + expect(readJsonFile(newTree, 'src/tsconfig.tsc.json').extends).toEqual('./tsconfig.base.json'); }); it('should not error out when a JSON file is a blank', async () => { tree.create('blank.json', ''); const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise(); - expect(readJsonFile(newTree, 'src/tsconfig.json').extends).toEqual('./../tsconfig.base.json'); + expect(readJsonFile(newTree, 'src/tsconfig.json').extends).toEqual('./../tsconfig.json'); }); it('should show warning with full path when parsing invalid JSON', async () => { const logs: string[] = []; schematicRunner.logger.subscribe(m => logs.push(m.message)); - tree.create('src/invalid/error.json', '{ invalid }'); + tree.create('src/invalid/error.json', `{ "extends": "./../../tsconfig.base.json", invalid }`); const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise(); - expect(readJsonFile(newTree, 'src/tsconfig.tsc.json').extends).toEqual('./tsconfig.json'); - expect(logs.join('\n')).toContain('Failed to parse "src/invalid/error.json" as JSON AST Object. Invalid JSON character'); + expect(readJsonFile(newTree, 'src/tsconfig.spec.json').extends).toEqual('./../tsconfig.json'); + expect(logs.join('\n')).toContain('Failed to parse "/src/invalid/error.json" as JSON AST Object. InvalidSymbol at location: 43.'); }); }); diff --git a/packages/schematics/angular/migrations/update-10/solution-style-tsconfig.ts b/packages/schematics/angular/migrations/update-10/solution-style-tsconfig.ts deleted file mode 100644 index df78bd6a56fa..000000000000 --- a/packages/schematics/angular/migrations/update-10/solution-style-tsconfig.ts +++ /dev/null @@ -1,141 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -import { JsonAstNode, JsonAstString, JsonParseMode, dirname, join, logging, normalize, parseJsonAst, resolve } from '@angular-devkit/core'; -import { DirEntry, Rule, chain } from '@angular-devkit/schematics'; -import { findPropertyInAstObject } from '../../utility/json-utils'; -import { getWorkspace } from '../../utility/workspace'; - -const SOLUTIONS_TS_CONFIG_HEADER = `/* - This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience. - It is not intended to be used to perform a compilation. - - To learn more about this file see: https://angular.io/config/solution-tsconfig. -*/ -`; - -function* visitExtendedJsonFiles(directory: DirEntry, logger: logging.LoggerApi): IterableIterator<[string, JsonAstString]> { - for (const path of directory.subfiles) { - if (!path.endsWith('.json')) { - continue; - } - - const entry = directory.file(path); - const content = entry?.content.toString(); - if (!content) { - continue; - } - - let jsonAst: JsonAstNode; - try { - jsonAst = parseJsonAst(content, JsonParseMode.Loose); - } catch (error) { - let jsonFilePath = `${join(directory.path, path)}`; - jsonFilePath = jsonFilePath.startsWith('/') ? jsonFilePath.substr(1) : jsonFilePath; - - const msg = error instanceof Error ? error.message : error; - logger.warn( - `Failed to parse "${jsonFilePath}" as JSON AST Object. ${msg}\n` + - 'If this is a TypeScript configuration file you will need to update the "extends" value manually.', - ); - continue; - } - - if (jsonAst.kind !== 'object') { - continue; - } - - const extendsAst = findPropertyInAstObject(jsonAst, 'extends'); - // Check if this config has the potential of extended the workspace tsconfig. - // Unlike tslint configuration, tsconfig "extends" cannot be an array. - if (extendsAst?.kind === 'string' && extendsAst.value.endsWith('tsconfig.json')) { - yield [join(directory.path, path), extendsAst]; - } - } - - for (const path of directory.subdirs) { - if (path === 'node_modules' || path.startsWith('.')) { - continue; - } - - yield* visitExtendedJsonFiles(directory.dir(path), logger); - } -} - -function updateTsconfigExtendsRule(): Rule { - return (host, context) => { - if (!host.exists('tsconfig.json')) { - return; - } - - // Rename workspace tsconfig to base tsconfig. - host.rename('tsconfig.json', 'tsconfig.base.json'); - - // Iterate over all tsconfig files and change the extends from 'tsconfig.json' 'tsconfig.base.json' - for (const [tsconfigPath, extendsAst] of visitExtendedJsonFiles(host.root, context.logger)) { - const tsConfigDir = dirname(normalize(tsconfigPath)); - if ('/tsconfig.json' !== resolve(tsConfigDir, normalize(extendsAst.value))) { - // tsconfig extends doesn't refer to the workspace tsconfig path. - continue; - } - - // Replace last path, json -> base.json - const recorder = host.beginUpdate(tsconfigPath); - const offset = extendsAst.end.offset - 5; - recorder.remove(offset, 4); - recorder.insertLeft(offset, 'base.json'); - host.commitUpdate(recorder); - } - }; -} - -function addSolutionTsConfigRule(): Rule { - return async host => { - const tsConfigPaths = new Set(); - const workspace = await getWorkspace(host); - - // Find all tsconfig which are refereces used by builders - for (const [, project] of workspace.projects) { - for (const [, target] of project.targets) { - if (!target.options) { - continue; - } - - for (const [key, value] of Object.entries(target.options)) { - if ((key === 'tsConfig' || key === 'webWorkerTsConfig') && typeof value === 'string') { - tsConfigPaths.add(value); - } - } - } - } - - // Generate the solutions style tsconfig/ - const tsConfigContent = { - files: [], - references: [...tsConfigPaths].map(p => ({ path: `./${p}` })), - }; - - host.create('tsconfig.json', SOLUTIONS_TS_CONFIG_HEADER + JSON.stringify(tsConfigContent, undefined, 2)); - }; -} - -export default function (): Rule { - return (host, context) => { - const logger = context.logger; - - if (host.exists('tsconfig.base.json')) { - logger.info('Migration has already been executed.'); - - return; - } - - return chain([ - updateTsconfigExtendsRule, - addSolutionTsConfigRule, - ]); - }; -} diff --git a/packages/schematics/angular/migrations/update-10/update-module-and-target-compiler-options.ts b/packages/schematics/angular/migrations/update-10/update-module-and-target-compiler-options.ts index 62642005a6da..ec4312c79707 100644 --- a/packages/schematics/angular/migrations/update-10/update-module-and-target-compiler-options.ts +++ b/packages/schematics/angular/migrations/update-10/update-module-and-target-compiler-options.ts @@ -23,13 +23,13 @@ export default function (): Rule { return async (host, { logger }) => { // Workspace level tsconfig try { - updateModuleAndTarget(host, 'tsconfig.base.json', { + updateModuleAndTarget(host, 'tsconfig.json', { oldModule: 'esnext', newModule: 'es2020', }); } catch (error) { logger.warn( - `Unable to update 'tsconfig.base.json' module option from 'esnext' to 'es2020': ${ + `Unable to update 'tsconfig.json' module option from 'esnext' to 'es2020': ${ error.message || error }`, ); diff --git a/packages/schematics/angular/migrations/update-10/update-module-and-target-compiler-options_spec.ts b/packages/schematics/angular/migrations/update-10/update-module-and-target-compiler-options_spec.ts index 5de9c28ccd2c..0e4736013256 100644 --- a/packages/schematics/angular/migrations/update-10/update-module-and-target-compiler-options_spec.ts +++ b/packages/schematics/angular/migrations/update-10/update-module-and-target-compiler-options_spec.ts @@ -91,7 +91,7 @@ describe('Migration to update target and module compiler options', () => { const compilerOptions = { target: 'es2015', module: 'esnext' }; // Workspace - createJsonFile(tree, 'tsconfig.base.json', { compilerOptions }); + createJsonFile(tree, 'tsconfig.json', { compilerOptions }); // Application createJsonFile(tree, 'src/tsconfig.app.json', { compilerOptions }); @@ -106,19 +106,19 @@ describe('Migration to update target and module compiler options', () => { createJsonFile(tree, 'src/tsconfig.server.json', { compilerOptions: { module: 'commonjs' } }); }); - it(`should update module and target in workspace 'tsconfig.base.json'`, async () => { + it(`should update module and target in workspace 'tsconfig.json'`, async () => { const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise(); - const { module } = readJsonFile(newTree, 'tsconfig.base.json').compilerOptions; + const { module } = readJsonFile(newTree, 'tsconfig.json').compilerOptions; expect(module).toBe('es2020'); }); - it(`should update module and target in 'tsconfig.base.json' which is referenced in option`, async () => { + it(`should update module and target in 'tsconfig.json' which is referenced in option`, async () => { const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise(); const { module } = readJsonFile(newTree, 'src/tsconfig.spec.json').compilerOptions; expect(module).toBe('es2020'); }); - it(`should update module and target in 'tsconfig.base.json' which is referenced in a configuration`, async () => { + it(`should update module and target in 'tsconfig.json' which is referenced in a configuration`, async () => { const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise(); const { module } = readJsonFile(newTree, 'src/tsconfig.app.prod.json').compilerOptions; expect(module).toBe('es2020'); diff --git a/packages/schematics/angular/migrations/update-9/update-app-tsconfigs_spec.ts b/packages/schematics/angular/migrations/update-9/update-app-tsconfigs_spec.ts index f4106272f13b..d9fca926bf1f 100644 --- a/packages/schematics/angular/migrations/update-9/update-app-tsconfigs_spec.ts +++ b/packages/schematics/angular/migrations/update-9/update-app-tsconfigs_spec.ts @@ -62,7 +62,7 @@ describe('Migration to version 9', () => { .toPromise(); // Pre version 9 - tsconfig.json was the base tsconfig file. - tree.overwrite('tsconfig.json', tree.readContent('tsconfig.base.json')); + tree.overwrite('tsconfig.json', tree.readContent('tsconfig.json')); }); it('should update apps tsConfig with stricter files inclusions', async () => { diff --git a/packages/schematics/angular/migrations/update-9/update-workspace-config_spec.ts b/packages/schematics/angular/migrations/update-9/update-workspace-config_spec.ts index defd2d76a5f4..9523041460df 100644 --- a/packages/schematics/angular/migrations/update-9/update-workspace-config_spec.ts +++ b/packages/schematics/angular/migrations/update-9/update-workspace-config_spec.ts @@ -82,7 +82,7 @@ describe('Migration to version 9', () => { .toPromise(); // Pre version 9 - tsconfig.json was the base tsconfig file. - tree.overwrite('tsconfig.json', tree.readContent('tsconfig.base.json')); + tree.overwrite('tsconfig.json', tree.readContent('tsconfig.json')); const tsConfig = JSON.stringify( { diff --git a/packages/schematics/angular/universal/index.ts b/packages/schematics/angular/universal/index.ts index 0d40359fb953..67d6be6f7be8 100644 --- a/packages/schematics/angular/universal/index.ts +++ b/packages/schematics/angular/universal/index.ts @@ -34,7 +34,6 @@ import { addPackageJsonDependency, getPackageJsonDependency } from '../utility/d import { findBootstrapModuleCall, findBootstrapModulePath } from '../utility/ng-ast-utils'; import { relativePathToWorkspaceRoot } from '../utility/paths'; import { targetBuildNotFoundError } from '../utility/project-targets'; -import { addTsConfigProjectReferences, verifyBaseTsConfigExists } from '../utility/tsconfig'; import { getWorkspace, updateWorkspace } from '../utility/workspace'; import { BrowserBuilderOptions, Builders, OutputHashing } from '../utility/workspace-models'; import { Schema as UniversalOptions } from './schema'; @@ -240,8 +239,6 @@ export default function (options: UniversalOptions): Rule { throw targetBuildNotFoundError(); } - verifyBaseTsConfigExists(host); - const clientBuildOptions = (clientBuildTarget.options || {}) as unknown as BrowserBuilderOptions; @@ -285,9 +282,6 @@ export default function (options: UniversalOptions): Rule { updateConfigFile(options, tsConfigDirectory), wrapBootstrapCall(clientBuildOptions.main), addServerTransition(options, clientBuildOptions.main, clientProject.root), - addTsConfigProjectReferences([ - join(tsConfigDirectory, 'tsconfig.server.json'), - ]), ]); }; } diff --git a/packages/schematics/angular/universal/index_spec.ts b/packages/schematics/angular/universal/index_spec.ts index 78e9d9de56f8..b5fb43a2f156 100644 --- a/packages/schematics/angular/universal/index_spec.ts +++ b/packages/schematics/angular/universal/index_spec.ts @@ -263,19 +263,4 @@ describe('Universal Schematic', () => { const contents = tree.readContent(filePath); expect(contents).toContain('@angular/localize/init'); }); - - it('should add reference in solution style tsconfig', async () => { - const tree = await schematicRunner.runSchematicAsync('universal', workspaceUniversalOptions, appTree) - .toPromise(); - - // tslint:disable-next-line:no-any - const { references } = parseJson(tree.readContent('/tsconfig.json').toString(), JsonParseMode.Loose) as any; - expect(references).toEqual([ - { path: './tsconfig.app.json' }, - { path: './tsconfig.spec.json' }, - { path: './projects/bar/tsconfig.app.json' }, - { path: './projects/bar/tsconfig.spec.json' }, - { path: './tsconfig.server.json' }, - ]); - }); }); diff --git a/packages/schematics/angular/utility/json-file.ts b/packages/schematics/angular/utility/json-file.ts index 96c8c4486bd6..e82d6899f096 100644 --- a/packages/schematics/angular/utility/json-file.ts +++ b/packages/schematics/angular/utility/json-file.ts @@ -8,7 +8,7 @@ import { JsonValue } from '@angular-devkit/core'; import { Tree } from '@angular-devkit/schematics'; -import { Node, applyEdits, findNodeAtLocation, getNodeValue, modify, parseTree } from 'jsonc-parser'; +import { Node, ParseError, applyEdits, findNodeAtLocation, getNodeValue, modify, parseTree, printParseErrorCode } from 'jsonc-parser'; export type InsertionIndex = (properties: string[]) => number; export type JSONPath = (string | number)[]; @@ -35,7 +35,12 @@ export class JSONFile { return this._jsonAst; } - this._jsonAst = parseTree(this.content); + const errors: ParseError[] = []; + this._jsonAst = parseTree(this.content, errors); + if (errors.length) { + const { error, offset } = errors[0]; + throw new Error(`Failed to parse "${this.path}" as JSON AST Object. ${printParseErrorCode(error)} at location: ${offset}.`); + } return this._jsonAst; } diff --git a/packages/schematics/angular/utility/tsconfig.ts b/packages/schematics/angular/utility/tsconfig.ts deleted file mode 100644 index 4d6679a1d863..000000000000 --- a/packages/schematics/angular/utility/tsconfig.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import { JsonParseMode, parseJsonAst } from '@angular-devkit/core'; -import { Rule, SchematicsException, Tree } from '@angular-devkit/schematics'; -import { appendValueInAstArray, findPropertyInAstObject } from './json-utils'; - -const SOLUTION_TSCONFIG_PATH = 'tsconfig.json'; - -/** - * Add project references in "Solution Style" tsconfig. - */ -export function addTsConfigProjectReferences(paths: string[]): Rule { - return (host, context) => { - const logger = context.logger; - - // We need to read after each write to avoid missing `,` when appending multiple items. - for (const path of paths) { - const source = host.read(SOLUTION_TSCONFIG_PATH); - if (!source) { - // Solution tsconfig doesn't exist. - logger.warn(`Cannot add reference '${path}' in '${SOLUTION_TSCONFIG_PATH}'. File doesn't exists.`); - - return; - } - - const jsonAst = parseJsonAst(source.toString(), JsonParseMode.Loose); - if (jsonAst?.kind !== 'object') { - // Invalid JSON - throw new SchematicsException(`Invalid JSON AST Object '${SOLUTION_TSCONFIG_PATH}'.`); - } - - // Solutions style tsconfig can contain 2 properties: - // - 'files' with a value of empty array - // - 'references' - const filesAst = findPropertyInAstObject(jsonAst, 'files'); - const referencesAst = findPropertyInAstObject(jsonAst, 'references'); - if ( - filesAst?.kind !== 'array' || - filesAst.elements.length !== 0 || - referencesAst?.kind !== 'array' - ) { - logger.warn(`Cannot add reference '${path}' in '${SOLUTION_TSCONFIG_PATH}'. It appears to be an invalid solution style tsconfig.`); - - return; - } - - // Append new paths - const recorder = host.beginUpdate(SOLUTION_TSCONFIG_PATH); - appendValueInAstArray(recorder, referencesAst, { 'path': `./${path}` }, 4); - host.commitUpdate(recorder); - } - }; -} - -/** - * Throws an exception when the base tsconfig doesn't exists. - */ -export function verifyBaseTsConfigExists(host: Tree): void { - if (host.exists('tsconfig.base.json')) { - return; - } - - throw new SchematicsException(`Cannot find base TypeScript configuration file 'tsconfig.base.json'.`); -} diff --git a/packages/schematics/angular/utility/tsconfig_spec.ts b/packages/schematics/angular/utility/tsconfig_spec.ts deleted file mode 100644 index 9f9a0f3516ba..000000000000 --- a/packages/schematics/angular/utility/tsconfig_spec.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import { EmptyTree, SchematicContext, Tree, callRule } from '@angular-devkit/schematics'; -import { addTsConfigProjectReferences } from './tsconfig'; - -const SOLUTION_TSCONFIG_PATH = 'tsconfig.json'; - -describe('addTsConfigProjectReference', () => { - const context = { - // tslint:disable-next-line:no-any - logger: {} as any, - } as SchematicContext; - - const createTsConfig = (content: object) => - tree.create(SOLUTION_TSCONFIG_PATH, JSON.stringify(content, undefined, 2)); - - const parseTsConfig = (tree: Tree) => - // tslint:disable-next-line:no-non-null-assertion - JSON.parse(tree.read(SOLUTION_TSCONFIG_PATH)!.toString()); - - let tree: Tree; - beforeEach(() => { - tree = new EmptyTree(); - }); - - it('works when references is an empty array', async () => { - createTsConfig({ - files: [], - references: [], - }); - - const result = await callRule( - addTsConfigProjectReferences(['foo/tsconfig.app.json']), - tree, - context, - ) - .toPromise(); - - // tslint:disable-next-line:no-non-null-assertion - const { references } = parseTsConfig(result); - expect(references).toEqual([ - { path: './foo/tsconfig.app.json' }, - ]); - }); - - it('works when references contains an element', async () => { - createTsConfig({ - files: [], - references: [ - { path: './foo/tsconfig.spec.json' }, - ], - }); - - const result = await callRule( - addTsConfigProjectReferences(['foo/tsconfig.app.json']), - tree, - context, - ) - .toPromise(); - - // tslint:disable-next-line:no-non-null-assertion - const { references } = parseTsConfig(result); - expect(references).toEqual([ - { path: './foo/tsconfig.spec.json' }, - { path: './foo/tsconfig.app.json' }, - ]); - }); - - it('works when adding multiple references and contains an element', async () => { - createTsConfig({ - files: [], - references: [ - { path: './foo/tsconfig.spec.json' }, - ], - }); - - const result = await callRule( - addTsConfigProjectReferences([ - 'foo/tsconfig.app.json', - 'foo/tsconfig.server.json', - ]), - tree, - context, - ) - .toPromise(); - - // tslint:disable-next-line:no-non-null-assertion - const { references } = parseTsConfig(result); - expect(references).toEqual([ - { path: './foo/tsconfig.spec.json' }, - { path: './foo/tsconfig.app.json' }, - { path: './foo/tsconfig.server.json' }, - ]); - }); -}); diff --git a/packages/schematics/angular/web-worker/files/worker-tsconfig/tsconfig.worker.json.template b/packages/schematics/angular/web-worker/files/worker-tsconfig/tsconfig.worker.json.template index ddfa6672080a..23267401fb74 100644 --- a/packages/schematics/angular/web-worker/files/worker-tsconfig/tsconfig.worker.json.template +++ b/packages/schematics/angular/web-worker/files/worker-tsconfig/tsconfig.worker.json.template @@ -1,6 +1,6 @@ /* To learn more about this file see: https://angular.io/config/tsconfig. */ { - "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.base.json", + "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.json", "compilerOptions": { "outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/worker", "lib": [ diff --git a/packages/schematics/angular/web-worker/index.ts b/packages/schematics/angular/web-worker/index.ts index f5ee05766f50..1ebf4942355b 100644 --- a/packages/schematics/angular/web-worker/index.ts +++ b/packages/schematics/angular/web-worker/index.ts @@ -19,7 +19,6 @@ import { import { JSONFile } from '../utility/json-file'; import { parseName } from '../utility/parse-name'; import { relativePathToWorkspaceRoot } from '../utility/paths'; -import { addTsConfigProjectReferences, verifyBaseTsConfigExists } from '../utility/tsconfig'; import { buildDefaultPath, getWorkspace, updateWorkspace } from '../utility/workspace'; import { BrowserBuilderOptions, LintBuilderOptions } from '../utility/workspace-models'; import { Schema as WebWorkerOptions } from './schema'; @@ -118,8 +117,6 @@ export default function (options: WebWorkerOptions): Rule { throw new SchematicsException(`Web Worker requires a project type of "application".`); } - verifyBaseTsConfigExists(host); - const projectTarget = project.targets.get(options.target); if (!projectTarget) { throw new Error(`Target is not defined for this project.`); @@ -160,9 +157,6 @@ export default function (options: WebWorkerOptions): Rule { options.snippet ? addSnippet(options) : noop(), // Add the worker. mergeWith(templateSource), - addTsConfigProjectReferences([ - `${root}/tsconfig.worker.json`, - ]), ]); }; } diff --git a/packages/schematics/angular/web-worker/index_spec.ts b/packages/schematics/angular/web-worker/index_spec.ts index 2dc9b539ffc4..066be368f57e 100644 --- a/packages/schematics/angular/web-worker/index_spec.ts +++ b/packages/schematics/angular/web-worker/index_spec.ts @@ -136,7 +136,7 @@ describe('Web Worker Schematic', () => { appTree.overwrite('/angular.json', JSON.stringify(workspace)); const oldTsConfig = { - extends: '../../../tsconfig.base.json', + extends: '../../../tsconfig.json', include: [ '**/*.ts', ], @@ -152,17 +152,4 @@ describe('Web Worker Schematic', () => { const { exclude } = JSON.parse(tree.readContent(tsConfigPath)); expect(exclude).toContain('**/*.worker.ts'); }); - - it('should add reference in solution style tsconfig', async () => { - const tree = await schematicRunner.runSchematicAsync('web-worker', defaultOptions, appTree) - .toPromise(); - - // tslint:disable-next-line:no-any - const { references } = parseJson(tree.readContent('/tsconfig.json').toString(), JsonParseMode.Loose) as any; - expect(references).toEqual([ - { path: './projects/bar/tsconfig.app.json' }, - { path: './projects/bar/tsconfig.spec.json' }, - { path: './projects/bar/tsconfig.worker.json' }, - ]); - }); }); diff --git a/packages/schematics/angular/workspace/files/tsconfig.base.json.template b/packages/schematics/angular/workspace/files/tsconfig.base.json.template deleted file mode 100644 index f0dcc4b97596..000000000000 --- a/packages/schematics/angular/workspace/files/tsconfig.base.json.template +++ /dev/null @@ -1,28 +0,0 @@ -/* To learn more about this file see: https://angular.io/config/tsconfig. */ -{ - "compileOnSave": false, - "compilerOptions": { - "baseUrl": "./", - "outDir": "./dist/out-tsc",<% if (strict) { %> - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true,<% } %> - "sourceMap": true, - "declaration": false, - "downlevelIteration": true, - "experimentalDecorators": true, - "moduleResolution": "node", - "importHelpers": true, - "target": "es2015", - "module": "es2020", - "lib": [ - "es2018", - "dom" - ] - }<% if (strict) { %>, - "angularCompilerOptions": { - "strictInjectionParameters": true, - "strictTemplates": true - }<% } %> -} diff --git a/packages/schematics/angular/workspace/files/tsconfig.json.template b/packages/schematics/angular/workspace/files/tsconfig.json.template index 1a60f07af1cf..f0dcc4b97596 100644 --- a/packages/schematics/angular/workspace/files/tsconfig.json.template +++ b/packages/schematics/angular/workspace/files/tsconfig.json.template @@ -1,10 +1,28 @@ -/* - This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience. - It is not intended to be used to perform a compilation. - - To learn more about this file see: https://angular.io/config/solution-tsconfig. -*/ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ { - "files": [], - "references": [] + "compileOnSave": false, + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist/out-tsc",<% if (strict) { %> + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true,<% } %> + "sourceMap": true, + "declaration": false, + "downlevelIteration": true, + "experimentalDecorators": true, + "moduleResolution": "node", + "importHelpers": true, + "target": "es2015", + "module": "es2020", + "lib": [ + "es2018", + "dom" + ] + }<% if (strict) { %>, + "angularCompilerOptions": { + "strictInjectionParameters": true, + "strictTemplates": true + }<% } %> } diff --git a/packages/schematics/angular/workspace/index_spec.ts b/packages/schematics/angular/workspace/index_spec.ts index c8a78d9a047a..2781fe7dba5e 100644 --- a/packages/schematics/angular/workspace/index_spec.ts +++ b/packages/schematics/angular/workspace/index_spec.ts @@ -33,7 +33,6 @@ describe('Workspace Schematic', () => { '/package.json', '/README.md', '/tsconfig.json', - '/tsconfig.base.json', '/tslint.json', ])); }); @@ -68,7 +67,6 @@ describe('Workspace Schematic', () => { '/package.json', '/README.md', '/tsconfig.json', - '/tsconfig.base.json', ])); expect(files).not.toContain('/tslint.json'); @@ -79,7 +77,7 @@ describe('Workspace Schematic', () => { const tree = await schematicRunner.runSchematicAsync('workspace', { ...defaultOptions, strict: false }).toPromise(); const { compilerOptions, angularCompilerOptions } = // tslint:disable-next-line: no-any - parseJson(tree.readContent('tsconfig.base.json').toString(), JsonParseMode.Loose) as any; + parseJson(tree.readContent('tsconfig.json').toString(), JsonParseMode.Loose) as any; expect(compilerOptions.strict).toBeUndefined(); expect(angularCompilerOptions).toBeUndefined(); }); @@ -88,7 +86,7 @@ describe('Workspace Schematic', () => { const tree = await schematicRunner.runSchematicAsync('workspace', { ...defaultOptions, strict: true }).toPromise(); const { compilerOptions, angularCompilerOptions } = // tslint:disable-next-line: no-any - parseJson(tree.readContent('tsconfig.base.json').toString(), JsonParseMode.Loose) as any; + parseJson(tree.readContent('tsconfig.json').toString(), JsonParseMode.Loose) as any; expect(compilerOptions.strict).toBe(true); expect(angularCompilerOptions.strictTemplates).toBe(true); }); diff --git a/tests/legacy-cli/e2e/setup/500-create-project.ts b/tests/legacy-cli/e2e/setup/500-create-project.ts index 0bb253a36ee5..c166b8e122de 100644 --- a/tests/legacy-cli/e2e/setup/500-create-project.ts +++ b/tests/legacy-cli/e2e/setup/500-create-project.ts @@ -23,7 +23,7 @@ export default async function() { process.chdir('./test-project'); if (argv['ve']) { - await updateJsonFile('tsconfig.base.json', config => { + await updateJsonFile('tsconfig.json', config => { const { angularCompilerOptions = {} } = config; angularCompilerOptions.enableIvy = false; config.angularCompilerOptions = angularCompilerOptions; diff --git a/tests/legacy-cli/e2e/tests/basic/ivy-opt-out.ts b/tests/legacy-cli/e2e/tests/basic/ivy-opt-out.ts index 71f87a3bb4db..5c6e0c913dc9 100644 --- a/tests/legacy-cli/e2e/tests/basic/ivy-opt-out.ts +++ b/tests/legacy-cli/e2e/tests/basic/ivy-opt-out.ts @@ -21,7 +21,7 @@ export default async function() { await ng('e2e', '--prod'); // View Engine (NGC) compilation should work after running NGCC from Webpack - await updateJsonFile('tsconfig.base.json', config => { + await updateJsonFile('tsconfig.json', config => { const { angularCompilerOptions = {} } = config; angularCompilerOptions.enableIvy = false; config.angularCompilerOptions = angularCompilerOptions; diff --git a/tests/legacy-cli/e2e/tests/build/worker.ts b/tests/legacy-cli/e2e/tests/build/worker.ts index b5173ec41b8c..c509abec9590 100644 --- a/tests/legacy-cli/e2e/tests/build/worker.ts +++ b/tests/legacy-cli/e2e/tests/build/worker.ts @@ -13,7 +13,7 @@ import { expectToFail } from '../../utils/utils'; export default async function () { const workerPath = join('src', 'app', 'app.worker.ts'); const snippetPath = join('src', 'app', 'app.component.ts'); - const projectTsConfig = 'tsconfig.base.json'; + const projectTsConfig = 'tsconfig.json'; const workerTsConfig = 'tsconfig.worker.json'; // Enable Differential loading to run both size checks diff --git a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-dl-xliff2.ts b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-dl-xliff2.ts index db6d4871cf9a..c12e80c41cda 100644 --- a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-dl-xliff2.ts +++ b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-dl-xliff2.ts @@ -20,7 +20,7 @@ export async function executeTest() { 'IE 11', ); - await updateJsonFile('tsconfig.base.json', config => { + await updateJsonFile('tsconfig.json', config => { config.compilerOptions.target = 'es2015'; if (!config.angularCompilerOptions) { config.angularCompilerOptions = {}; diff --git a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-es2015.ts b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-es2015.ts index 45f0785b94a9..fcb41e30d8b5 100644 --- a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-es2015.ts +++ b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-es2015.ts @@ -10,7 +10,7 @@ export default async function() { // Ensure a ES2015 build is used. await writeFile('.browserslistrc', 'Chrome 65'); - await updateJsonFile('tsconfig.base.json', config => { + await updateJsonFile('tsconfig.json', config => { config.compilerOptions.target = 'es2015'; if (!config.angularCompilerOptions) { config.angularCompilerOptions = {}; diff --git a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-es5.ts b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-es5.ts index 8a9fcac4f328..223100b20292 100644 --- a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-es5.ts +++ b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-es5.ts @@ -9,7 +9,7 @@ export default async function() { await setupI18nConfig(); // Ensure a es5 build is used. - await updateJsonFile('tsconfig.base.json', config => { + await updateJsonFile('tsconfig.json', config => { config.compilerOptions.target = 'es5'; if (!config.angularCompilerOptions) { config.angularCompilerOptions = {}; diff --git a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-serviceworker.ts b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-serviceworker.ts index ec10a863c9bf..242b878054fe 100644 --- a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-serviceworker.ts +++ b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-serviceworker.ts @@ -32,7 +32,7 @@ export default async function() { } await npm('install', `${serviceWorkerVersion}`); - await updateJsonFile('tsconfig.base.json', config => { + await updateJsonFile('tsconfig.json', config => { config.compilerOptions.target = 'es2015'; if (!config.angularCompilerOptions) { config.angularCompilerOptions = {}; diff --git a/tests/legacy-cli/e2e/tests/i18n/ve-localize-es2015.ts b/tests/legacy-cli/e2e/tests/i18n/ve-localize-es2015.ts index fe6e6a7758d7..19d5a45778ed 100644 --- a/tests/legacy-cli/e2e/tests/i18n/ve-localize-es2015.ts +++ b/tests/legacy-cli/e2e/tests/i18n/ve-localize-es2015.ts @@ -23,7 +23,7 @@ export default async function() { // Ensure a ES2015 build is used. await writeFile('.browserslistrc', 'Chrome 65'); - await updateJsonFile('tsconfig.base.json', config => { + await updateJsonFile('tsconfig.json', config => { config.compilerOptions.target = 'es2015'; if (!config.angularCompilerOptions) { config.angularCompilerOptions = {}; diff --git a/tests/legacy-cli/e2e/tests/misc/es5-polyfills.ts b/tests/legacy-cli/e2e/tests/misc/es5-polyfills.ts index 21ac1949c472..3a7e6ccb90a8 100644 --- a/tests/legacy-cli/e2e/tests/misc/es5-polyfills.ts +++ b/tests/legacy-cli/e2e/tests/misc/es5-polyfills.ts @@ -4,7 +4,7 @@ import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; export default async function () { - await updateJsonFile('tsconfig.base.json', configJson => { + await updateJsonFile('tsconfig.json', configJson => { const compilerOptions = configJson['compilerOptions']; compilerOptions['target'] = 'es5'; }); diff --git a/tests/legacy-cli/e2e/tests/misc/forwardref-es2015.ts b/tests/legacy-cli/e2e/tests/misc/forwardref-es2015.ts index 6faeba5f2b1e..497f60aab160 100644 --- a/tests/legacy-cli/e2e/tests/misc/forwardref-es2015.ts +++ b/tests/legacy-cli/e2e/tests/misc/forwardref-es2015.ts @@ -36,7 +36,7 @@ export default async function() { // Turn on emitDecoratorMetadata await replaceInFile( - 'tsconfig.base.json', + 'tsconfig.json', '"experimentalDecorators": true', '"experimentalDecorators": true, "emitDecoratorMetadata": true', ); diff --git a/tests/legacy-cli/e2e/tests/misc/module-resolution.ts b/tests/legacy-cli/e2e/tests/misc/module-resolution.ts index 7acba1b81eaa..0396650258c7 100644 --- a/tests/legacy-cli/e2e/tests/misc/module-resolution.ts +++ b/tests/legacy-cli/e2e/tests/misc/module-resolution.ts @@ -5,7 +5,7 @@ import { expectToFail } from '../../utils/utils'; export default async function () { - await updateJsonFile('tsconfig.base.json', tsconfig => { + await updateJsonFile('tsconfig.json', tsconfig => { tsconfig.compilerOptions.paths = { '*': ['./node_modules/*'], }; @@ -20,14 +20,14 @@ export default async function () { await expectToFail(() => ng('build')); - await updateJsonFile('tsconfig.base.json', tsconfig => { + await updateJsonFile('tsconfig.json', tsconfig => { tsconfig.compilerOptions.paths = { '@angular/common': [ './xyz/common' ], }; }); await ng('build'); - await updateJsonFile('tsconfig.base.json', tsconfig => { + await updateJsonFile('tsconfig.json', tsconfig => { tsconfig.compilerOptions.paths = { '*': ['./node_modules/*'], '@angular/common': [ './xyz/common' ], @@ -35,7 +35,7 @@ export default async function () { }); await ng('build'); - await updateJsonFile('tsconfig.base.json', tsconfig => { + await updateJsonFile('tsconfig.json', tsconfig => { tsconfig.compilerOptions.paths = { '@angular/common': [ './xyz/common' ], '*': ['./node_modules/*'], @@ -43,7 +43,7 @@ export default async function () { }); await ng('build'); - await updateJsonFile('tsconfig.base.json', tsconfig => { + await updateJsonFile('tsconfig.json', tsconfig => { delete tsconfig.compilerOptions.paths; }); @@ -58,12 +58,12 @@ export default async function () { await ng('build', '--aot'); await ng('test', '--watch=false'); - await updateJsonFile('tsconfig.base.json', tsconfig => { + await updateJsonFile('tsconfig.json', tsconfig => { tsconfig.compilerOptions.paths = {}; }); await ng('build'); - await updateJsonFile('tsconfig.base.json', tsconfig => { + await updateJsonFile('tsconfig.json', tsconfig => { tsconfig.compilerOptions.paths = { '@app/*': ['*'], '@lib/*/test': ['*/test'], @@ -71,14 +71,14 @@ export default async function () { }); await ng('build'); - await updateJsonFile('tsconfig.base.json', tsconfig => { + await updateJsonFile('tsconfig.json', tsconfig => { tsconfig.compilerOptions.paths = { '@firebase/polyfill': ['./node_modules/@firebase/polyfill/index.ts'], }; }); await expectToFail(() => ng('build')); - await updateJsonFile('tsconfig.base.json', tsconfig => { + await updateJsonFile('tsconfig.json', tsconfig => { tsconfig.compilerOptions.paths = { '@firebase/polyfill*': ['./node_modules/@firebase/polyfill/index.ts'], }; diff --git a/tests/legacy-cli/e2e/tests/misc/trace-resolution.ts b/tests/legacy-cli/e2e/tests/misc/trace-resolution.ts index 68b3fef7bec4..30c8113ce9ec 100644 --- a/tests/legacy-cli/e2e/tests/misc/trace-resolution.ts +++ b/tests/legacy-cli/e2e/tests/misc/trace-resolution.ts @@ -2,7 +2,7 @@ import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; export default async function () { - await updateJsonFile('tsconfig.base.json', tsconfig => { + await updateJsonFile('tsconfig.json', tsconfig => { tsconfig.compilerOptions.traceResolution = true; }); @@ -11,7 +11,7 @@ export default async function () { throw new Error(`Modules resolutions must be printed when 'traceResolution' is enabled.`); } - await updateJsonFile('tsconfig.base.json', tsconfig => { + await updateJsonFile('tsconfig.json', tsconfig => { tsconfig.compilerOptions.traceResolution = false; }); diff --git a/tests/legacy-cli/e2e/tests/misc/universal-bundle-dependencies.ts b/tests/legacy-cli/e2e/tests/misc/universal-bundle-dependencies.ts index 6b14d6ec1105..f00c1087589e 100644 --- a/tests/legacy-cli/e2e/tests/misc/universal-bundle-dependencies.ts +++ b/tests/legacy-cli/e2e/tests/misc/universal-bundle-dependencies.ts @@ -28,7 +28,7 @@ export default async function() { await writeMultipleFiles({ './tsconfig.server.json': ` { - "extends": "./tsconfig.base.json", + "extends": "./tsconfig.json", "compilerOptions": { "outDir": "../dist-server", "baseUrl": "./", diff --git a/tests/legacy-cli/e2e/tests/test/test-target.ts b/tests/legacy-cli/e2e/tests/test/test-target.ts index c9f79c64cff9..ba1afd13d1c2 100644 --- a/tests/legacy-cli/e2e/tests/test/test-target.ts +++ b/tests/legacy-cli/e2e/tests/test/test-target.ts @@ -6,7 +6,7 @@ export default function () { // TypeError: Assignment to constant variable. return; - return updateJsonFile('tsconfig.base.json', configJson => { + return updateJsonFile('tsconfig.json', configJson => { const compilerOptions = configJson['compilerOptions']; compilerOptions['target'] = 'es2015'; }) diff --git a/tests/legacy-cli/e2e/utils/project.ts b/tests/legacy-cli/e2e/utils/project.ts index 53008ed4dbb1..e494e8f35c77 100644 --- a/tests/legacy-cli/e2e/utils/project.ts +++ b/tests/legacy-cli/e2e/utils/project.ts @@ -6,7 +6,7 @@ import { prependToFile, readFile, replaceInFile, writeFile } from './fs'; import { gitCommit } from './git'; import { execAndWaitForOutputToMatch, git, ng, npm, silentNpm } from './process'; -const tsConfigPath = 'tsconfig.base.json'; +const tsConfigPath = 'tsconfig.json'; export function updateJsonFile(filePath: string, fn: (json: any) => any | void) { @@ -40,10 +40,10 @@ export async function createProject(name: string, ...args: string[]) { await ng('new', name, '--skip-install', ...extraArgs, ...args); process.chdir(name); - if (fs.existsSync('tsconfig.base.json')) { + if (fs.existsSync('tsconfig.json')) { // Disable the TS version check to make TS updates easier. // Only VE does it, but on Ivy the i18n extraction uses VE. - await updateJsonFile('tsconfig.base.json', config => { + await updateJsonFile('tsconfig.json', config => { if (!config.angularCompilerOptions) { config.angularCompilerOptions = {}; } @@ -102,7 +102,7 @@ export async function prepareProjectForE2e(name) { ); // Force sourcemaps to be from the root of the filesystem. await updateJsonFile( - 'tsconfig.base.json', + 'tsconfig.json', json => { json[ 'compilerOptions'