refactor(ivy): ngcc - remove redundant `entryPoint` argument from `writeBundle()` (#32052)
The entry-point is already available through the `bundle` argument, so passing it separately is redundant. PR Close #32052
This commit is contained in:
parent
ed70f73794
commit
93d27eefd5
|
@ -171,7 +171,7 @@ export function mainNgcc(
|
|||
logger.info(`Compiling ${entryPoint.name} : ${formatProperty} as ${format}`);
|
||||
|
||||
const transformedFiles = transformer.transform(bundle);
|
||||
fileWriter.writeBundle(entryPoint, bundle, transformedFiles, formatProperty);
|
||||
fileWriter.writeBundle(bundle, transformedFiles, formatProperty);
|
||||
|
||||
onTaskCompleted(task, TaskProcessingOutcome.Processed);
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {EntryPoint, EntryPointJsonProperty} from '../packages/entry_point';
|
||||
import {EntryPointJsonProperty} from '../packages/entry_point';
|
||||
import {EntryPointBundle} from '../packages/entry_point_bundle';
|
||||
import {FileToWrite} from '../rendering/utils';
|
||||
|
||||
|
@ -15,6 +15,6 @@ import {FileToWrite} from '../rendering/utils';
|
|||
*/
|
||||
export interface FileWriter {
|
||||
writeBundle(
|
||||
entryPoint: EntryPoint, bundle: EntryPointBundle, transformedFiles: FileToWrite[],
|
||||
bundle: EntryPointBundle, transformedFiles: FileToWrite[],
|
||||
formatProperty: EntryPointJsonProperty): void;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {FileSystem, absoluteFrom, dirname} from '../../../src/ngtsc/file_system';
|
||||
import {EntryPoint, EntryPointJsonProperty} from '../packages/entry_point';
|
||||
import {EntryPointJsonProperty} from '../packages/entry_point';
|
||||
import {EntryPointBundle} from '../packages/entry_point_bundle';
|
||||
import {FileToWrite} from '../rendering/utils';
|
||||
import {FileWriter} from './file_writer';
|
||||
|
@ -20,7 +20,7 @@ export class InPlaceFileWriter implements FileWriter {
|
|||
constructor(protected fs: FileSystem) {}
|
||||
|
||||
writeBundle(
|
||||
_entryPoint: EntryPoint, _bundle: EntryPointBundle, transformedFiles: FileToWrite[],
|
||||
_bundle: EntryPointBundle, transformedFiles: FileToWrite[],
|
||||
_formatProperty?: EntryPointJsonProperty) {
|
||||
transformedFiles.forEach(file => this.writeFileAndBackup(file));
|
||||
}
|
||||
|
|
|
@ -26,9 +26,10 @@ const NGCC_DIRECTORY = '__ivy_ngcc__';
|
|||
*/
|
||||
export class NewEntryPointFileWriter extends InPlaceFileWriter {
|
||||
writeBundle(
|
||||
entryPoint: EntryPoint, bundle: EntryPointBundle, transformedFiles: FileToWrite[],
|
||||
bundle: EntryPointBundle, transformedFiles: FileToWrite[],
|
||||
formatProperty: EntryPointJsonProperty) {
|
||||
// The new folder is at the root of the overall package
|
||||
const entryPoint = bundle.entryPoint;
|
||||
const ngccFolder = join(entryPoint.package, NGCC_DIRECTORY);
|
||||
this.copyBundle(bundle, entryPoint.package, ngccFolder);
|
||||
transformedFiles.forEach(file => this.writeFile(file, entryPoint.package, ngccFolder));
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import {absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_system';
|
||||
import {runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
||||
import {loadTestFiles} from '../../../test/helpers';
|
||||
import {EntryPoint} from '../../src/packages/entry_point';
|
||||
import {EntryPointBundle} from '../../src/packages/entry_point_bundle';
|
||||
import {InPlaceFileWriter} from '../../src/writing/in_place_file_writer';
|
||||
|
||||
|
@ -32,7 +31,7 @@ runInEachFileSystem(() => {
|
|||
it('should write all the FileInfo to the disk', () => {
|
||||
const fs = getFileSystem();
|
||||
const fileWriter = new InPlaceFileWriter(fs);
|
||||
fileWriter.writeBundle({} as EntryPoint, {} as EntryPointBundle, [
|
||||
fileWriter.writeBundle({} as EntryPointBundle, [
|
||||
{path: _('/package/path/top-level.js'), contents: 'MODIFIED TOP LEVEL'},
|
||||
{path: _('/package/path/folder-1/file-1.js'), contents: 'MODIFIED FILE 1'},
|
||||
{path: _('/package/path/folder-2/file-4.js'), contents: 'MODIFIED FILE 4'},
|
||||
|
@ -49,7 +48,7 @@ runInEachFileSystem(() => {
|
|||
it('should create backups of all files that previously existed', () => {
|
||||
const fs = getFileSystem();
|
||||
const fileWriter = new InPlaceFileWriter(fs);
|
||||
fileWriter.writeBundle({} as EntryPoint, {} as EntryPointBundle, [
|
||||
fileWriter.writeBundle({} as EntryPointBundle, [
|
||||
{path: _('/package/path/top-level.js'), contents: 'MODIFIED TOP LEVEL'},
|
||||
{path: _('/package/path/folder-1/file-1.js'), contents: 'MODIFIED FILE 1'},
|
||||
{path: _('/package/path/folder-2/file-4.js'), contents: 'MODIFIED FILE 4'},
|
||||
|
@ -72,10 +71,7 @@ runInEachFileSystem(() => {
|
|||
const absoluteBackupPath = _('/package/path/already-backed-up.js');
|
||||
expect(
|
||||
() => fileWriter.writeBundle(
|
||||
{} as EntryPoint, {} as EntryPointBundle,
|
||||
[
|
||||
{path: absoluteBackupPath, contents: 'MODIFIED BACKED UP'},
|
||||
]))
|
||||
{} as EntryPointBundle, [{path: absoluteBackupPath, contents: 'MODIFIED BACKED UP'}]))
|
||||
.toThrowError(
|
||||
`Tried to overwrite ${absoluteBackupPath}.__ivy_ngcc_bak with an ngcc back up file, which is disallowed.`);
|
||||
});
|
||||
|
|
|
@ -96,7 +96,7 @@ runInEachFileSystem(() => {
|
|||
|
||||
it('should write the modified files to a new folder', () => {
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm5bundle,
|
||||
esm5bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/esm5.js'),
|
||||
|
@ -115,7 +115,7 @@ runInEachFileSystem(() => {
|
|||
|
||||
it('should also copy unmodified files in the program', () => {
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm2015bundle,
|
||||
esm2015bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/es2015/foo.js'),
|
||||
|
@ -135,7 +135,7 @@ runInEachFileSystem(() => {
|
|||
|
||||
it('should update the package.json properties', () => {
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm5bundle,
|
||||
esm5bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/esm5.js'),
|
||||
|
@ -148,7 +148,7 @@ runInEachFileSystem(() => {
|
|||
}));
|
||||
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm2015bundle,
|
||||
esm2015bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/es2015/foo.js'),
|
||||
|
@ -164,7 +164,7 @@ runInEachFileSystem(() => {
|
|||
|
||||
it('should overwrite and backup typings files', () => {
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm2015bundle,
|
||||
esm2015bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/index.d.ts'),
|
||||
|
@ -200,7 +200,7 @@ runInEachFileSystem(() => {
|
|||
|
||||
it('should write the modified file to a new folder', () => {
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm5bundle,
|
||||
esm5bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/a/esm5.js'),
|
||||
|
@ -215,7 +215,7 @@ runInEachFileSystem(() => {
|
|||
|
||||
it('should also copy unmodified files in the program', () => {
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm2015bundle,
|
||||
esm2015bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/a/es2015/foo.js'),
|
||||
|
@ -235,7 +235,7 @@ runInEachFileSystem(() => {
|
|||
|
||||
it('should update the package.json properties', () => {
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm5bundle,
|
||||
esm5bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/a/esm5.js'),
|
||||
|
@ -248,7 +248,7 @@ runInEachFileSystem(() => {
|
|||
}));
|
||||
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm2015bundle,
|
||||
esm2015bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/a/es2015/foo.js'),
|
||||
|
@ -264,7 +264,7 @@ runInEachFileSystem(() => {
|
|||
|
||||
it('should overwrite and backup typings files', () => {
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm2015bundle,
|
||||
esm2015bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/a/index.d.ts'),
|
||||
|
@ -293,7 +293,7 @@ runInEachFileSystem(() => {
|
|||
|
||||
it('should write the modified file to a new folder', () => {
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm5bundle,
|
||||
esm5bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/lib/esm5.js'),
|
||||
|
@ -309,7 +309,7 @@ runInEachFileSystem(() => {
|
|||
|
||||
it('should also copy unmodified files in the program', () => {
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm2015bundle,
|
||||
esm2015bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/lib/es2015/foo.js'),
|
||||
|
@ -330,7 +330,7 @@ runInEachFileSystem(() => {
|
|||
it('should not copy typings files within the package (i.e. from a different entry-point)',
|
||||
() => {
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm2015bundle,
|
||||
esm2015bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/lib/es2015/foo.js'),
|
||||
|
@ -343,7 +343,7 @@ runInEachFileSystem(() => {
|
|||
|
||||
it('should not copy files outside of the package', () => {
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm2015bundle,
|
||||
esm2015bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/lib/es2015/foo.js'),
|
||||
|
@ -357,7 +357,7 @@ runInEachFileSystem(() => {
|
|||
|
||||
it('should update the package.json properties', () => {
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm5bundle,
|
||||
esm5bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/lib/esm5.js'),
|
||||
|
@ -370,7 +370,7 @@ runInEachFileSystem(() => {
|
|||
}));
|
||||
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm2015bundle,
|
||||
esm2015bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/lib/es2015/foo.js'),
|
||||
|
@ -386,7 +386,7 @@ runInEachFileSystem(() => {
|
|||
|
||||
it('should overwrite and backup typings files', () => {
|
||||
fileWriter.writeBundle(
|
||||
entryPoint, esm2015bundle,
|
||||
esm2015bundle,
|
||||
[
|
||||
{
|
||||
path: _('/node_modules/test/typings/index.d.ts'),
|
||||
|
|
Loading…
Reference in New Issue