refactor(migrations): ensure tsurge configures file system properly (#61553)

Currently in 1P, without this commit, the tsconfig parsing picks up the
default file system (InvalidFS) and results in runtime errors.

PR Close #61553
This commit is contained in:
Paul Gschwendtner
2025-05-21 07:53:22 +00:00
committed by Jessica Janiuk
parent 7adbb9c693
commit 08f7d21d5c
2 changed files with 8 additions and 10 deletions
@@ -6,13 +6,11 @@
* found in the LICENSE file at https://angular.dev/license
*/
import {absoluteFrom, FileSystem} from '@angular/compiler-cli/src/ngtsc/file_system';
import {NgCompilerOptions} from '@angular/compiler-cli/src/ngtsc/core/api';
import {getRootDirs} from '@angular/compiler-cli/src/ngtsc/util/src/typescript';
import {isShim} from '@angular/compiler-cli/src/ngtsc/shims';
import {ProgramInfo} from './program_info';
import {Serializable} from './helpers/serializable';
import {FileSystem} from '@angular/compiler-cli/src/ngtsc/file_system';
import {createBaseProgramInfo, getProgramInfoFromBaseInfo} from './helpers/create_program';
import {Serializable} from './helpers/serializable';
import {ProgramInfo} from './program_info';
/** Type helper extracting the stats type of a migration. */
export type MigrationStats<T> =
@@ -25,13 +25,13 @@ import {createPlainTsProgram} from './ts_program';
/** Creates the base program info for the given tsconfig path. */
export function createBaseProgramInfo(
absoluteTsconfigPath: string,
fs?: FileSystem,
fs: FileSystem,
optionOverrides: NgCompilerOptions = {},
): BaseProgramInfo {
if (fs === undefined) {
fs = new NodeJSFileSystem();
setFileSystem(fs);
}
// Make sure the FS becomes globally available. Some code paths
// of the Angular compiler, or tsconfig parsing aren't leveraging
// the specified file system.
setFileSystem(fs);
const tsconfig = parseTsconfigOrDie(absoluteTsconfigPath, fs);
const tsHost = new NgtscCompilerHost(fs, tsconfig.options);