-
Notifications
You must be signed in to change notification settings - Fork 40
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
Implement server-side code hot-swapping on file change #1225
Conversation
2f004ed
to
10b49be
Compare
req.user = null | ||
next() | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right this comment can probably be removed since it's pretty old and we actually benefit from not sharing req.user because it keeps our API stateless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, gotta fix this
) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this! Very clear and thoughtful error handling
10b49be
to
dd2e092
Compare
// Enable server-side code hot-swapping on change | ||
app.use('/api', reloadAndMount(path.resolve(__dirname, 'api'), { | ||
mountPoint: '/api' | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
c352c05
to
d7e040e
Compare
@@ -50,3 +61,10 @@ artsyXapp.on('error', (error) => { | |||
console.warn(error) | |||
process.exit(1) | |||
}) | |||
|
|||
const invalidateUserMiddleware = (app) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This is 🔥 |
This PR sets up code hot-swapping on the server without a full restart (but still requiring a refresh of the browser window). Crazy-fast development speed!
Overview of process:
reloadable
is called with a path to an app (client
,api
, etc) as well as a callback function that is executed whenever files with that appPath changerequire
cachedelete require.cache[id]
Example: