Created
March 21, 2016 23:56
-
-
Save jkuri/bb53181a26a0d5a2e1b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const options = require(path.resolve(process.cwd(), 'src', 'tsconfig.json')).compilerOptions; | |
const tsOpts = ts.parseJsonConfigFileContent({ compilerOptions: options, files: [] }, null, null).options; | |
const tsFiles = glob.sync('**/*.ts', { | |
cwd: path.resolve(process.cwd(), 'src') | |
}); | |
const tsServiceHost = new ServiceHost(tsOpts, tsFiles, tsFiles); | |
const tsService = ts.createLanguageService(tsServiceHost, ts.createDocumentRegistry()); | |
const output = tsFiles.map(file => { | |
return tsService.getEmitOutput(file); | |
}); | |
console.log(output[0]); | |
/* | |
{ outputFiles: | |
[ { name: '../dist/app.js.map', | |
writeByteOrderMark: false, | |
text: '{"version":3,"file":"app.js","sourceRoot":"/","sources":["app.ts"],"names":[],"mappings":";;;;;;;;;;;;;YAGA,mBAAS,CAAC,cAAO,EAAE,EAAE,CAAC,CAAC"}' }, | |
{ name: '../dist/app.js', | |
writeByteOrderMark: undefined, | |
text: 'System.register([\'angular2/platform/browser\', \'./app/proj\'], function(exports_1, context_1) {\r\n "use strict";\r\n var __moduleName = context_1 && context_1.id;\r\n var browser_1, proj_1;\r\n return {\r\n setters:[\r\n function (browser_1_1) {\r\n browser_1 = browser_1_1;\r\n },\r\n function (proj_1_1) {\r\n proj_1 = proj_1_1;\r\n }],\r\n execute: function() {\r\n browser_1.bootstrap(proj_1.ProjApp, []);\r\n }\r\n }\r\n});\r\n//# sourceMappingURL=../proj/app.js.map' } ], | |
emitSkipped: false } | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you add
ServiceHost
source code too? thx :)