refactor(ivy): ngcc - expose the entryPoint from the EntryPointBundle interface (#30591)

This will allow users of the `EntryPointBundle` to use some of the `EntryPoint`
properties without us having to pass them around one by one.

PR Close #30591
This commit is contained in:
Pete Bacon Darwin
2019-05-25 17:46:07 +01:00
committed by Kara Erickson
parent a94bdc6793
commit e943859843
10 changed files with 38 additions and 13 deletions

View File

@ -8,10 +8,22 @@
import {AbsoluteFsPath, NgtscCompilerHost, absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_system';
import {TestFile} from '../../../src/ngtsc/file_system/testing';
import {BundleProgram, makeBundleProgram} from '../../src/packages/bundle_program';
import {EntryPointFormat, EntryPointJsonProperty} from '../../src/packages/entry_point';
import {EntryPoint, EntryPointFormat, EntryPointJsonProperty} from '../../src/packages/entry_point';
import {EntryPointBundle} from '../../src/packages/entry_point_bundle';
import {NgccSourcesCompilerHost} from '../../src/packages/ngcc_compiler_host';
export function makeTestEntryPoint(
entryPointName: string, packageName: string = entryPointName): EntryPoint {
return {
name: entryPointName,
packageJson: {name: entryPointName},
package: absoluteFrom(`/node_modules/${packageName}`),
path: absoluteFrom(`/node_modules/${entryPointName}`),
typings: absoluteFrom(`/node_modules/${entryPointName}/index.d.ts`),
compiledByAngular: true,
};
}
/**
*
* @param format The format of the bundle.
@ -19,12 +31,19 @@ import {NgccSourcesCompilerHost} from '../../src/packages/ngcc_compiler_host';
* @param dtsFiles The typings files to include the bundle.
*/
export function makeTestEntryPointBundle(
formatProperty: EntryPointJsonProperty, format: EntryPointFormat, isCore: boolean,
srcRootNames: AbsoluteFsPath[], dtsRootNames?: AbsoluteFsPath[]): EntryPointBundle {
packageName: string, formatProperty: EntryPointJsonProperty, format: EntryPointFormat,
isCore: boolean, srcRootNames: AbsoluteFsPath[],
dtsRootNames?: AbsoluteFsPath[]): EntryPointBundle {
const entryPoint = makeTestEntryPoint(packageName);
const src = makeTestBundleProgram(srcRootNames[0], isCore);
const dts = dtsRootNames ? makeTestDtsBundleProgram(dtsRootNames[0], isCore) : null;
const isFlatCore = isCore && src.r3SymbolsFile === null;
return {formatProperty, format, rootDirs: [absoluteFrom('/')], src, dts, isCore, isFlatCore};
return {
entryPoint,
formatProperty,
format,
rootDirs: [absoluteFrom('/')], src, dts, isCore, isFlatCore
};
}
export function makeTestBundleProgram(