mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
fix(utils): handled undefined cjs entries
[release]
This commit is contained in:
parent
a84f31d2a9
commit
d8b84fe263
@ -3,15 +3,14 @@ export function isExternalDependency (id) {
|
||||
}
|
||||
|
||||
export function clearRequireCache (id) {
|
||||
let entry
|
||||
try {
|
||||
entry = require.cache[id]
|
||||
} catch (e) {
|
||||
const entry = getRequireCacheItem(id)
|
||||
|
||||
if (!entry) {
|
||||
delete require.cache[id]
|
||||
return
|
||||
}
|
||||
|
||||
if (!entry || isExternalDependency(id)) {
|
||||
if (isExternalDependency(id)) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -27,15 +26,14 @@ export function clearRequireCache (id) {
|
||||
}
|
||||
|
||||
export function scanRequireTree (id, files = new Set()) {
|
||||
let entry
|
||||
try {
|
||||
entry = require.cache[id]
|
||||
} catch (e) {
|
||||
const entry = getRequireCacheItem(id)
|
||||
|
||||
if (!entry) {
|
||||
files.add(id)
|
||||
return files
|
||||
}
|
||||
|
||||
if (!entry || isExternalDependency(id) || files.has(id)) {
|
||||
if (isExternalDependency(id) || files.has(id)) {
|
||||
return files
|
||||
}
|
||||
|
||||
@ -48,6 +46,13 @@ export function scanRequireTree (id, files = new Set()) {
|
||||
return files
|
||||
}
|
||||
|
||||
export function getRequireCacheItem (id) {
|
||||
try {
|
||||
return require.cache[id]
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
export function tryRequire (id) {
|
||||
try {
|
||||
return require(id)
|
||||
|
Loading…
Reference in New Issue
Block a user