refactor(ivy): ngcc - pass whole entry-point object to makeEntryPointBundle() (#30591)

This simplifies the interface somewhat but also allows us to make use of
other properties of the EntryPoint object in the future.

PR Close #30591
This commit is contained in:
Pete Bacon Darwin
2019-05-25 17:44:18 +01:00
committed by Kara Erickson
parent 2dfd97d8f0
commit a94bdc6793
4 changed files with 26 additions and 19 deletions

View File

@ -154,8 +154,7 @@ export function mainNgcc(
// the property as processed even if its underlying format has been built already.
if (!compiledFormats.has(formatPath) && (compileAllFormats || isFirstFormat)) {
const bundle = makeEntryPointBundle(
fileSystem, entryPoint.path, formatPath, entryPoint.typings, isCore, property, format,
processDts, pathMappings);
fileSystem, entryPoint, formatPath, isCore, property, format, processDts, pathMappings);
if (bundle) {
logger.info(`Compiling ${entryPoint.name} : ${property} as ${format}`);
const transformedFiles = transformer.transform(bundle);

View File

@ -10,10 +10,9 @@ import {AbsoluteFsPath, FileSystem, absoluteFrom, resolve} from '../../../src/ng
import {NgtscCompilerHost} from '../../../src/ngtsc/file_system/src/compiler_host';
import {PathMappings} from '../utils';
import {BundleProgram, makeBundleProgram} from './bundle_program';
import {EntryPointFormat, EntryPointJsonProperty} from './entry_point';
import {EntryPoint, EntryPointFormat, EntryPointJsonProperty} from './entry_point';
import {NgccSourcesCompilerHost} from './ngcc_compiler_host';
/**
* A bundle of files and paths (and TS programs) that correspond to a particular
* format of a package entry-point.
@ -38,27 +37,27 @@ export interface EntryPointBundle {
* @param transformDts Whether to transform the typings along with this bundle.
*/
export function makeEntryPointBundle(
fs: FileSystem, entryPointPath: string, formatPath: string, typingsPath: string,
isCore: boolean, formatProperty: EntryPointJsonProperty, format: EntryPointFormat,
transformDts: boolean, pathMappings?: PathMappings): EntryPointBundle|null {
fs: FileSystem, entryPoint: EntryPoint, formatPath: string, isCore: boolean,
formatProperty: EntryPointJsonProperty, format: EntryPointFormat, transformDts: boolean,
pathMappings?: PathMappings): EntryPointBundle|null {
// Create the TS program and necessary helpers.
const options: ts.CompilerOptions = {
allowJs: true,
maxNodeModuleJsDepth: Infinity,
noLib: true,
rootDir: entryPointPath, ...pathMappings
rootDir: entryPoint.path, ...pathMappings
};
const srcHost = new NgccSourcesCompilerHost(fs, options, entryPointPath);
const srcHost = new NgccSourcesCompilerHost(fs, options, entryPoint.path);
const dtsHost = new NgtscCompilerHost(fs, options);
const rootDirs = [absoluteFrom(entryPointPath)];
const rootDirs = [absoluteFrom(entryPoint.path)];
// Create the bundle programs, as necessary.
const src = makeBundleProgram(
fs, isCore, resolve(entryPointPath, formatPath), 'r3_symbols.js', options, srcHost);
const dts = transformDts ?
makeBundleProgram(
fs, isCore, resolve(entryPointPath, typingsPath), 'r3_symbols.d.ts', options, dtsHost) :
null;
fs, isCore, resolve(entryPoint.path, formatPath), 'r3_symbols.js', options, srcHost);
const dts = transformDts ? makeBundleProgram(
fs, isCore, resolve(entryPoint.path, entryPoint.typings),
'r3_symbols.d.ts', options, dtsHost) :
null;
const isFlatCore = isCore && src.r3SymbolsFile === null;
return {format, formatProperty, rootDirs, isCore, isFlatCore, src, dts};