Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (remix-serve): convert file url to path when loading source maps #8321

Merged
merged 4 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading