UNPKG

13.1 kBSource Map (JSON)View Raw
1{"version":3,"file":"compiler_host.js","sourceRoot":"","sources":["../../../../../tools/@angular/tsc-wrapped/src/compiler_host.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;AAEH,yBAAiC;AACjC,6BAA+B;AAC/B,+BAAiC;AAGjC,yCAA8C;AAG9C,2BAAkC,CAAkB;IAClD,IAAM,IAAI,GAA6B;QACrC,mBAAmB,EAAE,cAAM,OAAA,EAAE,CAAC,GAAG,CAAC,mBAAmB,EAAE,EAA5B,CAA4B;QACvD,UAAU,EAAE,cAAM,OAAA,EAAE,CAAC,GAAG,CAAC,OAAO,EAAd,CAAc;QAChC,oBAAoB,EAAE,UAAC,CAAS,IAAK,OAAA,CAAC,EAAD,CAAC;KACvC,CAAC;IACF,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC;AAPD,8CAOC;AAED;;;GAGG;AACH,2BAA2B;AAC3B;IACE,wBAAsB,QAAyB;QAA/C,iBAAmD;QAA7B,aAAQ,GAAR,QAAQ,CAAiB;QAC/C,kBAAa,GACT,UAAC,QAAgB,EAAE,eAAgC,EAAE,OAAmC;YACpF,OAAA,KAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,CAAC;QAA/D,CAA+D,CAAC;QAExE,yBAAoB,GAAG,cAAM,OAAA,KAAI,CAAC,QAAQ,CAAC,oBAAoB,EAAE,EAApC,CAAoC,CAAC;QAClE,0BAAqB,GAAG,UAAC,OAA2B;YAChD,OAAA,KAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,OAAO,CAAC;QAA5C,CAA4C,CAAC;QACjD,0BAAqB,GAAG,cAAM,OAAA,KAAI,CAAC,QAAQ,CAAC,qBAAqB,EAAE,EAArC,CAAqC,CAAC;QACpE,cAAS,GAAyB,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC1D,wBA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,gBAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC;gBACxE,wEAAwE;gBACxE,IAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;gBAC7D,kBAAa,CAAC,YAAY,EAAE,KAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC,CAAA;QArCP,KAAI,CAAC,wBAAwB,GAAG,gBAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC/D,KAAI,CAAC,YAAY,GAAG,cAAc,CAAC,OAAO,CAAC;QAC3C,KAAI,CAAC,aAAa,GAAG,cAAc,CAAC,QAAQ,CAAC;;IAC/C,CAAC;IAmCH,yBAAC;AAAD,CAAC,AA/CD,CAAwC,cAAc,GA+CrD;AA/CY,gDAAkB","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {writeFileSync} from 'fs';\nimport {normalize} from 'path';\nimport * as ts from 'typescript';\n\nimport NgOptions from './options';\nimport {MetadataCollector} from './collector';\nimport {ModuleMetadata} from './schema';\n\nexport function formatDiagnostics(d: ts.Diagnostic[]): string {\n const host: ts.FormatDiagnosticsHost = {\n getCurrentDirectory: () => ts.sys.getCurrentDirectory(),\n getNewLine: () => ts.sys.newLine,\n getCanonicalFileName: (f: string) => f\n };\n return ts.formatDiagnostics(d, host);\n}\n\n/**\n * Implementation of CompilerHost that forwards all methods to another instance.\n * Useful for partial implementations to override only methods they care about.\n */\n// tslint:disable:semicolon\nexport abstract class DelegatingHost implements ts.CompilerHost {\n constructor(protected delegate: ts.CompilerHost) {}\n getSourceFile =\n (fileName: string, languageVersion: ts.ScriptTarget, onError?: (message: string) => void) =>\n this.delegate.getSourceFile(fileName, languageVersion, onError);\n\n getCancellationToken = () => this.delegate.getCancellationToken();\n getDefaultLibFileName = (options: ts.CompilerOptions) =>\n this.delegate.getDefaultLibFileName(options);\n getDefaultLibLocation = () => this.delegate.getDefaultLibLocation();\n writeFile: ts.WriteFileCallback = this.delegate.writeFile;\n getCurrentDirectory = () => this.delegate.getCurrentDirectory();\n getDirectories = (path: string): string[] =>\n (this.delegate as any).getDirectories?(this.delegate as any).getDirectories(path): [];\n getCanonicalFileName = (fileName: string) => this.delegate.getCanonicalFileName(fileName);\n useCaseSensitiveFileNames = () => this.delegate.useCaseSensitiveFileNames();\n getNewLine = () => this.delegate.getNewLine();\n fileExists = (fileName: string) => this.delegate.fileExists(fileName);\n readFile = (fileName: string) => this.delegate.readFile(fileName);\n trace = (s: string) => this.delegate.trace(s);\n directoryExists = (directoryName: string) => this.delegate.directoryExists(directoryName);\n}\n\nconst IGNORED_FILES = /\\.ngfactory\\.js$|\\.ngstyle\\.js$/;\nconst DTS = /\\.d\\.ts$/;\n\nexport class MetadataWriterHost extends DelegatingHost {\n private metadataCollector = new MetadataCollector({quotedNames: true});\n private metadataCollector1 = new MetadataCollector({version: 1});\n constructor(\n delegate: ts.CompilerHost, private ngOptions: NgOptions, private emitAllFiles: boolean) {\n super(delegate);\n }\n\n private writeMetadata(emitFilePath: string, sourceFile: ts.SourceFile) {\n // TODO: replace with DTS filePath when https://github.com/Microsoft/TypeScript/pull/8412 is\n // released\n if (/*DTS*/ /\\.js$/.test(emitFilePath)) {\n const path = emitFilePath.replace(/*DTS*/ /\\.js$/, '.metadata.json');\n\n // Beginning with 2.1, TypeScript transforms the source tree before emitting it.\n // We need the original, unmodified, tree which might be several levels back\n // depending on the number of transforms performed. All SourceFile's prior to 2.1\n // will appear to be the original source since they didn't include an original field.\n let collectableFile = sourceFile;\n while ((collectableFile as any).original) {\n collectableFile = (collectableFile as any).original;\n }\n\n const metadata =\n this.metadataCollector.getMetadata(collectableFile, !!this.ngOptions.strictMetadataEmit);\n const metadata1 = this.metadataCollector1.getMetadata(collectableFile, false);\n const metadatas: ModuleMetadata[] = [metadata, metadata1].filter(e => !!e);\n if (metadatas.length) {\n const metadataText = JSON.stringify(metadatas);\n writeFileSync(path, metadataText, {encoding: 'utf-8'});\n }\n }\n }\n\n writeFile: ts.WriteFileCallback =\n (fileName: string, data: string, writeByteOrderMark: boolean,\n onError?: (message: string) => void, sourceFiles?: ts.SourceFile[]) => {\n const isDts = /\\.d\\.ts$/.test(fileName);\n if (this.emitAllFiles || isDts) {\n // Let the original file be written first; this takes care of creating parent directories\n this.delegate.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);\n }\n if (isDts) {\n // TODO: remove this early return after https://github.com/Microsoft/TypeScript/pull/8412\n // is released\n return;\n }\n\n if (IGNORED_FILES.test(fileName)) {\n return;\n }\n\n if (!sourceFiles) {\n throw new Error(\n 'Metadata emit requires the sourceFiles are passed to WriteFileCallback. ' +\n 'Update to TypeScript ^1.9.0-dev');\n }\n if (sourceFiles.length > 1) {\n throw new Error('Bundled emit with --out is not supported');\n }\n if (!this.ngOptions.skipMetadataEmit && !this.ngOptions.flatModuleOutFile) {\n this.writeMetadata(fileName, sourceFiles[0]);\n }\n }\n}\n\nexport class SyntheticIndexHost extends DelegatingHost {\n private normalSyntheticIndexName: string;\n private indexContent: string;\n private indexMetadata: string;\n\n constructor(\n delegate: ts.CompilerHost,\n syntheticIndex: {name: string, content: string, metadata: string}) {\n super(delegate);\n this.normalSyntheticIndexName = normalize(syntheticIndex.name);\n this.indexContent = syntheticIndex.content;\n this.indexMetadata = syntheticIndex.metadata;\n }\n\n fileExists = (fileName: string):\n boolean => {\n return normalize(fileName) == this.normalSyntheticIndexName ||\n this.delegate.fileExists(fileName);\n }\n\n readFile =\n (fileName: string) => {\n return normalize(fileName) == this.normalSyntheticIndexName ?\n this.indexContent :\n this.delegate.readFile(fileName);\n }\n\n getSourceFile =\n (fileName: string, languageVersion: ts.ScriptTarget,\n onError?: (message: string) => void) => {\n if (normalize(fileName) == this.normalSyntheticIndexName) {\n return ts.createSourceFile(fileName, this.indexContent, languageVersion, true);\n }\n return this.delegate.getSourceFile(fileName, languageVersion, onError);\n }\n\n writeFile: ts.WriteFileCallback =\n (fileName: string, data: string, writeByteOrderMark: boolean,\n onError?: (message: string) => void, sourceFiles?: ts.SourceFile[]) => {\n this.delegate.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);\n if (fileName.match(DTS) && sourceFiles && sourceFiles.length == 1 &&\n normalize(sourceFiles[0].fileName) == this.normalSyntheticIndexName) {\n // If we are writing the synthetic index, write the metadata along side.\n const metadataName = fileName.replace(DTS, '.metadata.json');\n writeFileSync(metadataName, this.indexMetadata, 'utf8');\n }\n }\n}\n"]}
\No newline at end of file