From 6fec6ab70e44994ac84a0a76a8017c3ef1b74ba7 Mon Sep 17 00:00:00 2001 From: bluwy Date: Thu, 28 Sep 2023 15:18:47 +0800 Subject: [PATCH] chore: add comment --- packages/vite/src/node/plugins/importAnalysis.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index 81c79c8e48ed75..43b26dce789c52 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -470,6 +470,10 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { } return } else if (templateLiteralRE.test(rawUrl)) { + // If the import has backticks but isn't transformed as a glob import + // (as there's nothing to glob), check if it's simply a plain string. + // If so, we can replace the specifier as a plain string to prevent + // an incorrect "cannot be analyzed" warning. if (!(rawUrl.includes('${') && rawUrl.includes('}'))) { specifier = rawUrl.replace(templateLiteralRE, '$1') }