Skip to content

Commit

Permalink
fix(localize): ng-add schematics for application builder
Browse files Browse the repository at this point in the history
The schematics now supports the `application` builder, which is the new default builder in an application built with the CLI v17
  • Loading branch information
cexbrayat committed Sep 14, 2023
1 parent a2681c7 commit afd1e15
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/localize/schematics/ng-add/index.ts
Expand Up @@ -35,6 +35,7 @@ function addTypeScriptConfigTypes(projectName: string): Rule {
case Builders.Karma:
case Builders.Server:
case Builders.Browser:
case Builders.Application:
const value = target.options?.['tsConfig'];
if (typeof value === 'string') {
tsConfigFiles.add(value);
Expand All @@ -48,6 +49,11 @@ function addTypeScriptConfigTypes(projectName: string): Rule {
if (typeof value === 'string') {
addTripleSlashType(host, value);
}
} else if (target.builder === Builders.Application) {
const value = target.options?.['browser'];
if (typeof value === 'string') {
addTripleSlashType(host, value);
}
}
}

Expand Down
23 changes: 23 additions & 0 deletions packages/localize/schematics/ng-add/index_spec.ts
Expand Up @@ -45,6 +45,13 @@ describe('ng-add schematic', () => {
'demo': {
root: '',
architect: {
application: {
builder: '@angular-devkit/build-angular:application',
options: {
browser: './main.ts',
tsConfig: './tsconfig.application.json',
},
},
build: {
builder: '@angular-devkit/build-angular:browser',
options: {
Expand Down Expand Up @@ -126,6 +133,22 @@ describe('ng-add schematic', () => {
expect(types).toHaveSize(2);
});

it(`should add '@angular/localize' in 'types' tsconfigs referenced in application builder`,
async () => {
const tsConfig = JSON.stringify({
compilerOptions: {
types: ['node'],
},
});

host.create('tsconfig.application.json', tsConfig);

host = await schematicRunner.runSchematic('ng-add', defaultOptions, host);
const {compilerOptions} = host.readJson('tsconfig.application.json') as TsConfig;
const types = compilerOptions?.types;
expect(types).toContain('@angular/localize');
expect(types).toHaveSize(2);
});

it(`should add '@angular/localize' in 'types' tsconfigs referenced in karma builder`,
async () => {
Expand Down

0 comments on commit afd1e15

Please sign in to comment.