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:
parent
a94bdc6793
commit
e943859843
|
@ -18,6 +18,7 @@ import {NgccSourcesCompilerHost} from './ngcc_compiler_host';
|
||||||
* format of a package entry-point.
|
* format of a package entry-point.
|
||||||
*/
|
*/
|
||||||
export interface EntryPointBundle {
|
export interface EntryPointBundle {
|
||||||
|
entryPoint: EntryPoint;
|
||||||
formatProperty: EntryPointJsonProperty;
|
formatProperty: EntryPointJsonProperty;
|
||||||
format: EntryPointFormat;
|
format: EntryPointFormat;
|
||||||
isCore: boolean;
|
isCore: boolean;
|
||||||
|
@ -60,5 +61,5 @@ export function makeEntryPointBundle(
|
||||||
null;
|
null;
|
||||||
const isFlatCore = isCore && src.r3SymbolsFile === null;
|
const isFlatCore = isCore && src.r3SymbolsFile === null;
|
||||||
|
|
||||||
return {format, formatProperty, rootDirs, isCore, isFlatCore, src, dts};
|
return {entryPoint, format, formatProperty, rootDirs, isCore, isFlatCore, src, dts};
|
||||||
}
|
}
|
||||||
|
|
|
@ -330,7 +330,7 @@ runInEachFileSystem(() => {
|
||||||
loadTestFiles(TEST_PROGRAM);
|
loadTestFiles(TEST_PROGRAM);
|
||||||
loadTestFiles(TEST_DTS_PROGRAM);
|
loadTestFiles(TEST_DTS_PROGRAM);
|
||||||
const bundle = makeTestEntryPointBundle(
|
const bundle = makeTestEntryPointBundle(
|
||||||
'esm2015', 'esm2015', false, getRootFiles(TEST_PROGRAM),
|
'test-package', 'esm2015', 'esm2015', false, getRootFiles(TEST_PROGRAM),
|
||||||
getRootFiles(TEST_DTS_PROGRAM));
|
getRootFiles(TEST_DTS_PROGRAM));
|
||||||
program = bundle.src.program;
|
program = bundle.src.program;
|
||||||
dtsProgram = bundle.dts;
|
dtsProgram = bundle.dts;
|
||||||
|
|
|
@ -225,7 +225,8 @@ runInEachFileSystem(() => {
|
||||||
loadTestFiles(jsProgram);
|
loadTestFiles(jsProgram);
|
||||||
loadTestFiles(dtsProgram);
|
loadTestFiles(dtsProgram);
|
||||||
const {src: {program}, dts} = makeTestEntryPointBundle(
|
const {src: {program}, dts} = makeTestEntryPointBundle(
|
||||||
'esm2015', 'esm2015', false, getRootFiles(jsProgram), getRootFiles(dtsProgram));
|
'test-package', 'esm2015', 'esm2015', false, getRootFiles(jsProgram),
|
||||||
|
getRootFiles(dtsProgram));
|
||||||
const host = new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker(), dts);
|
const host = new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker(), dts);
|
||||||
const referencesRegistry = new NgccReferencesRegistry(host);
|
const referencesRegistry = new NgccReferencesRegistry(host);
|
||||||
const analyzer = new PrivateDeclarationsAnalyzer(host, referencesRegistry);
|
const analyzer = new PrivateDeclarationsAnalyzer(host, referencesRegistry);
|
||||||
|
|
|
@ -8,10 +8,22 @@
|
||||||
import {AbsoluteFsPath, NgtscCompilerHost, absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_system';
|
import {AbsoluteFsPath, NgtscCompilerHost, absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_system';
|
||||||
import {TestFile} from '../../../src/ngtsc/file_system/testing';
|
import {TestFile} from '../../../src/ngtsc/file_system/testing';
|
||||||
import {BundleProgram, makeBundleProgram} from '../../src/packages/bundle_program';
|
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 {EntryPointBundle} from '../../src/packages/entry_point_bundle';
|
||||||
import {NgccSourcesCompilerHost} from '../../src/packages/ngcc_compiler_host';
|
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.
|
* @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.
|
* @param dtsFiles The typings files to include the bundle.
|
||||||
*/
|
*/
|
||||||
export function makeTestEntryPointBundle(
|
export function makeTestEntryPointBundle(
|
||||||
formatProperty: EntryPointJsonProperty, format: EntryPointFormat, isCore: boolean,
|
packageName: string, formatProperty: EntryPointJsonProperty, format: EntryPointFormat,
|
||||||
srcRootNames: AbsoluteFsPath[], dtsRootNames?: AbsoluteFsPath[]): EntryPointBundle {
|
isCore: boolean, srcRootNames: AbsoluteFsPath[],
|
||||||
|
dtsRootNames?: AbsoluteFsPath[]): EntryPointBundle {
|
||||||
|
const entryPoint = makeTestEntryPoint(packageName);
|
||||||
const src = makeTestBundleProgram(srcRootNames[0], isCore);
|
const src = makeTestBundleProgram(srcRootNames[0], isCore);
|
||||||
const dts = dtsRootNames ? makeTestDtsBundleProgram(dtsRootNames[0], isCore) : null;
|
const dts = dtsRootNames ? makeTestDtsBundleProgram(dtsRootNames[0], isCore) : null;
|
||||||
const isFlatCore = isCore && src.r3SymbolsFile === 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(
|
export function makeTestBundleProgram(
|
||||||
|
|
|
@ -149,7 +149,8 @@ exports.D = D;
|
||||||
loadTestFiles([file]);
|
loadTestFiles([file]);
|
||||||
const fs = getFileSystem();
|
const fs = getFileSystem();
|
||||||
const logger = new MockLogger();
|
const logger = new MockLogger();
|
||||||
const bundle = makeTestEntryPointBundle('module', 'commonjs', false, [file.name]);
|
const bundle =
|
||||||
|
makeTestEntryPointBundle('test-package', 'module', 'commonjs', false, [file.name]);
|
||||||
const typeChecker = bundle.src.program.getTypeChecker();
|
const typeChecker = bundle.src.program.getTypeChecker();
|
||||||
const host = new CommonJsReflectionHost(logger, false, bundle.src.program, bundle.src.host);
|
const host = new CommonJsReflectionHost(logger, false, bundle.src.program, bundle.src.host);
|
||||||
const referencesRegistry = new NgccReferencesRegistry(host);
|
const referencesRegistry = new NgccReferencesRegistry(host);
|
||||||
|
|
|
@ -60,7 +60,8 @@ function createTestRenderer(
|
||||||
const fs = getFileSystem();
|
const fs = getFileSystem();
|
||||||
const isCore = packageName === '@angular/core';
|
const isCore = packageName === '@angular/core';
|
||||||
const bundle = makeTestEntryPointBundle(
|
const bundle = makeTestEntryPointBundle(
|
||||||
'es2015', 'esm2015', isCore, getRootFiles(files), dtsFiles && getRootFiles(dtsFiles));
|
'test-package', 'es2015', 'esm2015', isCore, getRootFiles(files),
|
||||||
|
dtsFiles && getRootFiles(dtsFiles));
|
||||||
const typeChecker = bundle.src.program.getTypeChecker();
|
const typeChecker = bundle.src.program.getTypeChecker();
|
||||||
const host = new Esm2015ReflectionHost(logger, isCore, typeChecker, bundle.dts);
|
const host = new Esm2015ReflectionHost(logger, isCore, typeChecker, bundle.dts);
|
||||||
const referencesRegistry = new NgccReferencesRegistry(host);
|
const referencesRegistry = new NgccReferencesRegistry(host);
|
||||||
|
|
|
@ -26,7 +26,7 @@ function setup(file: {name: AbsoluteFsPath, contents: string}) {
|
||||||
loadTestFiles([file]);
|
loadTestFiles([file]);
|
||||||
const fs = getFileSystem();
|
const fs = getFileSystem();
|
||||||
const logger = new MockLogger();
|
const logger = new MockLogger();
|
||||||
const bundle = makeTestEntryPointBundle('module', 'esm5', false, [file.name]);
|
const bundle = makeTestEntryPointBundle('test-package', 'module', 'esm5', false, [file.name]);
|
||||||
const typeChecker = bundle.src.program.getTypeChecker();
|
const typeChecker = bundle.src.program.getTypeChecker();
|
||||||
const host = new Esm5ReflectionHost(logger, false, typeChecker);
|
const host = new Esm5ReflectionHost(logger, false, typeChecker);
|
||||||
const referencesRegistry = new NgccReferencesRegistry(host);
|
const referencesRegistry = new NgccReferencesRegistry(host);
|
||||||
|
|
|
@ -30,7 +30,8 @@ function setup(files: TestFile[], dtsFiles?: TestFile[]) {
|
||||||
const fs = getFileSystem();
|
const fs = getFileSystem();
|
||||||
const logger = new MockLogger();
|
const logger = new MockLogger();
|
||||||
const bundle = makeTestEntryPointBundle(
|
const bundle = makeTestEntryPointBundle(
|
||||||
'es2015', 'esm2015', false, getRootFiles(files), dtsFiles && getRootFiles(dtsFiles)) !;
|
'test-package', 'es2015', 'esm2015', false, getRootFiles(files),
|
||||||
|
dtsFiles && getRootFiles(dtsFiles)) !;
|
||||||
const typeChecker = bundle.src.program.getTypeChecker();
|
const typeChecker = bundle.src.program.getTypeChecker();
|
||||||
const host = new Esm2015ReflectionHost(logger, false, typeChecker, bundle.dts);
|
const host = new Esm2015ReflectionHost(logger, false, typeChecker, bundle.dts);
|
||||||
const referencesRegistry = new NgccReferencesRegistry(host);
|
const referencesRegistry = new NgccReferencesRegistry(host);
|
||||||
|
|
|
@ -62,7 +62,8 @@ function createTestRenderer(
|
||||||
const fs = getFileSystem();
|
const fs = getFileSystem();
|
||||||
const isCore = packageName === '@angular/core';
|
const isCore = packageName === '@angular/core';
|
||||||
const bundle = makeTestEntryPointBundle(
|
const bundle = makeTestEntryPointBundle(
|
||||||
'es2015', 'esm2015', isCore, getRootFiles(files), dtsFiles && getRootFiles(dtsFiles));
|
'test-package', 'es2015', 'esm2015', isCore, getRootFiles(files),
|
||||||
|
dtsFiles && getRootFiles(dtsFiles));
|
||||||
const typeChecker = bundle.src.program.getTypeChecker();
|
const typeChecker = bundle.src.program.getTypeChecker();
|
||||||
const host = new Esm2015ReflectionHost(logger, isCore, typeChecker, bundle.dts);
|
const host = new Esm2015ReflectionHost(logger, isCore, typeChecker, bundle.dts);
|
||||||
const referencesRegistry = new NgccReferencesRegistry(host);
|
const referencesRegistry = new NgccReferencesRegistry(host);
|
||||||
|
|
|
@ -25,7 +25,7 @@ function setup(file: TestFile) {
|
||||||
loadTestFiles([file]);
|
loadTestFiles([file]);
|
||||||
const fs = getFileSystem();
|
const fs = getFileSystem();
|
||||||
const logger = new MockLogger();
|
const logger = new MockLogger();
|
||||||
const bundle = makeTestEntryPointBundle('esm5', 'esm5', false, [file.name]);
|
const bundle = makeTestEntryPointBundle('test-package', 'esm5', 'esm5', false, [file.name]);
|
||||||
const src = bundle.src;
|
const src = bundle.src;
|
||||||
const typeChecker = src.program.getTypeChecker();
|
const typeChecker = src.program.getTypeChecker();
|
||||||
const host = new UmdReflectionHost(logger, false, src.program, src.host);
|
const host = new UmdReflectionHost(logger, false, src.program, src.host);
|
||||||
|
|
Loading…
Reference in New Issue