diff --git a/index.js b/index.js index de483fd8..2c265c68 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,23 @@ import 'dotenv/config' -import 'source-map-support/register.js' +import * as fs from 'fs' import { installGlobals } from '@remix-run/node' import chalk from 'chalk' import closeWithGrace from 'close-with-grace' +import sourceMapSupport from 'source-map-support' + +sourceMapSupport.install({ + retrieveSourceMap: function (source) { + // get source file without the `file://` prefix or `?t=...` suffix + const match = source.match(/^file:\/\/(.*)\?t=[.\d]+$/) + if (match) { + return { + url: source, + map: fs.readFileSync(`${match[1]}.map`, 'utf8'), + } + } + return null + }, +}) installGlobals()