Skip to content

Commit

Permalink
fix: prefer using native sourcemap support (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey authored Jan 12, 2022
1 parent ff94025 commit e414937
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,31 @@ import { transformSync, TransformOptions } from 'esbuild'
import { addHook } from 'pirates'
import fs from 'fs'
import module from 'module'
import process from 'process'
import { getOptions, inferPackageFormat } from './options'
import { removeNodePrefix } from './utils'
import { registerTsconfigPaths } from './tsconfig-paths'

const map: { [file: string]: string | RawSourceMap } = {}

function installSourceMapSupport() {
sourceMapSupport.install({
handleUncaughtExceptions: false,
environment: 'node',
retrieveSourceMap(file) {
if (map[file]) {
return {
url: file,
map: map[file],
if ((process as any).setSourceMapsEnabled) {
(process as any).setSourceMapsEnabled(true);
} else {
sourceMapSupport.install({
handleUncaughtExceptions: false,
environment: 'node',
retrieveSourceMap(file) {
if (map[file]) {
return {
url: file,
map: map[file],
}
}
}
return null
},
})
return null
},
})
}
}

type COMPILE = (
Expand Down

0 comments on commit e414937

Please sign in to comment.