UNPKG

10.5 kBSource Map (JSON)View Raw
1{"version":3,"file":"path_mapped_reflector_host.js","sourceRoot":"","sources":["../../../../modules/@angular/compiler-cli/src/path_mapped_reflector_host.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;;;;;AAIH,IAAY,IAAI,WAAM,MAAM,CAAC,CAAA;AAC7B,IAAY,EAAE,WAAM,YAAY,CAAC,CAAA;AAEjC,+BAAkD,kBAAkB,CAAC,CAAA;AAGrE,IAAM,GAAG,GAAG,kCAAkC,CAAC;AAC/C,IAAM,GAAG,GAAG,UAAU,CAAC;AAEvB;;;;;;GAMG;AACH;IAA6C,2CAAa;IACxD,iCACI,OAAmB,EAAE,YAA6B,EAAE,OAA+B,EACnF,OAA8B;QAChC,kBAAM,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAED,sDAAoB,GAApB,UAAqB,QAAgB;QACnC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;YAAC,MAAM,CAAC,QAAQ,CAAC;QAC/B,yDAAyD;QACzD,GAAG,CAAC,CAAc,UAA2B,EAA3B,KAAA,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,EAA3B,cAA2B,EAA3B,IAA2B,CAAC;YAAzC,IAAM,GAAG,SAAA;YACZ,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAChC,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC5C,CAAC;SACF;QACD,MAAM,CAAC,QAAQ,CAAC;IAClB,CAAC;IAES,yCAAO,GAAjB,UAAkB,CAAS,EAAE,cAAsB;QACjD,GAAG,CAAC,CAAe,UAA6B,EAA7B,KAAA,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,EAAE,CAAC,EAA7B,cAA6B,EAA7B,IAA6B,CAAC;YAA5C,IAAM,IAAI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AC1C,IAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;oBACjD,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,SAAS,GAAG,QAAQ,CAAC;gBAClF,CAAC;YACH,CAAC;YAAC,IAAI,CAAC,CAAC;gBACN,IAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;gBAClD,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBACR,MAAM,IAAI,KAAK,CAAC,iBAAe,UAAU,6BAA0B,CAAC,CAAC;gBACvE,CAAC;gBACD,EAAE,CAAC,QAAQ,GAAG,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;gBACrD,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YAChD,CAAC;SACF;IACH,CAAC;IACH,8BAAC;AAAD,CAAC,AAjHD,CAA6C,8BAAa,GAiHzD;AAjHY,+BAAuB,0BAiHnC,CAAA","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 {AngularCompilerOptions, ModuleMetadata} from '@angular/tsc-wrapped';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\n\nimport {ReflectorHost, ReflectorHostContext} from './reflector_host';\nimport {StaticSymbol} from './static_reflector';\n\nconst EXT = /(\\.ts|\\.d\\.ts|\\.js|\\.jsx|\\.tsx)$/;\nconst DTS = /\\.d\\.ts$/;\n\n/**\n * This version of the reflector host expects that the program will be compiled\n * and executed with a \"path mapped\" directory structure, where generated files\n * are in a parallel tree with the sources, and imported using a `./` relative\n * import. This requires using TS `rootDirs` option and also teaching the module\n * loader what to do.\n */\nexport class PathMappedReflectorHost extends ReflectorHost {\n constructor(\n program: ts.Program, compilerHost: ts.CompilerHost, options: AngularCompilerOptions,\n context?: ReflectorHostContext) {\n super(program, compilerHost, options, context);\n }\n\n getCanonicalFileName(fileName: string): string {\n if (!fileName) return fileName;\n // NB: the rootDirs should have been sorted longest-first\n for (const dir of this.options.rootDirs || []) {\n if (fileName.indexOf(dir) === 0) {\n fileName = fileName.substring(dir.length);\n }\n }\n return fileName;\n }\n\n protected resolve(m: string, containingFile: string) {\n for (const root of this.options.rootDirs || ['']) {\n const rootedContainingFile = path.join(root, containingFile);\n const resolved =\n ts.resolveModuleName(m, rootedContainingFile, this.options, this.context).resolvedModule;\n if (resolved) {\n if (this.options.traceResolution) {\n console.error('resolve', m, containingFile, '=>', resolved.resolvedFileName);\n }\n return resolved.resolvedFileName;\n }\n }\n }\n\n /**\n * We want a moduleId that will appear in import statements in the generated code.\n * These need to be in a form that system.js can load, so absolute file paths don't work.\n * Relativize the paths by checking candidate prefixes of the absolute path, to see if\n * they are resolvable by the moduleResolution strategy from the CompilerHost.\n */\n getImportPath(containingFile: string, importedFile: string): string {\n importedFile = this.resolveAssetUrl(importedFile, containingFile);\n containingFile = this.resolveAssetUrl(containingFile, '');\n\n if (this.options.traceResolution) {\n console.error(\n 'getImportPath from containingFile', containingFile, 'to importedFile', importedFile);\n }\n\n // If a file does not yet exist (because we compile it later), we still need to\n // assume it exists so that the `resolve` method works!\n if (!this.context.fileExists(importedFile)) {\n if (this.options.rootDirs && this.options.rootDirs.length > 0) {\n this.context.assumeFileExists(path.join(this.options.rootDirs[0], importedFile));\n } else {\n this.context.assumeFileExists(importedFile);\n }\n }\n\n const resolvable = (candidate: string) => {\n const resolved = this.getCanonicalFileName(this.resolve(candidate, importedFile));\n return resolved && resolved.replace(EXT, '') === importedFile.replace(EXT, '');\n };\n\n const importModuleName = importedFile.replace(EXT, '');\n const parts = importModuleName.split(path.sep).filter(p => !!p);\n let foundRelativeImport: string;\n for (let index = parts.length - 1; index >= 0; index--) {\n let candidate = parts.slice(index, parts.length).join(path.sep);\n if (resolvable(candidate)) {\n return candidate;\n }\n candidate = '.' + path.sep + candidate;\n if (resolvable(candidate)) {\n foundRelativeImport = candidate;\n }\n }\n\n if (foundRelativeImport) return foundRelativeImport;\n\n // Try a relative import\n const candidate = path.relative(path.dirname(containingFile), importModuleName);\n if (resolvable(candidate)) {\n return candidate;\n }\n\n throw new Error(\n `Unable to find any resolvable import for ${importedFile} relative to ${containingFile}`);\n }\n\n getMetadataFor(filePath: string): ModuleMetadata {\n for (const root of this.options.rootDirs || []) {\n const rootedPath = path.join(root, filePath);\n if (!this.compilerHost.fileExists(rootedPath)) {\n // If the file doesn't exists then we cannot return metadata for the file.\n // This will occur if the user refernced a declared module for which no file\n // exists for the module (i.e. jQuery or angularjs).\n continue;\n }\n if (DTS.test(rootedPath)) {\n const metadataPath = rootedPath.replace(DTS, '.metadata.json');\n if (this.context.fileExists(metadataPath)) {\n const metadata = this.readMetadata(metadataPath);\n return (Array.isArray(metadata) && metadata.length == 0) ? undefined : metadata;\n }\n } else {\n const sf = this.program.getSourceFile(rootedPath);\n if (!sf) {\n throw new Error(`Source file ${rootedPath} not present in program.`);\n }\n sf.fileName = this.getCanonicalFileName(sf.fileName);\n return this.metadataCollector.getMetadata(sf);\n }\n }\n }\n}\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
\No newline at end of file