fix(cjs): fix HMR issue with mongoose (#7938)

This commit is contained in:
Ahad Birang 2020-08-26 14:08:29 +04:30 committed by GitHub
parent 7cecbccabd
commit 9f05febe08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,11 +1,15 @@
import { join } from 'path'
export function isHMRCompatible (id) {
return !/[/\\]mongoose[/\\/]/.test(id)
}
export function isExternalDependency (id) {
return /[/\\]node_modules[/\\]/.test(id)
}
export function clearRequireCache (id) {
if (isExternalDependency(id)) {
if (isExternalDependency(id) && isHMRCompatible(id)) {
return
}