Skip to content

Commit

Permalink
fix (templates): apply source map fix to express template
Browse files Browse the repository at this point in the history
  • Loading branch information
VHall1 committed Jan 8, 2024
1 parent 961746e commit fab00a0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions templates/express/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ import sourceMapSupport from "source-map-support";

sourceMapSupport.install({
retrieveSourceMap: function (source) {
// get source file with the `file://` prefix
const match = source.match(/^file:\/\/(.*)$/);
const match = source.startsWith("file://");
if (match) {
const filePath = url.fileURLToPath(source);
return {
url: source,
map: fs.readFileSync(`${filePath}.map`, "utf8"),
};
const sourceMapPath = `${filePath}.map`;
if (fs.existsSync(sourceMapPath)) {
return {
url: source,
map: fs.readFileSync(sourceMapPath, "utf8"),
};
}
}
return null;
},
Expand Down

0 comments on commit fab00a0

Please sign in to comment.