Skip to content

Commit

Permalink
chore: apply patch from netlify/cli#3450
Browse files Browse the repository at this point in the history
Signed-off-by: Logan McAnsh <logan@mcan.sh>
  • Loading branch information
mcansh committed Oct 5, 2021
1 parent de366b4 commit c807cc1
Show file tree
Hide file tree
Showing 4 changed files with 44,891 additions and 4,113 deletions.
27 changes: 1 addition & 26 deletions netlify/functions/server/server.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
const { createRequestHandler } = require("@remix-run/netlify");
const path = require("path");

const BUILD_DIR = path.join(process.cwd(), "netlify");

function purgeRequireCache() {
// purge require cache on requests for "server side HMR" this won't let
// you have in-memory objects between requests in development,
// netlify typically does this for you, but we've found it to be hit or
// miss and some times requires you to refresh the page after it auto reloads
// or even have to restart your server
for (let key in require.cache) {
if (key.startsWith(BUILD_DIR)) {
delete require.cache[key];
}
}
}

exports.handler =
process.env.NODE_ENV === "production"
? createRequestHandler({ build: require("./build") })
: (event, context) => {
purgeRequireCache();
return createRequestHandler({ build: require("./build") })(
event,
context
);
};
exports.handler = createRequestHandler({ build: require("./build") });
Loading

0 comments on commit c807cc1

Please sign in to comment.