Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 9x 6x 3x 3x 3x 3x 1x 1x | import { Rule, Tree } from '@angular-devkit/schematics';
import * as path from 'path';
import { getWorkspace } from '../utils/backbase/package-utils';
import { readJsonFile } from './utils/json';
import { tryRule } from './utils/rules';
const tsConfigFileName = 'tsconfig.app.json';
const newCompilerOptions = { module: 'es2015' };
const manualProcess = `
## Please add "module": "es2015" to the compilerOptions of your apps tsconfig.app.json;
So your file should look like this:
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/app",
"types": [],
"module": "es2015"
},
"include": [
"src/**/*.ts"
],
"exclude": [
"src/test.ts",
"src/**/*.spec.ts"
]
}
`;
export default function (): Rule {
return tryRule(async (tree: Tree) => {
const workspace = await getWorkspace(tree);
const projects: string[] = [...workspace.projects]
.filter(([, project]) => project.extensions.projectType === 'application')
.filter(([, project]) => project.targets.has('build'))
.map(([, project]) => project.root);
for (const appRootFolder of projects) {
const tsConfigPath = path.join(appRootFolder, tsConfigFileName);
const currentConfig: { [key: string]: any } = readJsonFile(tree, tsConfigPath);
const newConfig = {
...currentConfig,
compilerOptions: {
...currentConfig.compilerOptions,
...newCompilerOptions,
},
};
tree.overwrite(tsConfigPath, JSON.stringify(newConfig, null, 2));
}
}, manualProcess);
}
|