refactor(ngcc): support processing only the typings files of packages (#40976)
Some tools (such as Language Server and ng-packagr) only care about the processed typings generated by ngcc. Forcing these tools to process the JavaScript files as well has two disadvantages: First, unnecessary work is being done, which is time consuming. But more importantly, it is not always possible to know how the final bundling tools will want the processed JavaScript to be configured. For example, the CLI would prefer the `--create-ivy-entry-points` option but this would break non-CLI build tooling. This commit adds a new option (`--typings-only` on the command line, and `typingsOnly` via programmatic API) that instructs ngcc to only render changes to the typings files for the entry-points that it finds, and not to write any JavaScript files. In order to process the typings, a JavaScript format will need to be analysed, but it will not be rendered to disk. When using this option, it is best to offer ngcc a wide range of possible JavaScript formats to choose from, and it will use the first format that it finds. Ideally you would configure it to try the `ES2015` FESM format first, since this will be the most performant. Fixes #40969 PR Close #40976
This commit is contained in:
parent
140ff8af13
commit
8d13f631d9
@ -49,7 +49,14 @@ export function parseCommandLineOptions(args: string[]): NgccOptions {
|
|||||||
})
|
})
|
||||||
.option('first-only', {
|
.option('first-only', {
|
||||||
describe:
|
describe:
|
||||||
'If specified then only the first matching package.json property will be compiled.',
|
'If specified then only the first matching package.json property will be compiled.\n' +
|
||||||
|
'This option is overridden by `--typings-only`.',
|
||||||
|
type: 'boolean',
|
||||||
|
})
|
||||||
|
.option('typings-only', {
|
||||||
|
describe:
|
||||||
|
'If specified then only the typings files are processed, and no JS source files will be modified.\n' +
|
||||||
|
'Setting this option will force `--first-only` to be set, since only one format is needed to process the typings',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
})
|
})
|
||||||
.option('create-ivy-entry-points', {
|
.option('create-ivy-entry-points', {
|
||||||
@ -122,6 +129,7 @@ export function parseCommandLineOptions(args: string[]): NgccOptions {
|
|||||||
const propertiesToConsider = options.p;
|
const propertiesToConsider = options.p;
|
||||||
const targetEntryPointPath = options.t;
|
const targetEntryPointPath = options.t;
|
||||||
const compileAllFormats = !options['first-only'];
|
const compileAllFormats = !options['first-only'];
|
||||||
|
const typingsOnly = options['typings-only'];
|
||||||
const createNewEntryPointFormats = options['create-ivy-entry-points'];
|
const createNewEntryPointFormats = options['create-ivy-entry-points'];
|
||||||
const logLevel = options.l as keyof typeof LogLevel | undefined;
|
const logLevel = options.l as keyof typeof LogLevel | undefined;
|
||||||
const enableI18nLegacyMessageIdFormat = options['legacy-message-ids'];
|
const enableI18nLegacyMessageIdFormat = options['legacy-message-ids'];
|
||||||
@ -139,6 +147,7 @@ export function parseCommandLineOptions(args: string[]): NgccOptions {
|
|||||||
basePath: baseSourcePath,
|
basePath: baseSourcePath,
|
||||||
propertiesToConsider,
|
propertiesToConsider,
|
||||||
targetEntryPointPath,
|
targetEntryPointPath,
|
||||||
|
typingsOnly,
|
||||||
compileAllFormats,
|
compileAllFormats,
|
||||||
createNewEntryPointFormats,
|
createNewEntryPointFormats,
|
||||||
logger,
|
logger,
|
||||||
|
@ -19,15 +19,16 @@ import {EntryPoint, EntryPointJsonProperty, EntryPointPackageJson, SUPPORTED_FOR
|
|||||||
import {cleanOutdatedPackages} from '../writing/cleaning/package_cleaner';
|
import {cleanOutdatedPackages} from '../writing/cleaning/package_cleaner';
|
||||||
|
|
||||||
import {AnalyzeEntryPointsFn} from './api';
|
import {AnalyzeEntryPointsFn} from './api';
|
||||||
import {PartiallyOrderedTasks, TaskQueue} from './tasks/api';
|
import {DtsProcessing, PartiallyOrderedTasks, TaskQueue} from './tasks/api';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the function for performing the analysis of the entry-points.
|
* Create the function for performing the analysis of the entry-points.
|
||||||
*/
|
*/
|
||||||
export function getAnalyzeEntryPointsFn(
|
export function getAnalyzeEntryPointsFn(
|
||||||
logger: Logger, finder: EntryPointFinder, fileSystem: FileSystem,
|
logger: Logger, finder: EntryPointFinder, fileSystem: FileSystem,
|
||||||
supportedPropertiesToConsider: EntryPointJsonProperty[], compileAllFormats: boolean,
|
supportedPropertiesToConsider: EntryPointJsonProperty[], typingsOnly: boolean,
|
||||||
propertiesToConsider: string[], inParallel: boolean): AnalyzeEntryPointsFn {
|
compileAllFormats: boolean, propertiesToConsider: string[],
|
||||||
|
inParallel: boolean): AnalyzeEntryPointsFn {
|
||||||
return () => {
|
return () => {
|
||||||
logger.debug('Analyzing entry-points...');
|
logger.debug('Analyzing entry-points...');
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
@ -49,9 +50,10 @@ export function getAnalyzeEntryPointsFn(
|
|||||||
for (const entryPoint of entryPoints) {
|
for (const entryPoint of entryPoints) {
|
||||||
const packageJson = entryPoint.packageJson;
|
const packageJson = entryPoint.packageJson;
|
||||||
const hasProcessedTypings = hasBeenProcessed(packageJson, 'typings');
|
const hasProcessedTypings = hasBeenProcessed(packageJson, 'typings');
|
||||||
const {propertiesToProcess, equivalentPropertiesMap} =
|
const {propertiesToProcess, equivalentPropertiesMap} = getPropertiesToProcess(
|
||||||
getPropertiesToProcess(packageJson, supportedPropertiesToConsider, compileAllFormats);
|
packageJson, supportedPropertiesToConsider, compileAllFormats, typingsOnly);
|
||||||
let processDts = !hasProcessedTypings;
|
let processDts = hasProcessedTypings ? DtsProcessing.No :
|
||||||
|
typingsOnly ? DtsProcessing.Only : DtsProcessing.Yes;
|
||||||
|
|
||||||
if (propertiesToProcess.length === 0) {
|
if (propertiesToProcess.length === 0) {
|
||||||
// This entry-point is unprocessable (i.e. there is no format property that is of interest
|
// This entry-point is unprocessable (i.e. there is no format property that is of interest
|
||||||
@ -73,7 +75,7 @@ export function getAnalyzeEntryPointsFn(
|
|||||||
tasks.push({entryPoint, formatProperty, formatPropertiesToMarkAsProcessed, processDts});
|
tasks.push({entryPoint, formatProperty, formatPropertiesToMarkAsProcessed, processDts});
|
||||||
|
|
||||||
// Only process typings for the first property (if not already processed).
|
// Only process typings for the first property (if not already processed).
|
||||||
processDts = false;
|
processDts = DtsProcessing.No;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +116,7 @@ function logInvalidEntryPoints(logger: Logger, invalidEntryPoints: InvalidEntryP
|
|||||||
*/
|
*/
|
||||||
function getPropertiesToProcess(
|
function getPropertiesToProcess(
|
||||||
packageJson: EntryPointPackageJson, propertiesToConsider: EntryPointJsonProperty[],
|
packageJson: EntryPointPackageJson, propertiesToConsider: EntryPointJsonProperty[],
|
||||||
compileAllFormats: boolean): {
|
compileAllFormats: boolean, typingsOnly: boolean): {
|
||||||
propertiesToProcess: EntryPointJsonProperty[];
|
propertiesToProcess: EntryPointJsonProperty[];
|
||||||
equivalentPropertiesMap: Map<EntryPointJsonProperty, EntryPointJsonProperty[]>;
|
equivalentPropertiesMap: Map<EntryPointJsonProperty, EntryPointJsonProperty[]>;
|
||||||
} {
|
} {
|
||||||
@ -156,7 +158,8 @@ function getPropertiesToProcess(
|
|||||||
const equivalentPropertiesMap = new Map<EntryPointJsonProperty, EntryPointJsonProperty[]>();
|
const equivalentPropertiesMap = new Map<EntryPointJsonProperty, EntryPointJsonProperty[]>();
|
||||||
for (const prop of propertiesToConsider) {
|
for (const prop of propertiesToConsider) {
|
||||||
const formatPath = packageJson[prop]!;
|
const formatPath = packageJson[prop]!;
|
||||||
const equivalentProperties = formatPathToProperties[formatPath];
|
// If we are only processing typings then there should be no format properties to mark
|
||||||
|
const equivalentProperties = typingsOnly ? [] : formatPathToProperties[formatPath];
|
||||||
equivalentPropertiesMap.set(prop, equivalentProperties);
|
equivalentPropertiesMap.set(prop, equivalentProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,8 +32,30 @@ export interface Task extends JsonObject {
|
|||||||
*/
|
*/
|
||||||
formatPropertiesToMarkAsProcessed: EntryPointJsonProperty[];
|
formatPropertiesToMarkAsProcessed: EntryPointJsonProperty[];
|
||||||
|
|
||||||
/** Whether to also process typings for this entry-point as part of the task. */
|
/**
|
||||||
processDts: boolean;
|
* Whether to process typings for this entry-point as part of the task.
|
||||||
|
*/
|
||||||
|
processDts: DtsProcessing;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The options for processing Typescript typings (.d.ts) files.
|
||||||
|
*/
|
||||||
|
export enum DtsProcessing {
|
||||||
|
/**
|
||||||
|
* Yes, process the typings for this entry point as part of the task.
|
||||||
|
*/
|
||||||
|
Yes,
|
||||||
|
/**
|
||||||
|
* No, do not process the typings as part of this task - they must have already been processed by
|
||||||
|
* another task or previous ngcc process.
|
||||||
|
*/
|
||||||
|
No,
|
||||||
|
/**
|
||||||
|
* Only process the typings for this entry-point; do not render any JavaScript files for the
|
||||||
|
* `formatProperty` of this task.
|
||||||
|
*/
|
||||||
|
Only,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +11,7 @@ import {markAsProcessed} from '../../packages/build_marker';
|
|||||||
import {getEntryPointFormat, PackageJsonFormatProperties} from '../../packages/entry_point';
|
import {getEntryPointFormat, PackageJsonFormatProperties} from '../../packages/entry_point';
|
||||||
import {PackageJsonUpdater} from '../../writing/package_json_updater';
|
import {PackageJsonUpdater} from '../../writing/package_json_updater';
|
||||||
|
|
||||||
import {Task, TaskCompletedCallback, TaskProcessingOutcome, TaskQueue} from './api';
|
import {DtsProcessing, Task, TaskCompletedCallback, TaskProcessingOutcome, TaskQueue} from './api';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function that can handle a specific outcome of a task completion.
|
* A function that can handle a specific outcome of a task completion.
|
||||||
@ -53,7 +53,7 @@ export function createMarkAsProcessedHandler(
|
|||||||
const packageJsonPath = fs.resolve(entryPoint.path, 'package.json');
|
const packageJsonPath = fs.resolve(entryPoint.path, 'package.json');
|
||||||
const propsToMarkAsProcessed: PackageJsonFormatProperties[] =
|
const propsToMarkAsProcessed: PackageJsonFormatProperties[] =
|
||||||
[...formatPropertiesToMarkAsProcessed];
|
[...formatPropertiesToMarkAsProcessed];
|
||||||
if (processDts) {
|
if (processDts !== DtsProcessing.No) {
|
||||||
propsToMarkAsProcessed.push('typings');
|
propsToMarkAsProcessed.push('typings');
|
||||||
}
|
}
|
||||||
markAsProcessed(
|
markAsProcessed(
|
||||||
@ -66,11 +66,7 @@ export function createMarkAsProcessedHandler(
|
|||||||
*/
|
*/
|
||||||
export function createThrowErrorHandler(fs: ReadonlyFileSystem): TaskCompletedHandler {
|
export function createThrowErrorHandler(fs: ReadonlyFileSystem): TaskCompletedHandler {
|
||||||
return (task: Task, message: string|null): void => {
|
return (task: Task, message: string|null): void => {
|
||||||
const format = getEntryPointFormat(fs, task.entryPoint, task.formatProperty);
|
throw new Error(createErrorMessage(fs, task, message));
|
||||||
throw new Error(
|
|
||||||
`Failed to compile entry-point ${task.entryPoint.name} (${task.formatProperty} as ${
|
|
||||||
format})` +
|
|
||||||
(message !== null ? ` due to ${message}` : ''));
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,10 +77,14 @@ export function createLogErrorHandler(
|
|||||||
logger: Logger, fs: ReadonlyFileSystem, taskQueue: TaskQueue): TaskCompletedHandler {
|
logger: Logger, fs: ReadonlyFileSystem, taskQueue: TaskQueue): TaskCompletedHandler {
|
||||||
return (task: Task, message: string|null): void => {
|
return (task: Task, message: string|null): void => {
|
||||||
taskQueue.markAsFailed(task);
|
taskQueue.markAsFailed(task);
|
||||||
const format = getEntryPointFormat(fs, task.entryPoint, task.formatProperty);
|
logger.error(createErrorMessage(fs, task, message));
|
||||||
logger.error(
|
|
||||||
`Failed to compile entry-point ${task.entryPoint.name} (${task.formatProperty} as ${
|
|
||||||
format})` +
|
|
||||||
(message !== null ? ` due to ${message}` : ''));
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createErrorMessage(fs: ReadonlyFileSystem, task: Task, message: string|null): string {
|
||||||
|
const jsFormat =
|
||||||
|
`${task.formatProperty} as ${getEntryPointFormat(fs, task.entryPoint, task.formatProperty)}`;
|
||||||
|
const format = task.typingsOnly ? `typings only using ${jsFormat}` : jsFormat;
|
||||||
|
message = message !== null ? ` due to ${message}` : '';
|
||||||
|
return `Failed to compile entry-point ${task.entryPoint.name} (${format})` + message;
|
||||||
|
}
|
||||||
|
@ -7,11 +7,12 @@
|
|||||||
*/
|
*/
|
||||||
import {DepGraph} from 'dependency-graph';
|
import {DepGraph} from 'dependency-graph';
|
||||||
import {EntryPoint} from '../../packages/entry_point';
|
import {EntryPoint} from '../../packages/entry_point';
|
||||||
import {PartiallyOrderedTasks, Task, TaskDependencies} from './api';
|
import {DtsProcessing, PartiallyOrderedTasks, Task, TaskDependencies} from './api';
|
||||||
|
|
||||||
/** Stringify a task for debugging purposes. */
|
/** Stringify a task for debugging purposes. */
|
||||||
export const stringifyTask = (task: Task): string => `{entryPoint: ${
|
export const stringifyTask = (task: Task): string =>
|
||||||
task.entryPoint.name}, formatProperty: ${task.formatProperty}, processDts: ${task.processDts}}`;
|
`{entryPoint: ${task.entryPoint.name}, formatProperty: ${task.formatProperty}, ` +
|
||||||
|
`processDts: ${DtsProcessing[task.processDts]}}`;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute a mapping of tasks to the tasks that are dependent on them (if any).
|
* Compute a mapping of tasks to the tasks that are dependent on them (if any).
|
||||||
@ -55,7 +56,7 @@ export function computeTaskDependencies(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (task.processDts) {
|
if (task.processDts !== DtsProcessing.No) {
|
||||||
// SANITY CHECK:
|
// SANITY CHECK:
|
||||||
// There should only be one task per entry-point that generates typings (and thus can be a
|
// There should only be one task per entry-point that generates typings (and thus can be a
|
||||||
// dependency of other tasks), so the following should theoretically never happen, but check
|
// dependency of other tasks), so the following should theoretically never happen, but check
|
||||||
|
@ -56,6 +56,7 @@ export function mainNgcc(options: AsyncNgccOptions|SyncNgccOptions): void|Promis
|
|||||||
basePath,
|
basePath,
|
||||||
targetEntryPointPath,
|
targetEntryPointPath,
|
||||||
propertiesToConsider,
|
propertiesToConsider,
|
||||||
|
typingsOnly,
|
||||||
compileAllFormats,
|
compileAllFormats,
|
||||||
logger,
|
logger,
|
||||||
pathMappings,
|
pathMappings,
|
||||||
@ -96,7 +97,7 @@ export function mainNgcc(options: AsyncNgccOptions|SyncNgccOptions): void|Promis
|
|||||||
const inParallel = workerCount > 1;
|
const inParallel = workerCount > 1;
|
||||||
|
|
||||||
const analyzeEntryPoints = getAnalyzeEntryPointsFn(
|
const analyzeEntryPoints = getAnalyzeEntryPointsFn(
|
||||||
logger, finder, fileSystem, supportedPropertiesToConsider, compileAllFormats,
|
logger, finder, fileSystem, supportedPropertiesToConsider, typingsOnly, compileAllFormats,
|
||||||
propertiesToConsider, inParallel);
|
propertiesToConsider, inParallel);
|
||||||
|
|
||||||
// Create an updater that will actually write to disk.
|
// Create an updater that will actually write to disk.
|
||||||
|
@ -42,9 +42,21 @@ export interface SyncNgccOptions {
|
|||||||
*/
|
*/
|
||||||
propertiesToConsider?: string[];
|
propertiesToConsider?: string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to only process the typings files for this entry-point.
|
||||||
|
*
|
||||||
|
* This is useful when running ngcc only to provide typings files to downstream tooling such as
|
||||||
|
* the Angular Language Service or ng-packagr. Defaults to `false`.
|
||||||
|
*
|
||||||
|
* If this is set to `true` then `compileAllFormats` is forced to `false`.
|
||||||
|
*/
|
||||||
|
typingsOnly?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to process all formats specified by (`propertiesToConsider`) or to stop processing
|
* Whether to process all formats specified by (`propertiesToConsider`) or to stop processing
|
||||||
* this entry-point at the first matching format. Defaults to `true`.
|
* this entry-point at the first matching format.
|
||||||
|
*
|
||||||
|
* Defaults to `true`, but is forced to `false` if `typingsOnly` is `true`.
|
||||||
*/
|
*/
|
||||||
compileAllFormats?: boolean;
|
compileAllFormats?: boolean;
|
||||||
|
|
||||||
@ -172,6 +184,7 @@ export function getSharedSetup(options: NgccOptions): SharedSetup&RequiredNgccOp
|
|||||||
basePath,
|
basePath,
|
||||||
targetEntryPointPath,
|
targetEntryPointPath,
|
||||||
propertiesToConsider = SUPPORTED_FORMAT_PROPERTIES,
|
propertiesToConsider = SUPPORTED_FORMAT_PROPERTIES,
|
||||||
|
typingsOnly = false,
|
||||||
compileAllFormats = true,
|
compileAllFormats = true,
|
||||||
createNewEntryPointFormats = false,
|
createNewEntryPointFormats = false,
|
||||||
logger = new ConsoleLogger(LogLevel.info),
|
logger = new ConsoleLogger(LogLevel.info),
|
||||||
@ -188,12 +201,19 @@ export function getSharedSetup(options: NgccOptions): SharedSetup&RequiredNgccOp
|
|||||||
errorOnFailedEntryPoint = true;
|
errorOnFailedEntryPoint = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typingsOnly) {
|
||||||
|
// If we only want to process the typings then we do not want to waste time trying to process
|
||||||
|
// multiple JS formats.
|
||||||
|
compileAllFormats = false;
|
||||||
|
}
|
||||||
|
|
||||||
checkForSolutionStyleTsConfig(fileSystem, logger, projectPath, options.tsConfigPath, tsConfig);
|
checkForSolutionStyleTsConfig(fileSystem, logger, projectPath, options.tsConfigPath, tsConfig);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
basePath,
|
basePath,
|
||||||
targetEntryPointPath,
|
targetEntryPointPath,
|
||||||
propertiesToConsider,
|
propertiesToConsider,
|
||||||
|
typingsOnly,
|
||||||
compileAllFormats,
|
compileAllFormats,
|
||||||
createNewEntryPointFormats,
|
createNewEntryPointFormats,
|
||||||
logger,
|
logger,
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
import {AbsoluteFsPath, FileSystem, ReadonlyFileSystem} from '../../../src/ngtsc/file_system';
|
import {AbsoluteFsPath, FileSystem, ReadonlyFileSystem} from '../../../src/ngtsc/file_system';
|
||||||
|
import {DtsProcessing} from '../execution/tasks/api';
|
||||||
import {PathMappings} from '../path_mappings';
|
import {PathMappings} from '../path_mappings';
|
||||||
import {BundleProgram, makeBundleProgram} from './bundle_program';
|
import {BundleProgram, makeBundleProgram} from './bundle_program';
|
||||||
import {EntryPoint, EntryPointFormat} from './entry_point';
|
import {EntryPoint, EntryPointFormat} from './entry_point';
|
||||||
@ -25,6 +26,7 @@ export interface EntryPointBundle {
|
|||||||
rootDirs: AbsoluteFsPath[];
|
rootDirs: AbsoluteFsPath[];
|
||||||
src: BundleProgram;
|
src: BundleProgram;
|
||||||
dts: BundleProgram|null;
|
dts: BundleProgram|null;
|
||||||
|
dtsProcessing: DtsProcessing;
|
||||||
enableI18nLegacyMessageIdFormat: boolean;
|
enableI18nLegacyMessageIdFormat: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +39,7 @@ export interface EntryPointBundle {
|
|||||||
* @param formatPath The path to the source files for this bundle.
|
* @param formatPath The path to the source files for this bundle.
|
||||||
* @param isCore This entry point is the Angular core package.
|
* @param isCore This entry point is the Angular core package.
|
||||||
* @param format The underlying format of the bundle.
|
* @param format The underlying format of the bundle.
|
||||||
* @param transformDts Whether to transform the typings along with this bundle.
|
* @param dtsProcessing Whether to transform the typings along with this bundle.
|
||||||
* @param pathMappings An optional set of mappings to use when compiling files.
|
* @param pathMappings An optional set of mappings to use when compiling files.
|
||||||
* @param mirrorDtsFromSrc If true then the `dts` program will contain additional files that
|
* @param mirrorDtsFromSrc If true then the `dts` program will contain additional files that
|
||||||
* were guessed by mapping the `src` files to `dts` files.
|
* were guessed by mapping the `src` files to `dts` files.
|
||||||
@ -47,7 +49,7 @@ export interface EntryPointBundle {
|
|||||||
export function makeEntryPointBundle(
|
export function makeEntryPointBundle(
|
||||||
fs: FileSystem, entryPoint: EntryPoint, sharedFileCache: SharedFileCache,
|
fs: FileSystem, entryPoint: EntryPoint, sharedFileCache: SharedFileCache,
|
||||||
moduleResolutionCache: ts.ModuleResolutionCache, formatPath: string, isCore: boolean,
|
moduleResolutionCache: ts.ModuleResolutionCache, formatPath: string, isCore: boolean,
|
||||||
format: EntryPointFormat, transformDts: boolean, pathMappings?: PathMappings,
|
format: EntryPointFormat, dtsProcessing: DtsProcessing, pathMappings?: PathMappings,
|
||||||
mirrorDtsFromSrc: boolean = false,
|
mirrorDtsFromSrc: boolean = false,
|
||||||
enableI18nLegacyMessageIdFormat: boolean = true): EntryPointBundle {
|
enableI18nLegacyMessageIdFormat: boolean = true): EntryPointBundle {
|
||||||
// Create the TS program and necessary helpers.
|
// Create the TS program and necessary helpers.
|
||||||
@ -64,13 +66,14 @@ export function makeEntryPointBundle(
|
|||||||
const typingsPath = fs.resolve(entryPoint.path, entryPoint.typings);
|
const typingsPath = fs.resolve(entryPoint.path, entryPoint.typings);
|
||||||
const src = makeBundleProgram(
|
const src = makeBundleProgram(
|
||||||
fs, isCore, entryPoint.packagePath, absFormatPath, 'r3_symbols.js', options, srcHost);
|
fs, isCore, entryPoint.packagePath, absFormatPath, 'r3_symbols.js', options, srcHost);
|
||||||
const additionalDtsFiles = transformDts && mirrorDtsFromSrc ?
|
const additionalDtsFiles = dtsProcessing !== DtsProcessing.No && mirrorDtsFromSrc ?
|
||||||
computePotentialDtsFilesFromJsFiles(fs, src.program, absFormatPath, typingsPath) :
|
computePotentialDtsFilesFromJsFiles(fs, src.program, absFormatPath, typingsPath) :
|
||||||
[];
|
[];
|
||||||
const dts = transformDts ? makeBundleProgram(
|
const dts = dtsProcessing !== DtsProcessing.No ?
|
||||||
fs, isCore, entryPoint.packagePath, typingsPath, 'r3_symbols.d.ts',
|
makeBundleProgram(
|
||||||
{...options, allowJs: false}, dtsHost, additionalDtsFiles) :
|
fs, isCore, entryPoint.packagePath, typingsPath, 'r3_symbols.d.ts',
|
||||||
null;
|
{...options, allowJs: false}, dtsHost, additionalDtsFiles) :
|
||||||
|
null;
|
||||||
const isFlatCore = isCore && src.r3SymbolsFile === null;
|
const isFlatCore = isCore && src.r3SymbolsFile === null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -81,6 +84,7 @@ export function makeEntryPointBundle(
|
|||||||
isFlatCore,
|
isFlatCore,
|
||||||
src,
|
src,
|
||||||
dts,
|
dts,
|
||||||
|
dtsProcessing,
|
||||||
enableI18nLegacyMessageIdFormat
|
enableI18nLegacyMessageIdFormat
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import {NgccReferencesRegistry} from '../analysis/ngcc_references_registry';
|
|||||||
import {ExportInfo, PrivateDeclarationsAnalyzer} from '../analysis/private_declarations_analyzer';
|
import {ExportInfo, PrivateDeclarationsAnalyzer} from '../analysis/private_declarations_analyzer';
|
||||||
import {SwitchMarkerAnalyses, SwitchMarkerAnalyzer} from '../analysis/switch_marker_analyzer';
|
import {SwitchMarkerAnalyses, SwitchMarkerAnalyzer} from '../analysis/switch_marker_analyzer';
|
||||||
import {CompiledFile} from '../analysis/types';
|
import {CompiledFile} from '../analysis/types';
|
||||||
|
import {DtsProcessing} from '../execution/tasks/api';
|
||||||
import {CommonJsReflectionHost} from '../host/commonjs_host';
|
import {CommonJsReflectionHost} from '../host/commonjs_host';
|
||||||
import {DelegatingReflectionHost} from '../host/delegating_host';
|
import {DelegatingReflectionHost} from '../host/delegating_host';
|
||||||
import {Esm2015ReflectionHost} from '../host/esm2015_host';
|
import {Esm2015ReflectionHost} from '../host/esm2015_host';
|
||||||
@ -92,12 +93,16 @@ export class Transformer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Transform the source files and source maps.
|
// Transform the source files and source maps.
|
||||||
const srcFormatter = this.getRenderingFormatter(ngccReflectionHost, bundle);
|
let renderedFiles: FileToWrite[] = [];
|
||||||
|
|
||||||
const renderer =
|
if (bundle.dtsProcessing !== DtsProcessing.Only) {
|
||||||
new Renderer(reflectionHost, srcFormatter, this.fs, this.logger, bundle, this.tsConfig);
|
// Render the transformed JavaScript files only if we are not doing "typings-only" processing.
|
||||||
let renderedFiles = renderer.renderProgram(
|
const srcFormatter = this.getRenderingFormatter(ngccReflectionHost, bundle);
|
||||||
decorationAnalyses, switchMarkerAnalyses, privateDeclarationsAnalyses);
|
const renderer =
|
||||||
|
new Renderer(reflectionHost, srcFormatter, this.fs, this.logger, bundle, this.tsConfig);
|
||||||
|
renderedFiles = renderer.renderProgram(
|
||||||
|
decorationAnalyses, switchMarkerAnalyses, privateDeclarationsAnalyses);
|
||||||
|
}
|
||||||
|
|
||||||
if (bundle.dts) {
|
if (bundle.dts) {
|
||||||
const dtsFormatter = new EsmRenderingFormatter(this.fs, reflectionHost, bundle.isCore);
|
const dtsFormatter = new EsmRenderingFormatter(this.fs, reflectionHost, bundle.isCore);
|
||||||
|
@ -15,7 +15,7 @@ import {AbsoluteFsPath} from '../../../../src/ngtsc/file_system';
|
|||||||
import {MockLogger} from '../../../../src/ngtsc/logging/testing';
|
import {MockLogger} from '../../../../src/ngtsc/logging/testing';
|
||||||
import {CreateCompileFn} from '../../../src/execution/api';
|
import {CreateCompileFn} from '../../../src/execution/api';
|
||||||
import {startWorker} from '../../../src/execution/cluster/worker';
|
import {startWorker} from '../../../src/execution/cluster/worker';
|
||||||
import {Task, TaskCompletedCallback, TaskProcessingOutcome} from '../../../src/execution/tasks/api';
|
import {DtsProcessing, Task, TaskCompletedCallback, TaskProcessingOutcome} from '../../../src/execution/tasks/api';
|
||||||
import {FileToWrite} from '../../../src/rendering/utils';
|
import {FileToWrite} from '../../../src/rendering/utils';
|
||||||
import {mockProperty, spyProperty} from '../../helpers/spy_utils';
|
import {mockProperty, spyProperty} from '../../helpers/spy_utils';
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ describe('startWorker()', () => {
|
|||||||
const mockTask = {
|
const mockTask = {
|
||||||
entryPoint: {name: 'foo'},
|
entryPoint: {name: 'foo'},
|
||||||
formatProperty: 'es2015',
|
formatProperty: 'es2015',
|
||||||
processDts: true,
|
processDts: DtsProcessing.Yes,
|
||||||
} as unknown as Task;
|
} as unknown as Task;
|
||||||
|
|
||||||
startWorker(mockLogger, createCompileFnSpy);
|
startWorker(mockLogger, createCompileFnSpy);
|
||||||
@ -134,7 +134,7 @@ describe('startWorker()', () => {
|
|||||||
expect(processSendSpy).not.toHaveBeenCalled();
|
expect(processSendSpy).not.toHaveBeenCalled();
|
||||||
|
|
||||||
expect(mockLogger.logs.debug[0]).toEqual([
|
expect(mockLogger.logs.debug[0]).toEqual([
|
||||||
'[Worker #42] Processing task: {entryPoint: foo, formatProperty: es2015, processDts: true}',
|
'[Worker #42] Processing task: {entryPoint: foo, formatProperty: es2015, processDts: Yes}',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ describe('startWorker()', () => {
|
|||||||
const mockTask = {
|
const mockTask = {
|
||||||
entryPoint: {name: 'foo'},
|
entryPoint: {name: 'foo'},
|
||||||
formatProperty: 'es2015',
|
formatProperty: 'es2015',
|
||||||
processDts: true,
|
processDts: DtsProcessing.Yes,
|
||||||
} as unknown as Task;
|
} as unknown as Task;
|
||||||
|
|
||||||
let err: string|Error;
|
let err: string|Error;
|
||||||
@ -178,7 +178,7 @@ describe('startWorker()', () => {
|
|||||||
const mockTask = {
|
const mockTask = {
|
||||||
entryPoint: {name: 'foo'},
|
entryPoint: {name: 'foo'},
|
||||||
formatProperty: 'es2015',
|
formatProperty: 'es2015',
|
||||||
processDts: true,
|
processDts: DtsProcessing.Yes,
|
||||||
} as unknown as Task;
|
} as unknown as Task;
|
||||||
|
|
||||||
const noMemError = Object.assign(new Error('ENOMEM: not enough memory'), {code: 'ENOMEM'});
|
const noMemError = Object.assign(new Error('ENOMEM: not enough memory'), {code: 'ENOMEM'});
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
import {DepGraph} from 'dependency-graph';
|
import {DepGraph} from 'dependency-graph';
|
||||||
import {PartiallyOrderedTasks, Task} from '../../src/execution/tasks/api';
|
import {DtsProcessing, PartiallyOrderedTasks, Task} from '../../src/execution/tasks/api';
|
||||||
import {EntryPoint} from '../../src/packages/entry_point';
|
import {EntryPoint} from '../../src/packages/entry_point';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,7 +52,8 @@ export function createTasksAndGraph(
|
|||||||
graph.addNode(entryPoint.path);
|
graph.addNode(entryPoint.path);
|
||||||
|
|
||||||
for (let tIdx = 0; tIdx < tasksPerEntryPointCount; tIdx++) {
|
for (let tIdx = 0; tIdx < tasksPerEntryPointCount; tIdx++) {
|
||||||
tasks.push({entryPoint, formatProperty: `prop-${tIdx}`, processDts: tIdx === 0} as Task);
|
const processDts = tIdx === 0 ? DtsProcessing.Yes : DtsProcessing.No;
|
||||||
|
tasks.push({entryPoint, formatProperty: `prop-${tIdx}`, processDts} as Task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {MockLogger} from '../../../../../src/ngtsc/logging/testing';
|
import {MockLogger} from '../../../../../src/ngtsc/logging/testing';
|
||||||
import {PartiallyOrderedTasks, TaskQueue} from '../../../../src/execution/tasks/api';
|
import {DtsProcessing, PartiallyOrderedTasks, TaskQueue} from '../../../../src/execution/tasks/api';
|
||||||
import {ParallelTaskQueue} from '../../../../src/execution/tasks/queues/parallel_task_queue';
|
import {ParallelTaskQueue} from '../../../../src/execution/tasks/queues/parallel_task_queue';
|
||||||
import {computeTaskDependencies} from '../../../../src/execution/tasks/utils';
|
import {computeTaskDependencies} from '../../../../src/execution/tasks/utils';
|
||||||
import {createTasksAndGraph} from '../../helpers';
|
import {createTasksAndGraph} from '../../helpers';
|
||||||
@ -141,9 +141,9 @@ describe('ParallelTaskQueue', () => {
|
|||||||
|
|
||||||
// Verify that the first two tasks are for the first entry-point.
|
// Verify that the first two tasks are for the first entry-point.
|
||||||
expect(tasks[0].entryPoint.name).toBe('entry-point-0');
|
expect(tasks[0].entryPoint.name).toBe('entry-point-0');
|
||||||
expect(tasks[0].processDts).toBe(true);
|
expect(tasks[0].processDts).toBe(DtsProcessing.Yes);
|
||||||
expect(tasks[1].entryPoint.name).toBe('entry-point-0');
|
expect(tasks[1].entryPoint.name).toBe('entry-point-0');
|
||||||
expect(tasks[1].processDts).toBe(false);
|
expect(tasks[1].processDts).toBe(DtsProcessing.No);
|
||||||
|
|
||||||
// Verify that the last two tasks are for the second entry-point.
|
// Verify that the last two tasks are for the second entry-point.
|
||||||
expect(tasks[2].entryPoint.name).toBe('entry-point-1');
|
expect(tasks[2].entryPoint.name).toBe('entry-point-1');
|
||||||
@ -282,7 +282,7 @@ describe('ParallelTaskQueue', () => {
|
|||||||
expect(() => queue.markAsCompleted(tasks[2]))
|
expect(() => queue.markAsCompleted(tasks[2]))
|
||||||
.toThrowError(
|
.toThrowError(
|
||||||
`Trying to mark task that was not in progress as completed: ` +
|
`Trying to mark task that was not in progress as completed: ` +
|
||||||
`{entryPoint: entry-point-2, formatProperty: prop-0, processDts: true}`);
|
`{entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should remove the completed task from the lists of blocking tasks (so other tasks can be unblocked)',
|
it('should remove the completed task from the lists of blocking tasks (so other tasks can be unblocked)',
|
||||||
@ -340,13 +340,13 @@ describe('ParallelTaskQueue', () => {
|
|||||||
expect(() => queue.markAsUnprocessed(tasks[0]))
|
expect(() => queue.markAsUnprocessed(tasks[0]))
|
||||||
.toThrowError(
|
.toThrowError(
|
||||||
`Trying to mark task that was not in progress as unprocessed: ` +
|
`Trying to mark task that was not in progress as unprocessed: ` +
|
||||||
`{entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}`);
|
`{entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}`);
|
||||||
|
|
||||||
// Try with a task that is not yet started.
|
// Try with a task that is not yet started.
|
||||||
expect(() => queue.markAsUnprocessed(tasks[2]))
|
expect(() => queue.markAsUnprocessed(tasks[2]))
|
||||||
.toThrowError(
|
.toThrowError(
|
||||||
`Trying to mark task that was not in progress as unprocessed: ` +
|
`Trying to mark task that was not in progress as unprocessed: ` +
|
||||||
`{entryPoint: entry-point-2, formatProperty: prop-0, processDts: true}`);
|
`{entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not remove the unprocessed task from the lists of blocking tasks', () => {
|
it('should not remove the unprocessed task from the lists of blocking tasks', () => {
|
||||||
@ -399,23 +399,23 @@ describe('ParallelTaskQueue', () => {
|
|||||||
expect(queue.toString())
|
expect(queue.toString())
|
||||||
.toContain(
|
.toContain(
|
||||||
' Unprocessed tasks (3): \n' +
|
' Unprocessed tasks (3): \n' +
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: true}\n');
|
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes}\n');
|
||||||
|
|
||||||
const task1 = queue.getNextTask()!;
|
const task1 = queue.getNextTask()!;
|
||||||
expect(queue.toString())
|
expect(queue.toString())
|
||||||
.toContain(
|
.toContain(
|
||||||
' Unprocessed tasks (2): \n' +
|
' Unprocessed tasks (2): \n' +
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: true}\n');
|
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes}\n');
|
||||||
|
|
||||||
queue.markAsCompleted(task1);
|
queue.markAsCompleted(task1);
|
||||||
const task2 = queue.getNextTask()!;
|
const task2 = queue.getNextTask()!;
|
||||||
expect(queue.toString())
|
expect(queue.toString())
|
||||||
.toContain(
|
.toContain(
|
||||||
' Unprocessed tasks (1): \n' +
|
' Unprocessed tasks (1): \n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: true}\n');
|
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes}\n');
|
||||||
|
|
||||||
queue.markAsCompleted(task2);
|
queue.markAsCompleted(task2);
|
||||||
processNextTask(queue);
|
processNextTask(queue);
|
||||||
@ -430,14 +430,14 @@ describe('ParallelTaskQueue', () => {
|
|||||||
expect(queue.toString())
|
expect(queue.toString())
|
||||||
.toContain(
|
.toContain(
|
||||||
' In-progress tasks (1): \n' +
|
' In-progress tasks (1): \n' +
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}\n');
|
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}\n');
|
||||||
|
|
||||||
queue.markAsCompleted(task1);
|
queue.markAsCompleted(task1);
|
||||||
const task2 = queue.getNextTask()!;
|
const task2 = queue.getNextTask()!;
|
||||||
expect(queue.toString())
|
expect(queue.toString())
|
||||||
.toContain(
|
.toContain(
|
||||||
' In-progress tasks (1): \n' +
|
' In-progress tasks (1): \n' +
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: true}\n');
|
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: Yes}\n');
|
||||||
|
|
||||||
queue.markAsCompleted(task2);
|
queue.markAsCompleted(task2);
|
||||||
processNextTask(queue);
|
processNextTask(queue);
|
||||||
@ -463,29 +463,29 @@ describe('ParallelTaskQueue', () => {
|
|||||||
.toContain(
|
.toContain(
|
||||||
' Blocked tasks (6): \n' +
|
' Blocked tasks (6): \n' +
|
||||||
// #0.1 blocked by its typings #0.0
|
// #0.1 blocked by its typings #0.0
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-1, processDts: false} (1): \n' +
|
' - {entryPoint: entry-point-0, formatProperty: prop-1, processDts: No} (1): \n' +
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
// #1.0 blocked by #0.0
|
// #1.0 blocked by #0.0
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: true} (1): \n' +
|
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: Yes} (1): \n' +
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
// #1.1 blocked by #0.0 and its typings #1.0
|
// #1.1 blocked by #0.0 and its typings #1.0
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-1, processDts: false} (2): \n' +
|
' - {entryPoint: entry-point-1, formatProperty: prop-1, processDts: No} (2): \n' +
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
// #3.0 blocked by #0.0 (transitively), #1.0 and #2.0.
|
// #3.0 blocked by #0.0 (transitively), #1.0 and #2.0.
|
||||||
' - {entryPoint: entry-point-3, formatProperty: prop-0, processDts: true} (3): \n' +
|
' - {entryPoint: entry-point-3, formatProperty: prop-0, processDts: Yes} (3): \n' +
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
// #3.1 blocked by #0.0 (transitively), #1.0 and #2.0, and its typings #3.0
|
// #3.1 blocked by #0.0 (transitively), #1.0 and #2.0, and its typings #3.0
|
||||||
' - {entryPoint: entry-point-3, formatProperty: prop-1, processDts: false} (4): \n' +
|
' - {entryPoint: entry-point-3, formatProperty: prop-1, processDts: No} (4): \n' +
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-3, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-3, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
// #2.1 blocked by its typings #2.0
|
// #2.1 blocked by its typings #2.0
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-1, processDts: false} (1): \n' +
|
' - {entryPoint: entry-point-2, formatProperty: prop-1, processDts: No} (1): \n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: true}');
|
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes}');
|
||||||
|
|
||||||
expect(processNextTask(queue)).toBe(tasks[0]); // Process #0.0.
|
expect(processNextTask(queue)).toBe(tasks[0]); // Process #0.0.
|
||||||
expect(processNextTask(queue)).toBe(tasks[2]); // Process #1.0.
|
expect(processNextTask(queue)).toBe(tasks[2]); // Process #1.0.
|
||||||
@ -493,23 +493,23 @@ describe('ParallelTaskQueue', () => {
|
|||||||
.toContain(
|
.toContain(
|
||||||
' Blocked tasks (3): \n' +
|
' Blocked tasks (3): \n' +
|
||||||
// #3.0 blocked by #2.0.
|
// #3.0 blocked by #2.0.
|
||||||
' - {entryPoint: entry-point-3, formatProperty: prop-0, processDts: true} (1): \n' +
|
' - {entryPoint: entry-point-3, formatProperty: prop-0, processDts: Yes} (1): \n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
// #3.1 blocked by #2.0 and its typings #3.0
|
// #3.1 blocked by #2.0 and its typings #3.0
|
||||||
' - {entryPoint: entry-point-3, formatProperty: prop-1, processDts: false} (2): \n' +
|
' - {entryPoint: entry-point-3, formatProperty: prop-1, processDts: No} (2): \n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-3, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-3, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
// #2.1 blocked by its typings #2.0
|
// #2.1 blocked by its typings #2.0
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-1, processDts: false} (1): \n' +
|
' - {entryPoint: entry-point-2, formatProperty: prop-1, processDts: No} (1): \n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: true}');
|
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes}');
|
||||||
|
|
||||||
expect(processNextTask(queue)).toBe(tasks[4]); // Process #2.0.
|
expect(processNextTask(queue)).toBe(tasks[4]); // Process #2.0.
|
||||||
expect(queue.toString())
|
expect(queue.toString())
|
||||||
.toContain(
|
.toContain(
|
||||||
' Blocked tasks (1): \n' +
|
' Blocked tasks (1): \n' +
|
||||||
// #3.1 blocked by its typings #3.0
|
// #3.1 blocked by its typings #3.0
|
||||||
' - {entryPoint: entry-point-3, formatProperty: prop-1, processDts: false} (1): \n' +
|
' - {entryPoint: entry-point-3, formatProperty: prop-1, processDts: No} (1): \n' +
|
||||||
' - {entryPoint: entry-point-3, formatProperty: prop-0, processDts: true}');
|
' - {entryPoint: entry-point-3, formatProperty: prop-0, processDts: Yes}');
|
||||||
expect(processNextTask(queue)).toBe(tasks[6]); // Process #3.0.
|
expect(processNextTask(queue)).toBe(tasks[6]); // Process #3.0.
|
||||||
expect(queue.toString()).toContain(' Blocked tasks (0): ');
|
expect(queue.toString()).toContain(' Blocked tasks (0): ');
|
||||||
});
|
});
|
||||||
@ -532,13 +532,13 @@ describe('ParallelTaskQueue', () => {
|
|||||||
'ParallelTaskQueue\n' +
|
'ParallelTaskQueue\n' +
|
||||||
' All tasks completed: false\n' +
|
' All tasks completed: false\n' +
|
||||||
' Unprocessed tasks (3): \n' +
|
' Unprocessed tasks (3): \n' +
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' In-progress tasks (0): \n' +
|
' In-progress tasks (0): \n' +
|
||||||
' Blocked tasks (1): \n' +
|
' Blocked tasks (1): \n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: true} (1): \n' +
|
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes} (1): \n' +
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: true}');
|
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: Yes}');
|
||||||
|
|
||||||
// Start processing tasks #1 and #0 (#2 is still blocked on #1).
|
// Start processing tasks #1 and #0 (#2 is still blocked on #1).
|
||||||
expect(queue2.getNextTask()).toBe(tasks2[1]);
|
expect(queue2.getNextTask()).toBe(tasks2[1]);
|
||||||
@ -548,13 +548,13 @@ describe('ParallelTaskQueue', () => {
|
|||||||
'ParallelTaskQueue\n' +
|
'ParallelTaskQueue\n' +
|
||||||
' All tasks completed: false\n' +
|
' All tasks completed: false\n' +
|
||||||
' Unprocessed tasks (1): \n' +
|
' Unprocessed tasks (1): \n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' In-progress tasks (2): \n' +
|
' In-progress tasks (2): \n' +
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' Blocked tasks (1): \n' +
|
' Blocked tasks (1): \n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: true} (1): \n' +
|
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes} (1): \n' +
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: true}');
|
' - {entryPoint: entry-point-1, formatProperty: prop-0, processDts: Yes}');
|
||||||
|
|
||||||
// Complete task #1 nd start processing #2 (which is not unblocked).
|
// Complete task #1 nd start processing #2 (which is not unblocked).
|
||||||
queue2.markAsCompleted(tasks2[1]);
|
queue2.markAsCompleted(tasks2[1]);
|
||||||
@ -565,8 +565,8 @@ describe('ParallelTaskQueue', () => {
|
|||||||
' All tasks completed: false\n' +
|
' All tasks completed: false\n' +
|
||||||
' Unprocessed tasks (0): \n' +
|
' Unprocessed tasks (0): \n' +
|
||||||
' In-progress tasks (2): \n' +
|
' In-progress tasks (2): \n' +
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-2, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' Blocked tasks (0): ');
|
' Blocked tasks (0): ');
|
||||||
|
|
||||||
// Complete tasks #2 and #0. All tasks are now completed.
|
// Complete tasks #2 and #0. All tasks are now completed.
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import {DepGraph} from 'dependency-graph';
|
import {DepGraph} from 'dependency-graph';
|
||||||
|
|
||||||
import {MockLogger} from '../../../../../src/ngtsc/logging/testing';
|
import {MockLogger} from '../../../../../src/ngtsc/logging/testing';
|
||||||
import {PartiallyOrderedTasks, Task, TaskQueue} from '../../../../src/execution/tasks/api';
|
import {DtsProcessing, PartiallyOrderedTasks, Task, TaskQueue} from '../../../../src/execution/tasks/api';
|
||||||
import {SerialTaskQueue} from '../../../../src/execution/tasks/queues/serial_task_queue';
|
import {SerialTaskQueue} from '../../../../src/execution/tasks/queues/serial_task_queue';
|
||||||
import {computeTaskDependencies} from '../../../../src/execution/tasks/utils';
|
import {computeTaskDependencies} from '../../../../src/execution/tasks/utils';
|
||||||
import {EntryPoint} from '../../../../src/packages/entry_point';
|
import {EntryPoint} from '../../../../src/packages/entry_point';
|
||||||
@ -32,8 +32,8 @@ describe('SerialTaskQueue', () => {
|
|||||||
for (let i = 0; i < taskCount; i++) {
|
for (let i = 0; i < taskCount; i++) {
|
||||||
const entryPoint = {name: `entry-point-${i}`, path: `/path/to/entry/point/${i}`} as
|
const entryPoint = {name: `entry-point-${i}`, path: `/path/to/entry/point/${i}`} as
|
||||||
EntryPoint;
|
EntryPoint;
|
||||||
tasks.push(
|
const processDts = i % 2 === 0 ? DtsProcessing.Yes : DtsProcessing.No;
|
||||||
{entryPoint: entryPoint, formatProperty: `prop-${i}`, processDts: i % 2 === 0} as Task);
|
tasks.push({entryPoint: entryPoint, formatProperty: `prop-${i}`, processDts} as Task);
|
||||||
graph.addNode(entryPoint.path);
|
graph.addNode(entryPoint.path);
|
||||||
}
|
}
|
||||||
const dependencies = computeTaskDependencies(tasks, graph);
|
const dependencies = computeTaskDependencies(tasks, graph);
|
||||||
@ -131,7 +131,7 @@ describe('SerialTaskQueue', () => {
|
|||||||
expect(() => queue.getNextTask())
|
expect(() => queue.getNextTask())
|
||||||
.toThrowError(
|
.toThrowError(
|
||||||
`Trying to get next task, while there is already a task in progress: ` +
|
`Trying to get next task, while there is already a task in progress: ` +
|
||||||
`{entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}`);
|
`{entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ describe('SerialTaskQueue', () => {
|
|||||||
expect(() => queue.markAsCompleted(tasks[2]))
|
expect(() => queue.markAsCompleted(tasks[2]))
|
||||||
.toThrowError(
|
.toThrowError(
|
||||||
`Trying to mark task that was not in progress as completed: ` +
|
`Trying to mark task that was not in progress as completed: ` +
|
||||||
`{entryPoint: entry-point-2, formatProperty: prop-2, processDts: true}`);
|
`{entryPoint: entry-point-2, formatProperty: prop-2, processDts: Yes}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -177,13 +177,13 @@ describe('SerialTaskQueue', () => {
|
|||||||
expect(() => queue.markAsUnprocessed(tasks[0]))
|
expect(() => queue.markAsUnprocessed(tasks[0]))
|
||||||
.toThrowError(
|
.toThrowError(
|
||||||
`Trying to mark task that was not in progress as unprocessed: ` +
|
`Trying to mark task that was not in progress as unprocessed: ` +
|
||||||
`{entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}`);
|
`{entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}`);
|
||||||
|
|
||||||
// Try with a task that is not yet started.
|
// Try with a task that is not yet started.
|
||||||
expect(() => queue.markAsUnprocessed(tasks[2]))
|
expect(() => queue.markAsUnprocessed(tasks[2]))
|
||||||
.toThrowError(
|
.toThrowError(
|
||||||
`Trying to mark task that was not in progress as unprocessed: ` +
|
`Trying to mark task that was not in progress as unprocessed: ` +
|
||||||
`{entryPoint: entry-point-2, formatProperty: prop-2, processDts: true}`);
|
`{entryPoint: entry-point-2, formatProperty: prop-2, processDts: Yes}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -215,23 +215,23 @@ describe('SerialTaskQueue', () => {
|
|||||||
expect(queue.toString())
|
expect(queue.toString())
|
||||||
.toContain(
|
.toContain(
|
||||||
' Unprocessed tasks (3): \n' +
|
' Unprocessed tasks (3): \n' +
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-1, processDts: false}\n' +
|
' - {entryPoint: entry-point-1, formatProperty: prop-1, processDts: No}\n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-2, processDts: true}\n');
|
' - {entryPoint: entry-point-2, formatProperty: prop-2, processDts: Yes}\n');
|
||||||
|
|
||||||
const task1 = queue.getNextTask()!;
|
const task1 = queue.getNextTask()!;
|
||||||
expect(queue.toString())
|
expect(queue.toString())
|
||||||
.toContain(
|
.toContain(
|
||||||
' Unprocessed tasks (2): \n' +
|
' Unprocessed tasks (2): \n' +
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-1, processDts: false}\n' +
|
' - {entryPoint: entry-point-1, formatProperty: prop-1, processDts: No}\n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-2, processDts: true}\n');
|
' - {entryPoint: entry-point-2, formatProperty: prop-2, processDts: Yes}\n');
|
||||||
|
|
||||||
queue.markAsCompleted(task1);
|
queue.markAsCompleted(task1);
|
||||||
const task2 = queue.getNextTask()!;
|
const task2 = queue.getNextTask()!;
|
||||||
expect(queue.toString())
|
expect(queue.toString())
|
||||||
.toContain(
|
.toContain(
|
||||||
' Unprocessed tasks (1): \n' +
|
' Unprocessed tasks (1): \n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-2, processDts: true}\n');
|
' - {entryPoint: entry-point-2, formatProperty: prop-2, processDts: Yes}\n');
|
||||||
|
|
||||||
queue.markAsCompleted(task2);
|
queue.markAsCompleted(task2);
|
||||||
processNextTask(queue);
|
processNextTask(queue);
|
||||||
@ -246,14 +246,14 @@ describe('SerialTaskQueue', () => {
|
|||||||
expect(queue.toString())
|
expect(queue.toString())
|
||||||
.toContain(
|
.toContain(
|
||||||
' In-progress tasks (1): \n' +
|
' In-progress tasks (1): \n' +
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}');
|
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}');
|
||||||
|
|
||||||
queue.markAsCompleted(task1);
|
queue.markAsCompleted(task1);
|
||||||
const task2 = queue.getNextTask()!;
|
const task2 = queue.getNextTask()!;
|
||||||
expect(queue.toString())
|
expect(queue.toString())
|
||||||
.toContain(
|
.toContain(
|
||||||
' In-progress tasks (1): \n' +
|
' In-progress tasks (1): \n' +
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-1, processDts: false}');
|
' - {entryPoint: entry-point-1, formatProperty: prop-1, processDts: No}');
|
||||||
|
|
||||||
queue.markAsCompleted(task2);
|
queue.markAsCompleted(task2);
|
||||||
processNextTask(queue);
|
processNextTask(queue);
|
||||||
@ -275,9 +275,9 @@ describe('SerialTaskQueue', () => {
|
|||||||
'SerialTaskQueue\n' +
|
'SerialTaskQueue\n' +
|
||||||
' All tasks completed: false\n' +
|
' All tasks completed: false\n' +
|
||||||
' Unprocessed tasks (3): \n' +
|
' Unprocessed tasks (3): \n' +
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-1, processDts: false}\n' +
|
' - {entryPoint: entry-point-1, formatProperty: prop-1, processDts: No}\n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-2, processDts: true}\n' +
|
' - {entryPoint: entry-point-2, formatProperty: prop-2, processDts: Yes}\n' +
|
||||||
' In-progress tasks (0): ');
|
' In-progress tasks (0): ');
|
||||||
|
|
||||||
processNextTask(queue2);
|
processNextTask(queue2);
|
||||||
@ -287,9 +287,9 @@ describe('SerialTaskQueue', () => {
|
|||||||
'SerialTaskQueue\n' +
|
'SerialTaskQueue\n' +
|
||||||
' All tasks completed: false\n' +
|
' All tasks completed: false\n' +
|
||||||
' Unprocessed tasks (1): \n' +
|
' Unprocessed tasks (1): \n' +
|
||||||
' - {entryPoint: entry-point-2, formatProperty: prop-2, processDts: true}\n' +
|
' - {entryPoint: entry-point-2, formatProperty: prop-2, processDts: Yes}\n' +
|
||||||
' In-progress tasks (1): \n' +
|
' In-progress tasks (1): \n' +
|
||||||
' - {entryPoint: entry-point-1, formatProperty: prop-1, processDts: false}');
|
' - {entryPoint: entry-point-1, formatProperty: prop-1, processDts: No}');
|
||||||
|
|
||||||
queue2.markAsCompleted(task);
|
queue2.markAsCompleted(task);
|
||||||
processNextTask(queue2);
|
processNextTask(queue2);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
* Use of this source code is governed by an MIT-style license that can be
|
* 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
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
import {DtsProcessing} from '../../src/execution/tasks/api';
|
||||||
import {computeTaskDependencies, sortTasksByPriority} from '../../src/execution/tasks/utils';
|
import {computeTaskDependencies, sortTasksByPriority} from '../../src/execution/tasks/utils';
|
||||||
import {createTasksAndGraph} from './helpers';
|
import {createTasksAndGraph} from './helpers';
|
||||||
|
|
||||||
@ -16,14 +17,14 @@ describe('execution utils', () => {
|
|||||||
0: [], // Entry-point #0 does not depend on anything.
|
0: [], // Entry-point #0 does not depend on anything.
|
||||||
1: [0], // Entry-point #1 depends on #0.
|
1: [0], // Entry-point #1 depends on #0.
|
||||||
});
|
});
|
||||||
tasks[1].processDts = true; // Tweak task #1 to also generate typings.
|
tasks[1].processDts = DtsProcessing.Yes; // Tweak task #1 to also generate typings.
|
||||||
|
|
||||||
expect(() => computeTaskDependencies(tasks, graph))
|
expect(() => computeTaskDependencies(tasks, graph))
|
||||||
.toThrowError(
|
.toThrowError(
|
||||||
'Invariant violated: Multiple tasks are assigned generating typings for ' +
|
'Invariant violated: Multiple tasks are assigned generating typings for ' +
|
||||||
'\'/path/to/entry/point/0\':\n' +
|
'\'/path/to/entry/point/0\':\n' +
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: true}\n' +
|
' - {entryPoint: entry-point-0, formatProperty: prop-0, processDts: Yes}\n' +
|
||||||
' - {entryPoint: entry-point-0, formatProperty: prop-1, processDts: true}');
|
' - {entryPoint: entry-point-0, formatProperty: prop-1, processDts: Yes}');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add non-typings tasks to the dependents of typings tasks', () => {
|
it('should add non-typings tasks to the dependents of typings tasks', () => {
|
||||||
|
@ -9,6 +9,7 @@ import * as ts from 'typescript';
|
|||||||
|
|
||||||
import {absoluteFrom, AbsoluteFsPath, getFileSystem, NgtscCompilerHost} from '../../../src/ngtsc/file_system';
|
import {absoluteFrom, AbsoluteFsPath, getFileSystem, NgtscCompilerHost} from '../../../src/ngtsc/file_system';
|
||||||
import {TestFile} from '../../../src/ngtsc/file_system/testing';
|
import {TestFile} from '../../../src/ngtsc/file_system/testing';
|
||||||
|
import {DtsProcessing} from '../../src/execution/tasks/api';
|
||||||
import {BundleProgram, makeBundleProgram} from '../../src/packages/bundle_program';
|
import {BundleProgram, makeBundleProgram} from '../../src/packages/bundle_program';
|
||||||
import {NgccEntryPointConfig} from '../../src/packages/configuration';
|
import {NgccEntryPointConfig} from '../../src/packages/configuration';
|
||||||
import {EntryPoint, EntryPointFormat} from '../../src/packages/entry_point';
|
import {EntryPoint, EntryPointFormat} from '../../src/packages/entry_point';
|
||||||
@ -55,6 +56,7 @@ export function makeTestEntryPointBundle(
|
|||||||
rootDirs: [absoluteFrom('/')],
|
rootDirs: [absoluteFrom('/')],
|
||||||
src,
|
src,
|
||||||
dts,
|
dts,
|
||||||
|
dtsProcessing: dtsRootNames ? DtsProcessing.Yes : DtsProcessing.No,
|
||||||
isCore,
|
isCore,
|
||||||
isFlatCore,
|
isFlatCore,
|
||||||
enableI18nLegacyMessageIdFormat
|
enableI18nLegacyMessageIdFormat
|
||||||
|
@ -25,6 +25,7 @@ import {DirectPackageJsonUpdater, PackageJsonUpdater} from '../../src/writing/pa
|
|||||||
|
|
||||||
import {compileIntoApf, compileIntoFlatEs2015Package, compileIntoFlatEs5Package} from './util';
|
import {compileIntoApf, compileIntoFlatEs2015Package, compileIntoFlatEs5Package} from './util';
|
||||||
|
|
||||||
|
const ANGULAR_CORE_IMPORT_REGEX = /import \* as ɵngcc\d+ from '@angular\/core';/;
|
||||||
const testFiles = loadStandardTestFiles({fakeCore: false, rxjs: true});
|
const testFiles = loadStandardTestFiles({fakeCore: false, rxjs: true});
|
||||||
|
|
||||||
runInEachFileSystem(() => {
|
runInEachFileSystem(() => {
|
||||||
@ -1240,9 +1241,94 @@ runInEachFileSystem(() => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('with typingsOnly set to true', () => {
|
||||||
|
it('should only compile the typings', () => {
|
||||||
|
mainNgcc({
|
||||||
|
basePath: '/node_modules',
|
||||||
|
propertiesToConsider: ['module', 'fesm2015', 'main'],
|
||||||
|
typingsOnly: true,
|
||||||
|
compileAllFormats: true,
|
||||||
|
logger: new MockLogger(),
|
||||||
|
});
|
||||||
|
expect(loadPackage('@angular/core').__processed_by_ivy_ngcc__).toEqual({
|
||||||
|
typings: '0.0.0-PLACEHOLDER',
|
||||||
|
});
|
||||||
|
expect(loadPackage('@angular/common').__processed_by_ivy_ngcc__).toEqual({
|
||||||
|
typings: '0.0.0-PLACEHOLDER',
|
||||||
|
});
|
||||||
|
expect(loadPackage('@angular/common/testing').__processed_by_ivy_ngcc__).toEqual({
|
||||||
|
typings: '0.0.0-PLACEHOLDER',
|
||||||
|
});
|
||||||
|
expect(loadPackage('@angular/common/http').__processed_by_ivy_ngcc__).toEqual({
|
||||||
|
typings: '0.0.0-PLACEHOLDER',
|
||||||
|
});
|
||||||
|
|
||||||
|
// Doesn't touch original source files
|
||||||
|
expect(fs.readFile(_(`/node_modules/@angular/common/esm2015/src/common_module.js`)))
|
||||||
|
.not.toMatch(ANGULAR_CORE_IMPORT_REGEX);
|
||||||
|
// Or create a backup of the original
|
||||||
|
expect(fs.exists(
|
||||||
|
_(`/node_modules/@angular/common/esm2015/src/common_module.js.__ivy_ngcc_bak`)))
|
||||||
|
.toBe(false);
|
||||||
|
|
||||||
|
// Overwrites .d.ts files
|
||||||
|
expect(fs.readFile(_(`/node_modules/@angular/common/common.d.ts`)))
|
||||||
|
.toMatch(ANGULAR_CORE_IMPORT_REGEX);
|
||||||
|
// And makes a backup
|
||||||
|
expect(fs.exists(_(`/node_modules/@angular/common/common.d.ts.__ivy_ngcc_bak`))).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should cope with compiling the same entry-point multiple times with different formats',
|
||||||
|
() => {
|
||||||
|
mainNgcc({
|
||||||
|
basePath: '/node_modules',
|
||||||
|
propertiesToConsider: ['main'],
|
||||||
|
typingsOnly: true,
|
||||||
|
logger: new MockLogger(),
|
||||||
|
});
|
||||||
|
expect(loadPackage('@angular/core').__processed_by_ivy_ngcc__).toEqual({
|
||||||
|
typings: '0.0.0-PLACEHOLDER',
|
||||||
|
});
|
||||||
|
|
||||||
|
// If ngcc tries to write out the typings files again, this will throw an exception.
|
||||||
|
mainNgcc({
|
||||||
|
basePath: '/node_modules',
|
||||||
|
propertiesToConsider: ['esm2015'],
|
||||||
|
typingsOnly: true,
|
||||||
|
logger: new MockLogger(),
|
||||||
|
});
|
||||||
|
expect(loadPackage('@angular/core').__processed_by_ivy_ngcc__).toEqual({
|
||||||
|
typings: '0.0.0-PLACEHOLDER',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should cope with compiling typings only followed by javascript formats', () => {
|
||||||
|
mainNgcc({
|
||||||
|
basePath: '/node_modules',
|
||||||
|
propertiesToConsider: ['esm2015', 'main'],
|
||||||
|
typingsOnly: true,
|
||||||
|
logger: new MockLogger(),
|
||||||
|
});
|
||||||
|
expect(loadPackage('@angular/core').__processed_by_ivy_ngcc__).toEqual({
|
||||||
|
typings: '0.0.0-PLACEHOLDER',
|
||||||
|
});
|
||||||
|
|
||||||
|
// If ngcc tries to write out the typings files again, this will throw an exception.
|
||||||
|
mainNgcc({
|
||||||
|
basePath: '/node_modules',
|
||||||
|
propertiesToConsider: ['esm2015', 'main'],
|
||||||
|
logger: new MockLogger(),
|
||||||
|
});
|
||||||
|
expect(loadPackage('@angular/core').__processed_by_ivy_ngcc__).toEqual({
|
||||||
|
main: '0.0.0-PLACEHOLDER',
|
||||||
|
esm2015: '0.0.0-PLACEHOLDER',
|
||||||
|
typings: '0.0.0-PLACEHOLDER',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('with createNewEntryPointFormats', () => {
|
describe('with createNewEntryPointFormats', () => {
|
||||||
it('should create new files rather than overwriting the originals', () => {
|
it('should create new files rather than overwriting the originals', () => {
|
||||||
const ANGULAR_CORE_IMPORT_REGEX = /import \* as ɵngcc\d+ from '@angular\/core';/;
|
|
||||||
mainNgcc({
|
mainNgcc({
|
||||||
basePath: '/node_modules',
|
basePath: '/node_modules',
|
||||||
createNewEntryPointFormats: true,
|
createNewEntryPointFormats: true,
|
||||||
|
@ -99,6 +99,23 @@ runInEachFileSystem(() => {
|
|||||||
expect(setup.tsConfig?.rootNames).toEqual([]);
|
expect(setup.tsConfig?.rootNames).toEqual([]);
|
||||||
expect((setup.logger as MockLogger).logs.warn).toEqual([]);
|
expect((setup.logger as MockLogger).logs.warn).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not modify `compileAllFormats` if `typingsOnly` is falsy', () => {
|
||||||
|
let setup = getSharedSetup({...createOptions(), compileAllFormats: true, typingsOnly: false});
|
||||||
|
expect(setup.typingsOnly).toBe(false);
|
||||||
|
expect(setup.compileAllFormats).toBe(true);
|
||||||
|
|
||||||
|
setup = getSharedSetup({...createOptions(), compileAllFormats: true});
|
||||||
|
expect(setup.typingsOnly).toBe(false);
|
||||||
|
expect(setup.compileAllFormats).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should force `compileAllFormats` to false if `typingsOnly` is true', () => {
|
||||||
|
const setup =
|
||||||
|
getSharedSetup({...createOptions(), compileAllFormats: true, typingsOnly: true});
|
||||||
|
expect(setup.typingsOnly).toBe(true);
|
||||||
|
expect(setup.compileAllFormats).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getMaxNumberOfWorkers', () => {
|
describe('getMaxNumberOfWorkers', () => {
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
import {absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_system';
|
import {absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_system';
|
||||||
import {runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
import {runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
||||||
import {loadTestFiles} from '../../../src/ngtsc/testing';
|
import {loadTestFiles} from '../../../src/ngtsc/testing';
|
||||||
|
import {DtsProcessing} from '../../src/execution/tasks/api';
|
||||||
import {EntryPoint} from '../../src/packages/entry_point';
|
import {EntryPoint} from '../../src/packages/entry_point';
|
||||||
import {makeEntryPointBundle} from '../../src/packages/entry_point_bundle';
|
import {makeEntryPointBundle} from '../../src/packages/entry_point_bundle';
|
||||||
import {createModuleResolutionCache, SharedFileCache} from '../../src/packages/source_file_cache';
|
import {createModuleResolutionCache, SharedFileCache} from '../../src/packages/source_file_cache';
|
||||||
@ -184,7 +185,7 @@ runInEachFileSystem(() => {
|
|||||||
const moduleResolutionCache = createModuleResolutionCache(fs);
|
const moduleResolutionCache = createModuleResolutionCache(fs);
|
||||||
const esm5bundle = makeEntryPointBundle(
|
const esm5bundle = makeEntryPointBundle(
|
||||||
fs, entryPoint, new SharedFileCache(fs), moduleResolutionCache, './index.js', false,
|
fs, entryPoint, new SharedFileCache(fs), moduleResolutionCache, './index.js', false,
|
||||||
'esm5', true);
|
'esm5', DtsProcessing.Yes);
|
||||||
|
|
||||||
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
||||||
.toEqual(jasmine.arrayWithExactContents([
|
.toEqual(jasmine.arrayWithExactContents([
|
||||||
@ -298,8 +299,7 @@ runInEachFileSystem(() => {
|
|||||||
const moduleResolutionCache = createModuleResolutionCache(fs);
|
const moduleResolutionCache = createModuleResolutionCache(fs);
|
||||||
const esm5bundle = makeEntryPointBundle(
|
const esm5bundle = makeEntryPointBundle(
|
||||||
fs, entryPoint, new SharedFileCache(fs), moduleResolutionCache, './index.js', false,
|
fs, entryPoint, new SharedFileCache(fs), moduleResolutionCache, './index.js', false,
|
||||||
'esm5',
|
'esm5', DtsProcessing.Yes,
|
||||||
/* transformDts */ true,
|
|
||||||
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ true);
|
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ true);
|
||||||
|
|
||||||
expect(esm5bundle.src.program.getSourceFiles().map(sf => _(sf.fileName)))
|
expect(esm5bundle.src.program.getSourceFiles().map(sf => _(sf.fileName)))
|
||||||
@ -338,8 +338,7 @@ runInEachFileSystem(() => {
|
|||||||
const moduleResolutionCache = createModuleResolutionCache(fs);
|
const moduleResolutionCache = createModuleResolutionCache(fs);
|
||||||
const esm5bundle = makeEntryPointBundle(
|
const esm5bundle = makeEntryPointBundle(
|
||||||
fs, entryPoint, new SharedFileCache(fs), moduleResolutionCache, './index.js', false,
|
fs, entryPoint, new SharedFileCache(fs), moduleResolutionCache, './index.js', false,
|
||||||
'esm5',
|
'esm5', DtsProcessing.Yes,
|
||||||
/* transformDts */ true,
|
|
||||||
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ true);
|
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ true);
|
||||||
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
||||||
.toContain(absoluteFrom('/node_modules/test/internal.js'));
|
.toContain(absoluteFrom('/node_modules/test/internal.js'));
|
||||||
@ -364,8 +363,7 @@ runInEachFileSystem(() => {
|
|||||||
const moduleResolutionCache = createModuleResolutionCache(fs);
|
const moduleResolutionCache = createModuleResolutionCache(fs);
|
||||||
const esm5bundle = makeEntryPointBundle(
|
const esm5bundle = makeEntryPointBundle(
|
||||||
fs, entryPoint, new SharedFileCache(fs), moduleResolutionCache,
|
fs, entryPoint, new SharedFileCache(fs), moduleResolutionCache,
|
||||||
'./esm2015/index.js', false, 'esm2015',
|
'./esm2015/index.js', false, 'esm2015', DtsProcessing.Yes,
|
||||||
/* transformDts */ true,
|
|
||||||
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ true);
|
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ true);
|
||||||
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
||||||
.toContain(absoluteFrom('/node_modules/internal/esm2015/src/internal.js'));
|
.toContain(absoluteFrom('/node_modules/internal/esm2015/src/internal.js'));
|
||||||
@ -390,8 +388,7 @@ runInEachFileSystem(() => {
|
|||||||
const moduleResolutionCache = createModuleResolutionCache(fs);
|
const moduleResolutionCache = createModuleResolutionCache(fs);
|
||||||
const esm5bundle = makeEntryPointBundle(
|
const esm5bundle = makeEntryPointBundle(
|
||||||
fs, entryPoint, new SharedFileCache(fs), moduleResolutionCache, './index.js', false,
|
fs, entryPoint, new SharedFileCache(fs), moduleResolutionCache, './index.js', false,
|
||||||
'esm5',
|
'esm5', DtsProcessing.Yes,
|
||||||
/* transformDts */ true,
|
|
||||||
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ false);
|
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ false);
|
||||||
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
||||||
.toContain(absoluteFrom('/node_modules/test/internal.js'));
|
.toContain(absoluteFrom('/node_modules/test/internal.js'));
|
||||||
@ -417,8 +414,7 @@ runInEachFileSystem(() => {
|
|||||||
const moduleResolutionCache = createModuleResolutionCache(fs);
|
const moduleResolutionCache = createModuleResolutionCache(fs);
|
||||||
const bundle = makeEntryPointBundle(
|
const bundle = makeEntryPointBundle(
|
||||||
fs, entryPoint, new SharedFileCache(fs), moduleResolutionCache, './index.js', false,
|
fs, entryPoint, new SharedFileCache(fs), moduleResolutionCache, './index.js', false,
|
||||||
'esm2015',
|
'esm2015', DtsProcessing.Yes,
|
||||||
/* transformDts */ true,
|
|
||||||
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ true);
|
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ true);
|
||||||
expect(bundle.rootDirs).toEqual([absoluteFrom('/node_modules/primary')]);
|
expect(bundle.rootDirs).toEqual([absoluteFrom('/node_modules/primary')]);
|
||||||
});
|
});
|
||||||
|
@ -10,6 +10,7 @@ import {runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
|||||||
import {MockLogger} from '../../../src/ngtsc/logging/testing';
|
import {MockLogger} from '../../../src/ngtsc/logging/testing';
|
||||||
import {RawSourceMap} from '../../../src/ngtsc/sourcemaps';
|
import {RawSourceMap} from '../../../src/ngtsc/sourcemaps';
|
||||||
import {loadTestFiles} from '../../../src/ngtsc/testing';
|
import {loadTestFiles} from '../../../src/ngtsc/testing';
|
||||||
|
import {DtsProcessing} from '../../src/execution/tasks/api';
|
||||||
import {NgccConfiguration} from '../../src/packages/configuration';
|
import {NgccConfiguration} from '../../src/packages/configuration';
|
||||||
import {EntryPoint, EntryPointFormat, EntryPointJsonProperty, getEntryPointInfo, isEntryPoint} from '../../src/packages/entry_point';
|
import {EntryPoint, EntryPointFormat, EntryPointJsonProperty, getEntryPointInfo, isEntryPoint} from '../../src/packages/entry_point';
|
||||||
import {EntryPointBundle, makeEntryPointBundle} from '../../src/packages/entry_point_bundle';
|
import {EntryPointBundle, makeEntryPointBundle} from '../../src/packages/entry_point_bundle';
|
||||||
@ -731,6 +732,6 @@ runInEachFileSystem(() => {
|
|||||||
const moduleResolutionCache = createModuleResolutionCache(fs);
|
const moduleResolutionCache = createModuleResolutionCache(fs);
|
||||||
return makeEntryPointBundle(
|
return makeEntryPointBundle(
|
||||||
fs, entryPoint, new SharedFileCache(fs), moduleResolutionCache,
|
fs, entryPoint, new SharedFileCache(fs), moduleResolutionCache,
|
||||||
entryPoint.packageJson[formatProperty]!, false, format, true);
|
entryPoint.packageJson[formatProperty]!, false, format, DtsProcessing.Yes);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user