Skip to content

Commit ebf82ca

Browse files
committed
fix: add comment for url filter logic
1 parent 0413ff8 commit ebf82ca

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

packages/build/vite-config/src/localCdnFile/copyBundleDeps.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export function copyBundleDeps({
5353
}) {
5454
const cdnFiles = extraBundleCdnLink(bundleFile, originCdnPrefix)
5555
.map((url) => getCdnPathNpmInfoForSingleFile(url, originCdnPrefix, base, dir, false, bundleTempDir))
56+
// 比如 url 前缀跟 originCdnPrefix 不匹配,或者 url 格式不正确 的场景有可能会导致匹配失败
57+
// 匹配失败时,会返回 null,需要过滤掉
5658
.filter(Boolean)
5759

5860
const { packages: packageNeedToInstall, files } = getPackageNeedToInstallAndFilesUsingSameVersion(cdnFiles)

packages/build/vite-config/src/localCdnFile/copyImportMap.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ export const copyLocalImportMap = ({
2626
}
2727
return getCdnPathNpmInfoForSingleFile(libPath, originCdnPrefix, base, dir, false, bundleTempDir)
2828
})
29+
// 比如 url 前缀跟 originCdnPrefix 不匹配,或者 url 格式不正确 的场景有可能会导致匹配失败
30+
// 匹配失败时,会返回 null,需要过滤掉
2931
.filter(Boolean)
3032
const styleFiles = styleUrls
3133
.filter((styleUrl) => styleUrl.startsWith(originCdnPrefix))
3234
.map((url) => getCdnPathNpmInfoForSingleFile(url, originCdnPrefix, base, dir, false), bundleTempDir)
35+
// 比如 url 前缀跟 originCdnPrefix 不匹配,或者 url 格式不正确 的场景有可能会导致匹配失败
36+
// 匹配失败时,会返回 null,需要过滤掉
3337
.filter(Boolean)
3438

3539
const { packages: packageNeedToInstall, files } = getPackageNeedToInstallAndFilesUsingSameVersion(

0 commit comments

Comments
 (0)