Skip to content

Commit

Permalink
Always output source maps in-memory
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Aug 5, 2015
1 parent 5031603 commit 825a4a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/typescript-node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('ts-node', function () {
it('should work with source maps', function (done) {
exec(`node ${BIN_PATH} tests/throw`, function (err) {
expect(err.message).to.contain([
`${join(__dirname, '../tests/throw.ts')}:3`,
' bar () { throw new Error(\'this is a demo\') }',
' ^',
'Error: this is a demo'
Expand All @@ -72,6 +73,7 @@ describe('ts-node', function () {
it('eval should work with source maps', function (done) {
exec(`node ${BIN_PATH} -p "import './tests/throw'"`, function (err) {
expect(err.message).to.contain([
`${join(__dirname, '../tests/throw.ts')}:3`,
' bar () { throw new Error(\'this is a demo\') }',
' ^',
'Error: this is a demo'
Expand Down
20 changes: 10 additions & 10 deletions src/typescript-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ function readConfig (fileName: string, ts: typeof TS) {
config.compilerOptions = extend({
target: 'es5'
}, config.compilerOptions, {
module: 'commonjs'
module: 'commonjs',
sourceMap: true,
inlineSourceMap: false,
inlineSources: true,
declaration: false
})

return ts.parseConfigFile(config, ts.sys, fileName)
Expand Down Expand Up @@ -96,7 +100,6 @@ export function register (opts?: Options) {

const registry = ts.createDocumentRegistry()
const service = ts.createLanguageService(serviceHost, registry)
const hasSourceMap = config.options.sourceMap

// Install source map support and read from cache.
sourceMapSupport.install({
Expand All @@ -113,15 +116,12 @@ export function register (opts?: Options) {
files[fileName] = true

const output = service.getEmitOutput(fileName)
const result = output.outputFiles[hasSourceMap ? 1 : 0].text
const result = output.outputFiles[1].text
const sourceMap = output.outputFiles[0].text
const sourceText = service.getSourceFile(fileName).text

// Cache source maps where provided.
if (hasSourceMap) {
const sourceText = service.getSourceFile(fileName).text
const sourceMapText = output.outputFiles[0].text

maps[fileName] = getSourceMap(sourceMapText, fileName, sourceText)
}
// Cache source maps in memory.
maps[fileName] = getSourceMap(sourceMap, fileName, sourceText)

// Log all diagnostics before exiting the program.
const diagnostics = getDiagnostics(service, fileName, options)
Expand Down

0 comments on commit 825a4a0

Please sign in to comment.