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
fix(cjs): fix HMR issue with mongoose #7938
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #7938 +/- ##
==========================================
- Coverage 68.92% 68.91% -0.02%
==========================================
Files 91 91
Lines 3846 3847 +1
Branches 1041 1042 +1
==========================================
Hits 2651 2651
Misses 971 971
- Partials 224 225 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
packages/utils/src/cjs.js
Outdated
@@ -1,11 +1,15 @@ | |||
import { join } from 'path' | |||
|
|||
export function isHMRCompatible (id) { | |||
return !/[/\\]mongoose[/\\/](lib[/\\/])?index.js/.test(id) |
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.
Why not marking entire mongoose dep as incompatible? A regex matching node_modules/mongoose
as a part of id
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.
mongoose has lots of files and it does not bundle them. clearing entire mongose deps causes Maximum call stack size exceeded. (Honestly, I don't understand why)
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.
Do you have a repo to quickly check? Maybe it is a nuxt HMR bug
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.
I'll have one, let me push it to github
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.
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.
Can we create a nuxt module for mongoouse and clear cache via watchers
or modules:before
hook ?
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.
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.
@clarkdo Seems nice idea. Also there is an alternative way i used once to use unload method.
Since it is really minor case (serverMiddleware + HMR + mongoose) but not uncommon setup, it may worth excluding mongoose by default. Nuxt 3 will isolate functions anyway so we won't have such issues for HMR.
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.
Types of changes
Description
Introduce
isHMRCompatible
function to detect clear incompatible modules cache.As we know
mongoose
is incompatible and clearingmongoose/index.js
andmongoose/lib/index.js
makes it work.close #7917
Checklist: