Skip to content

Commit 58efd86

Browse files
aparzithePunderWoman
authored andcommitted
fix(migrations): migration skip any target are not build or test
Fix migration behaviout that skip any target are not build or test Fixes angular#66865
1 parent 32d7315 commit 58efd86

2 files changed

Lines changed: 39 additions & 7 deletions

File tree

‎packages/core/schematics/test/inject_migration_spec.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,6 +2054,42 @@ describe('inject migration', () => {
20542054
]);
20552055
});
20562056

2057+
it('should work with an esbuild target in angular.json', async () => {
2058+
writeFile(
2059+
'/angular.json',
2060+
JSON.stringify({
2061+
version: 1,
2062+
projects: {
2063+
t: {
2064+
root: '',
2065+
architect: {
2066+
esbuild: {
2067+
options: {tsConfig: './tsconfig.json'},
2068+
},
2069+
},
2070+
},
2071+
},
2072+
}),
2073+
);
2074+
2075+
writeFile(
2076+
'/dir.ts',
2077+
[
2078+
`import { Directive } from '@angular/core';`,
2079+
`import { Foo } from 'foo';`,
2080+
``,
2081+
`@Directive()`,
2082+
`class MyDir {`,
2083+
` constructor(private foo: Foo) {}`,
2084+
`}`,
2085+
].join('\n'),
2086+
);
2087+
2088+
await runMigration();
2089+
2090+
expect(tree.readContent('/dir.ts')).toContain('private foo = inject(Foo);');
2091+
});
2092+
20572093
describe('internal-only behavior', () => {
20582094
function runInternalMigration(
20592095
{replaceParameterReferences} = {replaceParameterReferences: true},

‎packages/core/schematics/utils/project_tsconfig_paths.ts‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,17 @@ export async function getProjectTsConfigPaths(
2424
const workspace = await getWorkspace(tree);
2525
for (const [, project] of workspace.projects) {
2626
for (const [name, target] of project.targets) {
27-
if (name !== 'build' && name !== 'test') {
28-
continue;
29-
}
30-
3127
for (const [, options] of allTargetOptions(target)) {
3228
const tsConfig = options['tsConfig'];
3329
// Filter out tsconfig files that don't exist in the CLI project.
3430
if (typeof tsConfig !== 'string' || !tree.exists(tsConfig)) {
3531
continue;
3632
}
3733

38-
if (name === 'build') {
39-
buildPaths.add(normalize(tsConfig));
40-
} else {
34+
if (name === 'test' || name.includes('test')) {
4135
testPaths.add(normalize(tsConfig));
36+
} else {
37+
buildPaths.add(normalize(tsConfig));
4238
}
4339
}
4440
}

0 commit comments

Comments
 (0)