@angular/tsc-wrapped
Advanced tools
Comparing version 5.0.0-beta.6 to 5.0.0-beta.7
{ | ||
"name": "@angular/tsc-wrapped", | ||
"version": "5.0.0-beta.6", | ||
"version": "5.0.0-beta.7", | ||
"description": "Wraps the tsc CLI, allowing extensions.", | ||
@@ -14,7 +14,7 @@ "homepage": "https://github.com/angular/angular/blob/master/packages/tsc-wrapped", | ||
"dependencies": { | ||
"tsickle": "^0.23.5" | ||
"tsickle": "^0.24.0" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^2.1.5" | ||
"typescript": "^2.4.2" | ||
} | ||
} |
@@ -188,5 +188,7 @@ "use strict"; | ||
exportedSymbols.forEach(function (symbol) { return _this.convertSymbol(symbol); }); | ||
var symbolsMap = new Map(); | ||
Array.from(this.symbolMap.values()).forEach(function (symbol) { | ||
if (symbol.referenced && !symbol.reexport) { | ||
var name_3 = symbol.name; | ||
var declaredName = symbol.declaration.name; | ||
if (symbol.isPrivate && !symbol.privateName) { | ||
@@ -196,5 +198,28 @@ name_3 = newPrivateName(); | ||
} | ||
if (symbolsMap.has(declaredName)) { | ||
var names = symbolsMap.get(declaredName); | ||
names.push(name_3); | ||
} | ||
else { | ||
symbolsMap.set(declaredName, [name_3]); | ||
} | ||
result[name_3] = symbol.value; | ||
} | ||
}); | ||
// check for duplicated entries | ||
symbolsMap.forEach(function (names, declaredName) { | ||
if (names.length > 1) { | ||
// prefer the export that uses the declared name (if any) | ||
var reference_1 = names.indexOf(declaredName); | ||
if (reference_1 === -1) { | ||
reference_1 = 0; | ||
} | ||
// keep one entry and replace the others by references | ||
names.forEach(function (name, i) { | ||
if (i !== reference_1) { | ||
result[name] = { __symbolic: 'reference', name: names[reference_1] }; | ||
} | ||
}); | ||
} | ||
}); | ||
return result; | ||
@@ -201,0 +226,0 @@ }; |
@@ -35,3 +35,3 @@ /** | ||
private recordExport; | ||
constructor(symbols: Symbols, nodeMap: Map<MetadataEntry, ts.Node>, options?: CollectorOptions, recordExport?: (name: string, value: MetadataValue) => void); | ||
constructor(symbols: Symbols, nodeMap: Map<MetadataEntry, ts.Node>, options?: CollectorOptions, recordExport?: ((name: string, value: MetadataValue) => void) | undefined); | ||
nameOf(node: ts.Node | undefined): string | MetadataError; | ||
@@ -38,0 +38,0 @@ /** |
@@ -48,2 +48,5 @@ "use strict"; | ||
var host_1 = ts.createCompilerHost(parsed_1.options, true); | ||
// Make sure we do not `host.realpath()` from TS as we do not want to resolve symlinks. | ||
// https://github.com/Microsoft/TypeScript/issues/9552 | ||
host_1.realpath = function (fileName) { return fileName; }; | ||
// If the compilation is a flat module index then produce the flat module index | ||
@@ -59,4 +62,3 @@ // metadata and the synthetic flat module index. | ||
} | ||
var tsickleCompilerHostOptions = { googmodule: false, untyped: true, convertIndexImportShorthand: false }; | ||
var tsickleHost = { | ||
var tsickleHost_1 = { | ||
shouldSkipTsickleProcessing: function (fileName) { return /\.d\.ts$/.test(fileName); }, | ||
@@ -66,5 +68,9 @@ pathToModuleName: function (context, importPath) { return ''; }, | ||
fileNameToModuleId: function (fileName) { return fileName; }, | ||
googmodule: false, | ||
untyped: true, | ||
convertIndexImportShorthand: false, | ||
transformDecorators: ngOptions_1.annotationsAs !== 'decorators', | ||
transformTypesToClosure: ngOptions_1.annotateForClosureCompiler, | ||
}; | ||
var tsickleCompilerHost_1 = new tsickle.TsickleCompilerHost(host_1, ngOptions_1, tsickleCompilerHostOptions, tsickleHost); | ||
var program_1 = createProgram_1(tsickleCompilerHost_1); | ||
var program_1 = createProgram_1(host_1); | ||
var errors = program_1.getOptionsDiagnostics(); | ||
@@ -84,41 +90,14 @@ tsc_1.check(errors); | ||
} | ||
var definitionsHost = tsickleCompilerHost_1; | ||
if (!ngOptions_1.skipMetadataEmit) { | ||
// if tsickle is not not used for emitting, but we do use the MetadataWriterHost, | ||
// it also needs to emit the js files. | ||
var emitJsFiles = ngOptions_1.annotationsAs === 'decorators' && !ngOptions_1.annotateForClosureCompiler; | ||
definitionsHost = new compiler_host_1.MetadataWriterHost(tsickleCompilerHost_1, ngOptions_1, emitJsFiles); | ||
host_1 = new compiler_host_1.MetadataWriterHost(host_1, ngOptions_1, true); | ||
} | ||
// Create a new program since codegen files were created after making the old program | ||
var programWithCodegen = createProgram_1(definitionsHost, program_1); | ||
var programWithCodegen = createProgram_1(host_1, program_1); | ||
tsc_1.tsc.typeCheck(host_1, programWithCodegen); | ||
var programForJsEmit = programWithCodegen; | ||
if (ngOptions_1.annotationsAs !== 'decorators') { | ||
if (diagnostics_1) | ||
console.time('NG downlevel'); | ||
tsickleCompilerHost_1.reconfigureForRun(programForJsEmit, tsickle.Pass.DECORATOR_DOWNLEVEL); | ||
// A program can be re-used only once; save the programWithCodegen to be reused by | ||
// metadataWriter | ||
programForJsEmit = createProgram_1(tsickleCompilerHost_1); | ||
tsc_1.check(tsickleCompilerHost_1.diagnostics); | ||
if (diagnostics_1) | ||
console.timeEnd('NG downlevel'); | ||
} | ||
if (ngOptions_1.annotateForClosureCompiler) { | ||
if (diagnostics_1) | ||
console.time('NG JSDoc'); | ||
tsickleCompilerHost_1.reconfigureForRun(programForJsEmit, tsickle.Pass.CLOSURIZE); | ||
programForJsEmit = createProgram_1(tsickleCompilerHost_1); | ||
tsc_1.check(tsickleCompilerHost_1.diagnostics); | ||
if (diagnostics_1) | ||
console.timeEnd('NG JSDoc'); | ||
} | ||
// Emit *.js and *.js.map | ||
tsc_1.tsc.emit(programForJsEmit); | ||
// Emit *.d.ts and maybe *.metadata.json | ||
// Not in the same emit pass with above, because tsickle erases | ||
// decorators which we want to read or document. | ||
// Do this emit second since TypeScript will create missing directories for us | ||
// in the standard emit. | ||
tsc_1.tsc.emit(programWithCodegen); | ||
if (diagnostics_1) | ||
console.time('Emit'); | ||
var emitDiags = tsickle.emitWithTsickle(programWithCodegen, tsickleHost_1, host_1, ngOptions_1).diagnostics; | ||
if (diagnostics_1) | ||
console.timeEnd('Emit'); | ||
tsc_1.check(emitDiags); | ||
if (diagnostics_1) { | ||
@@ -125,0 +104,0 @@ ts.performance.forEachMeasure(function (name, duration) { console.error("TS " + name + ": " + duration + "ms"); }); |
@@ -82,4 +82,6 @@ "use strict"; | ||
res += ' at ' + d.file.fileName + ':'; | ||
var _a = d.file.getLineAndCharacterOfPosition(d.start), line = _a.line, character = _a.character; | ||
res += (line + 1) + ':' + (character + 1) + ':'; | ||
if (d.start !== undefined) { | ||
var _a = d.file.getLineAndCharacterOfPosition(d.start), line = _a.line, character = _a.character; | ||
res += (line + 1) + ':' + (character + 1) + ':'; | ||
} | ||
} | ||
@@ -86,0 +88,0 @@ res += ' ' + ts.flattenDiagnosticMessageText(d.messageText, '\n'); |
@@ -124,2 +124,19 @@ "use strict"; | ||
}); | ||
it('should be able to de-duplicate symbols of re-exported modules', function () { | ||
var host = new MockStringBundlerHost('/', { | ||
'public-api.ts': "\n export {A as A2, A, B as B1, B as B2} from './src/core';\n ", | ||
'src': { | ||
'core.ts': "\n export class A {}\n export class B {}\n ", | ||
} | ||
}); | ||
var bundler = new bundler_1.MetadataBundler('/public-api', undefined, host); | ||
var result = bundler.getMetadataBundle(); | ||
var _a = result.metadata.metadata, A = _a.A, A2 = _a.A2, B1 = _a.B1, B2 = _a.B2; | ||
expect(A.__symbolic).toEqual('class'); | ||
expect(A2.__symbolic).toEqual('reference'); | ||
expect(A2.name).toEqual('A'); | ||
expect(B1.__symbolic).toEqual('class'); | ||
expect(B2.__symbolic).toEqual('reference'); | ||
expect(B2.name).toEqual('B1'); | ||
}); | ||
}); | ||
@@ -126,0 +143,0 @@ var MockStringBundlerHost = (function () { |
@@ -43,3 +43,3 @@ "use strict"; | ||
// Expand `export *` and fix index import | ||
expect(out).toContain("export { A, B } from './dep'"); | ||
expect(out).toContain("export { A, B } from \"./dep\""); | ||
// Annotated for Closure compiler | ||
@@ -79,3 +79,3 @@ expect(out).toContain('* @param {?} x'); | ||
// Expand `export *` and fix index import | ||
expect(out).toContain("export { A, B } from './dep'"); | ||
expect(out).toContain("export { A, B } from \"./dep\""); | ||
// Annotated for Closure compiler | ||
@@ -169,3 +169,3 @@ expect(out).toContain('* @param {?} x'); | ||
var out = readOut('js.map'); | ||
expect(out).toContain('"sources":["other_test.ts","../test.ts"]'); | ||
expect(out).toContain('"sources":["other_test.ts"]'); | ||
done(); | ||
@@ -186,3 +186,3 @@ }) | ||
var out = readOut('js.map'); | ||
expect(out).toContain('"sources":["other_test.ts","../test.ts"]'); | ||
expect(out).toContain('"sources":["other_test.ts"]'); | ||
done(); | ||
@@ -197,3 +197,3 @@ }) | ||
var fileOutput = readOut('js'); | ||
expect(fileOutput).toContain("export { A, B } from './dep'"); | ||
expect(fileOutput).toContain("export { A, B } from \"./dep\""); | ||
done(); | ||
@@ -200,0 +200,0 @@ }) |
@@ -80,3 +80,3 @@ "use strict"; | ||
case ts.SyntaxKind.VariableDeclarationList: | ||
return ts.forEachChild(node, visit); | ||
return !!ts.forEachChild(node, visit); | ||
case ts.SyntaxKind.VariableDeclaration: | ||
@@ -83,0 +83,0 @@ var variableDeclaration = node; |
@@ -15,2 +15,3 @@ import * as ts from 'typescript'; | ||
getScriptSnapshot(fileName: string): ts.IScriptSnapshot | undefined; | ||
fileExists(fileName: string): boolean; | ||
getCurrentDirectory(): string; | ||
@@ -43,3 +44,3 @@ getDefaultLibFileName(options: ts.CompilerOptions): string; | ||
getLastToken(sourceFile?: ts.SourceFile): ts.Node; | ||
forEachChild<T>(cbNode: (node: ts.Node) => T, cbNodeArray?: (nodes: ts.Node[]) => T): T; | ||
forEachChild<T>(cbNode: (node: ts.Node) => T | undefined, cbNodeArray?: (nodes: ts.NodeArray<ts.Node>) => T | undefined): T | undefined; | ||
} | ||
@@ -56,2 +57,3 @@ export declare class MockIdentifier extends MockNode implements ts.Identifier { | ||
_expressionBrand: any; | ||
_updateExpressionBrand: any; | ||
constructor(name: string, kind?: ts.SyntaxKind.Identifier, flags?: ts.NodeFlags, pos?: number, end?: number); | ||
@@ -80,3 +82,3 @@ } | ||
export declare function expectValidSources(service: ts.LanguageService, program: ts.Program): void; | ||
export declare function allChildren<T>(node: ts.Node, cb: (node: ts.Node) => T): T; | ||
export declare function allChildren<T>(node: ts.Node, cb: (node: ts.Node) => T | undefined): T | undefined; | ||
export declare function findClass(sourceFile: ts.SourceFile, name: string): ts.ClassDeclaration | undefined; | ||
@@ -83,0 +85,0 @@ export declare function findVar(sourceFile: ts.SourceFile, name: string): ts.VariableDeclaration | undefined; |
@@ -43,2 +43,3 @@ "use strict"; | ||
}; | ||
Host.prototype.fileExists = function (fileName) { return this.getFileContent(fileName) != null; }; | ||
Host.prototype.getCurrentDirectory = function () { return '/'; }; | ||
@@ -110,3 +111,3 @@ Host.prototype.getDefaultLibFileName = function (options) { return 'lib.d.ts'; }; | ||
MockNode.prototype.forEachChild = function (cbNode, cbNodeArray) { | ||
return null; | ||
return undefined; | ||
}; | ||
@@ -173,5 +174,7 @@ return MockNode; | ||
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); | ||
var _a = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start), line = _a.line, character = _a.character; | ||
// tslint:disable-next-line:no-console | ||
console.log(diagnostic.file.fileName + " (" + (line + 1) + "," + (character + 1) + "): " + message); | ||
if (diagnostic.file && diagnostic.start) { | ||
var _a = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start), line = _a.line, character = _a.character; | ||
// tslint:disable-next-line:no-console | ||
console.log(diagnostic.file.fileName + " (" + (line + 1) + "," + (character + 1) + "): " + message); | ||
} | ||
} | ||
@@ -191,9 +194,3 @@ expect(diagnostics.length).toBe(0); | ||
function allChildren(node, cb) { | ||
return ts.forEachChild(node, function (child) { | ||
var result = cb(node); | ||
if (result) { | ||
return result; | ||
} | ||
return allChildren(child, cb); | ||
}); | ||
return ts.forEachChild(node, function (child) { return cb(node) || allChildren(child, cb); }); | ||
} | ||
@@ -200,0 +197,0 @@ exports.allChildren = allChildren; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
692927
5454
+ Addedtsickle@0.24.1(transitive)
+ Addedtypescript@2.4.2(transitive)
- Removedtsickle@0.23.6(transitive)
- Removedtypescript@2.3.4(transitive)
Updatedtsickle@^0.24.0