Skip to content

Commit

Permalink
fix (remix-serve): convert file url to path when loading source maps (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
VHall1 authored Dec 18, 2023
1 parent 9edcf88 commit 837d843
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-poets-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/serve": patch
---

Use node `fileURLToPath` to convert source map URL to path
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -623,3 +623,4 @@
- timkraut
- alexanderson1993
- signed
- VHall1
7 changes: 4 additions & 3 deletions packages/remix-serve/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ process.env.NODE_ENV = process.env.NODE_ENV ?? "production";

sourceMapSupport.install({
retrieveSourceMap: function (source) {
// get source file without the `file://` prefix or `?t=...` suffix
let match = source.match(/^file:\/\/(.*)\?t=[.\d]+$/);
// get source file with the `file://` prefix
let match = source.match(/^file:\/\/(.*)$/);
if (match) {
let filePath = url.fileURLToPath(source);
return {
url: source,
map: fs.readFileSync(`${match[1]}.map`, "utf8"),
map: fs.readFileSync(`${filePath}.map`, "utf8"),
};
}
return null;
Expand Down
7 changes: 4 additions & 3 deletions templates/express/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ 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]+$/);
// get source file with the `file://` prefix
const match = source.match(/^file:\/\/(.*)$/);
if (match) {
const filePath = url.fileURLToPath(source);
return {
url: source,
map: fs.readFileSync(`${match[1]}.map`, "utf8"),
map: fs.readFileSync(`${filePath}.map`, "utf8"),
};
}
return null;
Expand Down

0 comments on commit 837d843

Please sign in to comment.