From 97165828ecbcea867e927c62033002359d83a0db Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Sat, 27 Mar 2021 15:18:11 +0800 Subject: [PATCH] fix: fix types errors (#2726) --- packages/vite/src/node/plugins/importAnalysis.ts | 6 ++---- packages/vite/src/node/plugins/importAnalysisBuild.ts | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index e74dea65bb33d6..4249c5d16675cd 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -107,7 +107,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { const rewriteStart = Date.now() await init - let imports: ImportSpecifier[] = [] + let imports: readonly ImportSpecifier[] = [] try { imports = parseImports(source)[0] } catch (e) { @@ -310,10 +310,8 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { const isDynamicImport = dynamicIndex >= 0 // static import or valid string in dynamic import - const isLiteralId = !!specifier - // If resolvable, let's resolve it - if (isLiteralId) { + if (!!specifier) { // skip external / data uri if (isExternalUrl(specifier) || isDataUrl(specifier)) { continue diff --git a/packages/vite/src/node/plugins/importAnalysisBuild.ts b/packages/vite/src/node/plugins/importAnalysisBuild.ts index 15f186b1430efd..0baba266958434 100644 --- a/packages/vite/src/node/plugins/importAnalysisBuild.ts +++ b/packages/vite/src/node/plugins/importAnalysisBuild.ts @@ -102,7 +102,7 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin { await init - let imports: ImportSpecifier[] = [] + let imports: readonly ImportSpecifier[] = [] try { imports = parseImports(source)[0] } catch (e) {