Skip to content

Commit

Permalink
fix: server wrong import build directory
Browse files Browse the repository at this point in the history
  • Loading branch information
riipandi committed Sep 10, 2024
1 parent 20454cd commit 5cb41f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ app.all(
'*',
process.env.NODE_ENV === 'development'
? async (req, res, next) => {
await purgeRequireCache()
await purgeRequireCache(BUILD_DIR)
// `remix build` and `remix dev` output files to a build directory,
// you need to pass that build to the request handler.
const { default: build } = await import(BUILD_DIR)
Expand Down
4 changes: 2 additions & 2 deletions server/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function getLocalIpAddress() {
.find((ip) => ip?.family === 'IPv4' && !ip.internal)?.address
}

export async function purgeRequireCache() {
export async function purgeRequireCache(buildDir) {
// purge require cache on requests for "server side HMR" this won't let
// you have in-memory objects between requests in development,
// alternatively you can set up nodemon/pm2-dev to restart the server on
Expand All @@ -88,7 +88,7 @@ export async function purgeRequireCache() {
const require = createRequire(import.meta.url)

for (const key of Object.keys(require.cache)) {
if (key.startsWith(BUILD_DIR)) {
if (key.startsWith(buildDir)) {
delete require.cache[key]
}
}
Expand Down

0 comments on commit 5cb41f2

Please sign in to comment.