fix(nitro): improve externals error handling (#1188)

This commit is contained in:
Daniel Roe 2021-10-18 17:08:37 +01:00 committed by GitHub
parent 47c004ac97
commit 80883cfb8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -52,8 +52,12 @@ export function externals (opts: NodeExternalsOptions): Plugin {
// Track externals
if (opts.trace !== false) {
const resolved = await this.resolve(originalId, importer, { ...options, skipSelf: true }).then(r => r.id)
trackedExternals.add(resolved)
const resolved = await this.resolve(originalId, importer, { ...options, skipSelf: true })
if (!resolved) {
console.warn(`Could not resolve \`${originalId}\`. Have you installed it?`)
} else {
trackedExternals.add(resolved.id)
}
}
return {