diff --git a/packages/compiler-cli/ngcc/src/main.ts b/packages/compiler-cli/ngcc/src/main.ts index 8fd1ee005c..c424966727 100644 --- a/packages/compiler-cli/ngcc/src/main.ts +++ b/packages/compiler-cli/ngcc/src/main.ts @@ -7,14 +7,16 @@ */ import {AbsoluteFsPath} from '../../src/ngtsc/path'; + import {checkMarker, writeMarker} from './packages/build_marker'; import {DependencyHost} from './packages/dependency_host'; import {DependencyResolver} from './packages/dependency_resolver'; -import {EntryPointFormat, EntryPointJsonProperty, getEntryPointFormat} from './packages/entry_point'; +import {EntryPointFormat, EntryPointJsonProperty, SUPPORTED_FORMAT_PROPERTIES, getEntryPointFormat} from './packages/entry_point'; import {makeEntryPointBundle} from './packages/entry_point_bundle'; import {EntryPointFinder} from './packages/entry_point_finder'; import {Transformer} from './packages/transformer'; + /** * The options to configure the ngcc compiler. */ @@ -48,7 +50,8 @@ const SUPPORTED_FORMATS: EntryPointFormat[] = ['esm5', 'esm2015']; * * @param options The options telling ngcc what to compile and how. */ -export function mainNgcc({baseSourcePath, targetEntryPointPath, propertiesToConsider, +export function mainNgcc({baseSourcePath, targetEntryPointPath, + propertiesToConsider = SUPPORTED_FORMAT_PROPERTIES, compileAllFormats = true}: NgccOptions): void { const transformer = new Transformer(baseSourcePath, baseSourcePath); const host = new DependencyHost(); @@ -61,12 +64,10 @@ export function mainNgcc({baseSourcePath, targetEntryPointPath, propertiesToCons // Are we compiling the Angular core? const isCore = entryPoint.name === '@angular/core'; - const propertiesToCompile = - propertiesToConsider || Object.keys(entryPoint.packageJson) as EntryPointJsonProperty[]; const compiledFormats = new Set(); - for (let i = 0; i < propertiesToCompile.length; i++) { - const property = propertiesToCompile[i]; + for (let i = 0; i < propertiesToConsider.length; i++) { + const property = propertiesToConsider[i]; const formatPath = entryPoint.packageJson[property]; const format = getEntryPointFormat(property); @@ -106,7 +107,7 @@ export function mainNgcc({baseSourcePath, targetEntryPointPath, propertiesToCons if (compiledFormats.size === 0) { throw new Error( - `Failed to compile any formats for entry-point at (${entryPoint.path}). Tried ${propertiesToCompile}.`); + `Failed to compile any formats for entry-point at (${entryPoint.path}). Tried ${propertiesToConsider}.`); } }); } diff --git a/packages/compiler-cli/ngcc/src/packages/entry_point.ts b/packages/compiler-cli/ngcc/src/packages/entry_point.ts index 541b81f6e9..11dcbfc193 100644 --- a/packages/compiler-cli/ngcc/src/packages/entry_point.ts +++ b/packages/compiler-cli/ngcc/src/packages/entry_point.ts @@ -55,6 +55,9 @@ export interface EntryPointPackageJson extends PackageJsonFormatProperties { } export type EntryPointJsonProperty = keyof(PackageJsonFormatProperties); +// We need to keep the elements of this const and the `EntryPointJsonProperty` type in sync. +export const SUPPORTED_FORMAT_PROPERTIES: EntryPointJsonProperty[] = + ['fesm2015', 'fesm5', 'es2015', 'esm2015', 'esm5', 'main', 'module']; /** * Try to create an entry-point from the given paths and properties.