Skip to content

Commit

Permalink
fix (server): Fix source map retrieval for updated builds
Browse files Browse the repository at this point in the history
This PR adds the fix submitted in Remix PR #8174. The issue is caused when the build server imports an updated server build with a ?t=timestamp suffix. This causes the source map support library to fail to load the source map.

remix-run/remix#8174
  • Loading branch information
kiliman committed Nov 30, 2023
1 parent 5397661 commit 5b9e858
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import 'dotenv/config'
import 'source-map-support/register.js'
import 'source-map-support'
import { installGlobals } from '@remix-run/node'
import chalk from 'chalk'
import closeWithGrace from 'close-with-grace'

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()

closeWithGrace(async ({ err }) => {
Expand Down

0 comments on commit 5b9e858

Please sign in to comment.