diff --git a/.changeset/angry-poets-accept.md b/.changeset/angry-poets-accept.md new file mode 100644 index 00000000000..0454cf765d6 --- /dev/null +++ b/.changeset/angry-poets-accept.md @@ -0,0 +1,5 @@ +--- +"@remix-run/serve": patch +--- + +Use node `fileURLToPath` to convert source map URL to path diff --git a/contributors.yml b/contributors.yml index e3794c92761..14b80999999 100644 --- a/contributors.yml +++ b/contributors.yml @@ -623,3 +623,4 @@ - timkraut - alexanderson1993 - signed +- VHall1 diff --git a/packages/remix-serve/cli.ts b/packages/remix-serve/cli.ts index 079bad13d61..d741647d0e7 100644 --- a/packages/remix-serve/cli.ts +++ b/packages/remix-serve/cli.ts @@ -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; diff --git a/templates/express/server.js b/templates/express/server.js index b66f6daf084..0533f94dc28 100644 --- a/templates/express/server.js +++ b/templates/express/server.js @@ -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;