refactor(ngcc): rename `ReexportStatement` to `WildcardReexportStatement` (#36989)

The term `ReexportStatement` is too general for this particular concept.
Here the re-export actually refers to a wildcard where all the module
exports are being re-exported.

When we introduce other re-export statement types later this will be
confusing.

PR Close #36989
This commit is contained in:
Pete Bacon Darwin 2020-05-12 08:20:01 +01:00 committed by Kara Erickson
parent 9846b19986
commit 0672a0e547
4 changed files with 14 additions and 14 deletions

View File

@ -8,7 +8,7 @@
import * as ts from 'typescript';
import {AbsoluteFsPath} from '../../../src/ngtsc/file_system';
import {isReexportStatement, isRequireCall, RequireCall} from '../host/commonjs_umd_utils';
import {isRequireCall, isWildcardReexportStatement, RequireCall} from '../host/commonjs_umd_utils';
import {DependencyHostBase} from './dependency_host';
import {ResolvedDeepImport, ResolvedRelativeModule} from './module_resolver';
@ -59,7 +59,7 @@ export class CommonJsDependencyHost extends DependencyHostBase {
// Import for the side-effects only:
// `require('...')`
requireCalls.push(stmt.expression);
} else if (isReexportStatement(stmt)) {
} else if (isWildcardReexportStatement(stmt)) {
// Re-export in one of the following formats:
// - `__export(require('...'))`
// - `__export(<identifier>)`

View File

@ -14,7 +14,7 @@ import {Logger} from '../logging/logger';
import {BundleProgram} from '../packages/bundle_program';
import {FactoryMap, getTsHelperFnFromIdentifier, isDefined, stripExtension} from '../utils';
import {ExportDeclaration, ExportStatement, findNamespaceOfIdentifier, findRequireCallReference, isExportStatement, isReexportStatement, isRequireCall, ReexportStatement, RequireCall} from './commonjs_umd_utils';
import {ExportDeclaration, ExportStatement, findNamespaceOfIdentifier, findRequireCallReference, isExportStatement, isRequireCall, isWildcardReexportStatement, RequireCall, WildcardReexportStatement} from './commonjs_umd_utils';
import {Esm5ReflectionHost} from './esm5_host';
import {NgccClassSymbol} from './ngcc_host';
@ -101,8 +101,8 @@ export class CommonJsReflectionHost extends Esm5ReflectionHost {
if (isExportStatement(statement)) {
const exportDeclaration = this.extractCommonJsExportDeclaration(statement);
moduleMap.set(exportDeclaration.name, exportDeclaration.declaration);
} else if (isReexportStatement(statement)) {
const reexports = this.extractCommonJsReexports(statement, sourceFile);
} else if (isWildcardReexportStatement(statement)) {
const reexports = this.extractCommonJsWildcardReexports(statement, sourceFile);
for (const reexport of reexports) {
moduleMap.set(reexport.name, reexport.declaration);
}
@ -130,8 +130,8 @@ export class CommonJsReflectionHost extends Esm5ReflectionHost {
}
}
private extractCommonJsReexports(statement: ReexportStatement, containingFile: ts.SourceFile):
ExportDeclaration[] {
private extractCommonJsWildcardReexports(
statement: WildcardReexportStatement, containingFile: ts.SourceFile): ExportDeclaration[] {
const reexportArg = statement.expression.arguments[0];
const requireCall = isRequireCall(reexportArg) ?

View File

@ -39,7 +39,7 @@ export interface ExportStatement extends ts.ExpressionStatement {
* expression and can be either a `require('...')` call or an identifier (initialized via a
* `require('...')` call).
*/
export interface ReexportStatement extends ts.ExpressionStatement {
export interface WildcardReexportStatement extends ts.ExpressionStatement {
expression: ts.CallExpression;
}
@ -94,7 +94,7 @@ export function isExportStatement(stmt: ts.Statement): stmt is ExportStatement {
* - `tslib.__export(<foo>, exports)`
* - `tslib.__exportStar(<foo>, exports)`
*/
export function isReexportStatement(stmt: ts.Statement): stmt is ReexportStatement {
export function isWildcardReexportStatement(stmt: ts.Statement): stmt is WildcardReexportStatement {
// Ensure it is a call expression statement.
if (!ts.isExpressionStatement(stmt) || !ts.isCallExpression(stmt.expression)) {
return false;

View File

@ -14,7 +14,7 @@ import {Logger} from '../logging/logger';
import {BundleProgram} from '../packages/bundle_program';
import {FactoryMap, getTsHelperFnFromIdentifier, stripExtension} from '../utils';
import {ExportDeclaration, ExportStatement, findNamespaceOfIdentifier, findRequireCallReference, isExportStatement, isReexportStatement, isRequireCall, ReexportStatement} from './commonjs_umd_utils';
import {ExportDeclaration, ExportStatement, findNamespaceOfIdentifier, findRequireCallReference, isExportStatement, isRequireCall, isWildcardReexportStatement, WildcardReexportStatement} from './commonjs_umd_utils';
import {Esm5ReflectionHost} from './esm5_host';
import {stripParentheses} from './utils';
@ -92,8 +92,8 @@ export class UmdReflectionHost extends Esm5ReflectionHost {
if (isExportStatement(statement)) {
const exportDeclaration = this.extractUmdExportDeclaration(statement);
moduleMap.set(exportDeclaration.name, exportDeclaration.declaration);
} else if (isReexportStatement(statement)) {
const reexports = this.extractUmdReexports(statement, sourceFile);
} else if (isWildcardReexportStatement(statement)) {
const reexports = this.extractUmdWildcardReexports(statement, sourceFile);
for (const reexport of reexports) {
moduleMap.set(reexport.name, reexport.declaration);
}
@ -145,8 +145,8 @@ export class UmdReflectionHost extends Esm5ReflectionHost {
}
}
private extractUmdReexports(statement: ReexportStatement, containingFile: ts.SourceFile):
ExportDeclaration[] {
private extractUmdWildcardReexports(
statement: WildcardReexportStatement, containingFile: ts.SourceFile): ExportDeclaration[] {
const reexportArg = statement.expression.arguments[0];
const requireCall = isRequireCall(reexportArg) ?