parent
da668848c9
commit
cd29d68f3c
|
@ -9,14 +9,11 @@ import * as path from 'path';
|
|||
import * as ts from 'typescript';
|
||||
|
||||
import {MetadataCollector} from './collector';
|
||||
import {ClassMetadata, ConstructorMetadata, FunctionMetadata, MemberMetadata, MetadataArray, MetadataEntry, MetadataError, MetadataImportedSymbolReferenceExpression, MetadataMap, MetadataObject, MetadataSymbolicBinaryExpression, MetadataSymbolicCallExpression, MetadataSymbolicExpression, MetadataSymbolicIfExpression, MetadataSymbolicIndexExpression, MetadataSymbolicPrefixExpression, MetadataSymbolicReferenceExpression, MetadataSymbolicSelectExpression, MetadataSymbolicSpreadExpression, MetadataValue, MethodMetadata, ModuleMetadata, VERSION, isClassMetadata, isConstructorMetadata, isFunctionMetadata, isInterfaceMetadata, isMetadataError, isMetadataGlobalReferenceExpression, isMetadataImportedSymbolReferenceExpression, isMetadataModuleReferenceExpression, isMetadataSymbolicExpression, isMetadataSymbolicReferenceExpression, isMethodMetadata} from './schema';
|
||||
import {ClassMetadata, ConstructorMetadata, FunctionMetadata, MemberMetadata, MetadataEntry, MetadataError, MetadataImportedSymbolReferenceExpression, MetadataMap, MetadataObject, MetadataSymbolicExpression, MetadataSymbolicReferenceExpression, MetadataValue, MethodMetadata, ModuleMetadata, VERSION, isClassMetadata, isConstructorMetadata, isFunctionMetadata, isInterfaceMetadata, isMetadataError, isMetadataGlobalReferenceExpression, isMetadataImportedSymbolReferenceExpression, isMetadataModuleReferenceExpression, isMetadataSymbolicExpression, isMethodMetadata} from './schema';
|
||||
|
||||
|
||||
// The character set used to produce private names.
|
||||
const PRIVATE_NAME_CHARS = [
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
||||
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
|
||||
];
|
||||
const PRIVATE_NAME_CHARS = 'abcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
interface Symbol {
|
||||
module: string;
|
||||
|
@ -199,7 +196,6 @@ export class MetadataBundler {
|
|||
private canonicalizeSymbols(exportedSymbols: Symbol[]) {
|
||||
const symbols = Array.from(this.symbolMap.values());
|
||||
this.exported = new Set(exportedSymbols);
|
||||
;
|
||||
symbols.forEach(this.canonicalizeSymbol, this);
|
||||
}
|
||||
|
||||
|
@ -433,18 +429,15 @@ export class MetadataBundler {
|
|||
|
||||
if (isMetadataImportedSymbolReferenceExpression(value)) {
|
||||
// References to imported symbols are separated into two, references to bundled modules and
|
||||
// references to modules
|
||||
// external to the bundle. If the module reference is relative it is assuemd to be in the
|
||||
// bundle. If it is Global
|
||||
// it is assumed to be outside the bundle. References to symbols outside the bundle are left
|
||||
// unmodified. Refernces
|
||||
// to symbol inside the bundle need to be converted to a bundle import reference reachable
|
||||
// from the bundle index.
|
||||
// references to modules external to the bundle. If the module reference is relative it is
|
||||
// assumed to be in the bundle. If it is Global it is assumed to be outside the bundle.
|
||||
// References to symbols outside the bundle are left unmodified. References to symbol inside
|
||||
// the bundle need to be converted to a bundle import reference reachable from the bundle
|
||||
// index.
|
||||
|
||||
if (value.module.startsWith('.')) {
|
||||
// Reference is to a symbol defined inside the module. Convert the reference to a reference
|
||||
// to the canonical
|
||||
// symbol.
|
||||
// to the canonical symbol.
|
||||
const referencedModule = resolveModule(value.module, moduleName);
|
||||
const referencedName = value.name;
|
||||
return createReference(this.canonicalSymbolOf(referencedModule, referencedName));
|
||||
|
@ -453,7 +446,7 @@ export class MetadataBundler {
|
|||
// Value is a reference to a symbol defined outside the module.
|
||||
if (value.arguments) {
|
||||
// If a reference has arguments the arguments need to be converted.
|
||||
const result: MetadataImportedSymbolReferenceExpression = {
|
||||
return {
|
||||
__symbolic: 'reference',
|
||||
name: value.name,
|
||||
module: value.module,
|
||||
|
@ -538,10 +531,6 @@ function isPrimitive(o: any): o is boolean|string|number {
|
|||
return o === null || (typeof o !== 'function' && typeof o !== 'object');
|
||||
}
|
||||
|
||||
function isMetadataArray(o: MetadataValue): o is MetadataArray {
|
||||
return Array.isArray(o);
|
||||
}
|
||||
|
||||
function getRootExport(symbol: Symbol): Symbol {
|
||||
return symbol.reexportedAs ? getRootExport(symbol.reexportedAs) : symbol;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,6 @@ export class MetadataCollector {
|
|||
value: evaluator.evaluateNode(returnStatement.expression)
|
||||
};
|
||||
if (functionDeclaration.parameters.some(p => p.initializer != null)) {
|
||||
const defaults: MetadataValue[] = [];
|
||||
func.defaults = functionDeclaration.parameters.map(
|
||||
p => p.initializer && evaluator.evaluateNode(p.initializer));
|
||||
}
|
||||
|
@ -358,7 +357,6 @@ export class MetadataCollector {
|
|||
case ts.SyntaxKind.ClassDeclaration:
|
||||
const classDeclaration = <ts.ClassDeclaration>node;
|
||||
if (classDeclaration.name) {
|
||||
const className = classDeclaration.name.text;
|
||||
if (isExported(classDeclaration)) {
|
||||
if (!metadata) metadata = {};
|
||||
metadata[exportedName(classDeclaration)] = classMetadataOf(classDeclaration);
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
import {writeFileSync} from 'fs';
|
||||
import {normalize} from 'path';
|
||||
import * as tsickle from 'tsickle';
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import NgOptions from './options';
|
||||
|
@ -98,8 +97,7 @@ export class MetadataWriterHost extends DelegatingHost {
|
|||
}
|
||||
if (isDts) {
|
||||
// TODO: remove this early return after https://github.com/Microsoft/TypeScript/pull/8412
|
||||
// is
|
||||
// released
|
||||
// is released
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import * as ts from 'typescript';
|
||||
|
||||
import {CollectorOptions} from './collector';
|
||||
import {MetadataEntry, MetadataError, MetadataGlobalReferenceExpression, MetadataImportedSymbolReferenceExpression, MetadataSymbolicCallExpression, MetadataSymbolicReferenceExpression, MetadataValue, isMetadataError, isMetadataGlobalReferenceExpression, isMetadataImportedSymbolReferenceExpression, isMetadataModuleReferenceExpression, isMetadataSymbolicReferenceExpression, isMetadataSymbolicSpreadExpression} from './schema';
|
||||
import {MetadataEntry, MetadataError, MetadataImportedSymbolReferenceExpression, MetadataSymbolicCallExpression, MetadataValue, isMetadataError, isMetadataModuleReferenceExpression, isMetadataSymbolicReferenceExpression, isMetadataSymbolicSpreadExpression} from './schema';
|
||||
import {Symbols} from './symbols';
|
||||
|
||||
// In TypeScript 2.1 the spread element kind was renamed.
|
||||
|
@ -86,7 +86,7 @@ export function errorSymbol(
|
|||
const {line, character} =
|
||||
ts.getLineAndCharacterOfPosition(sourceFile, node.getStart(sourceFile));
|
||||
result = {__symbolic: 'error', message, line, character};
|
||||
};
|
||||
}
|
||||
}
|
||||
if (!result) {
|
||||
result = {__symbolic: 'error', message};
|
||||
|
|
|
@ -55,7 +55,7 @@ export function main(
|
|||
|
||||
let host = ts.createCompilerHost(parsed.options, true);
|
||||
|
||||
// If the comilation is a flat module index then produce the flat module index
|
||||
// If the compilation is a flat module index then produce the flat module index
|
||||
// metadata and the synthetic flat module index.
|
||||
if (ngOptions.flatModuleOutFile && !ngOptions.skipMetadataEmit) {
|
||||
const files = parsed.fileNames.filter(f => !DTS.test(f));
|
||||
|
@ -170,7 +170,7 @@ export function main(
|
|||
// CLI entry point
|
||||
if (require.main === module) {
|
||||
const args = process.argv.slice(2);
|
||||
let {options, fileNames, errors} = (ts as any).parseCommandLine(args);
|
||||
let {options, errors} = (ts as any).parseCommandLine(args);
|
||||
check(errors);
|
||||
const project = options.project || '.';
|
||||
// TODO(alexeagle): command line should be TSC-compatible, remove "CliOptions" here
|
||||
|
|
|
@ -12,8 +12,7 @@ export interface VinylFile extends Object {
|
|||
// Content of the virtual file
|
||||
contents: Buffer;
|
||||
}
|
||||
;
|
||||
|
||||
export function isVinylFile(obj: any): obj is VinylFile {
|
||||
return (typeof obj === 'object') && ('path' in obj) && ('contents' in obj);
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue