feat(ngcc): enable private NgModule re-exports in ngcc on request (#33177)

This commit adapts the private NgModule re-export system (using aliasing) to
ngcc. Not all ngcc compilations are compatible with these re-exports, as
they assume a 1:1 correspondence between .js and .d.ts files. The primary
concern here is supporting them for commonjs-only packages.

PR Close #33177
This commit is contained in:
Alex Rickabaugh
2019-10-14 13:04:42 -07:00
committed by Matias Niemelä
parent c4733c15c0
commit e030375d9a
17 changed files with 287 additions and 11 deletions

View File

@ -6,15 +6,19 @@
* found in the LICENSE file at https://angular.io/license
*/
import * as ts from 'typescript';
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 {NgccEntryPointConfig} from '../../src/packages/configuration';
import {EntryPoint, EntryPointFormat} from '../../src/packages/entry_point';
import {EntryPointBundle} from '../../src/packages/entry_point_bundle';
import {NgccSourcesCompilerHost} from '../../src/packages/ngcc_compiler_host';
export type TestConfig = Pick<NgccEntryPointConfig, 'generateDeepReexports'>;
export function makeTestEntryPoint(
entryPointName: string, packageName: string = entryPointName): EntryPoint {
entryPointName: string, packageName: string = entryPointName, config?: TestConfig): EntryPoint {
return {
name: entryPointName,
packageJson: {name: entryPointName},
@ -23,6 +27,7 @@ export function makeTestEntryPoint(
typings: absoluteFrom(`/node_modules/${entryPointName}/index.d.ts`),
compiledByAngular: true,
ignoreMissingDependencies: false,
generateDeepReexports: config !== undefined ? !!config.generateDeepReexports : false,
};
}
@ -34,8 +39,8 @@ export function makeTestEntryPoint(
*/
export function makeTestEntryPointBundle(
packageName: string, format: EntryPointFormat, isCore: boolean, srcRootNames: AbsoluteFsPath[],
dtsRootNames?: AbsoluteFsPath[]): EntryPointBundle {
const entryPoint = makeTestEntryPoint(packageName);
dtsRootNames?: AbsoluteFsPath[], config?: TestConfig): EntryPointBundle {
const entryPoint = makeTestEntryPoint(packageName, packageName, config);
const src = makeTestBundleProgram(srcRootNames[0], isCore);
const dts =
dtsRootNames ? makeTestDtsBundleProgram(dtsRootNames[0], entryPoint.package, isCore) : null;