From bd71e434d9b077fd4a2d46263b8b1a90b2fb0e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=A3=E4=BA=9B=E8=8A=B1=E5=84=BF?= <1781554387@qq.com> Date: Tue, 10 Dec 2019 00:06:02 +0800 Subject: [PATCH] feat: remove unnecessary check in moduleResolver.ts (#2068) --- .../shared-utils/src/moduleResolver.ts | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/packages/@vuepress/shared-utils/src/moduleResolver.ts b/packages/@vuepress/shared-utils/src/moduleResolver.ts index 7ae69cfb98..cf38380fe7 100644 --- a/packages/@vuepress/shared-utils/src/moduleResolver.ts +++ b/packages/@vuepress/shared-utils/src/moduleResolver.ts @@ -212,19 +212,17 @@ class ModuleResolver { if (req.startsWith('@')) { const pkg = resolveScopePackage(req) - if (pkg) { - // special handling for default org. - if (this.org && pkg.org === this.org) { - shortcut = pkg.name.startsWith(`${this.type}-`) - ? pkg.name.slice(this.typePrefixLength) - : pkg.name - name = `${this.scopePrefix}${shortcut}` - } else { - shortcut = this.getShortcut(pkg.name) - name = `@${pkg.org}/${this.nonScopePrefix}${shortcut}` - } - shortcut = `@${pkg.org}/${shortcut}` + // special handling for default org. + if (this.org && pkg.org === this.org) { + shortcut = pkg.name.startsWith(`${this.type}-`) + ? pkg.name.slice(this.typePrefixLength) + : pkg.name + name = `${this.scopePrefix}${shortcut}` + } else { + shortcut = this.getShortcut(pkg.name) + name = `@${pkg.org}/${this.nonScopePrefix}${shortcut}` } + shortcut = `@${pkg.org}/${shortcut}` } else { shortcut = this.getShortcut(req) name = `${this.nonScopePrefix}${shortcut}`