refactor(ngcc): export magic strings as constants (#35079)
These strings will be used when cleaning up outdated packages. PR Close #35079
This commit is contained in:
parent
3cf55c195b
commit
16e15f50d2
|
@ -12,6 +12,7 @@ import {EntryPointBundle} from '../packages/entry_point_bundle';
|
|||
import {FileToWrite} from '../rendering/utils';
|
||||
import {FileWriter} from './file_writer';
|
||||
|
||||
export const NGCC_BACKUP_EXTENSION = '.__ivy_ngcc_bak';
|
||||
/**
|
||||
* This FileWriter overwrites the transformed file, in-place, while creating
|
||||
* a back-up of the original file with an extra `.__ivy_ngcc_bak` extension.
|
||||
|
@ -27,7 +28,7 @@ export class InPlaceFileWriter implements FileWriter {
|
|||
|
||||
protected writeFileAndBackup(file: FileToWrite): void {
|
||||
this.fs.ensureDir(dirname(file.path));
|
||||
const backPath = absoluteFrom(`${file.path}.__ivy_ngcc_bak`);
|
||||
const backPath = absoluteFrom(`${file.path}${NGCC_BACKUP_EXTENSION}`);
|
||||
if (this.fs.exists(backPath)) {
|
||||
throw new Error(
|
||||
`Tried to overwrite ${backPath} with an ngcc back up file, which is disallowed.`);
|
||||
|
|
|
@ -15,7 +15,8 @@ import {FileToWrite} from '../rendering/utils';
|
|||
import {InPlaceFileWriter} from './in_place_file_writer';
|
||||
import {PackageJsonUpdater} from './package_json_updater';
|
||||
|
||||
const NGCC_DIRECTORY = '__ivy_ngcc__';
|
||||
export const NGCC_DIRECTORY = '__ivy_ngcc__';
|
||||
export const NGCC_PROPERTY_EXTENSION = '_ivy_ngcc';
|
||||
|
||||
/**
|
||||
* This FileWriter creates a copy of the original entry-point, then writes the transformed
|
||||
|
@ -93,7 +94,8 @@ export class NewEntryPointFileWriter extends InPlaceFileWriter {
|
|||
`(${formatProperties.join(', ')}) map to more than one format-path.`);
|
||||
}
|
||||
|
||||
update.addChange([`${formatProperty}_ivy_ngcc`], newFormatPath, {before: formatProperty});
|
||||
update.addChange(
|
||||
[`${formatProperty}${NGCC_PROPERTY_EXTENSION}`], newFormatPath, {before: formatProperty});
|
||||
}
|
||||
|
||||
update.writeChanges(packageJsonPath, packageJson);
|
||||
|
|
Loading…
Reference in New Issue