perf: optimize the diffPreferences logic and adjust the unit test (#4130)

This commit is contained in:
Vben
2024-08-12 21:05:01 +08:00
committed by GitHub
parent 3f9ce63868
commit 7b46780af7
11 changed files with 177 additions and 99 deletions

View File

@@ -80,7 +80,7 @@ async function viteImportMapPlugin(
const firstLayerKeys = Object.keys(scopes);
const inputMapScopes: string[] = [];
firstLayerKeys.forEach((key) => {
inputMapScopes.push(...Object.keys(scopes[key]));
inputMapScopes.push(...Object.keys(scopes[key] || {}));
});
const inputMapImports = Object.keys(imports);
@@ -160,7 +160,10 @@ async function viteImportMapPlugin(
options.defaultProvider || DEFAULT_PROVIDER,
);
const resultHtml = await injectShimsToHtml(html, esModuleShimsSrc);
const resultHtml = await injectShimsToHtml(
html,
esModuleShimsSrc || '',
);
html = await minify(resultHtml || html, {
collapseWhitespace: true,
minifyCSS: true,

View File

@@ -16,8 +16,8 @@ function resolvePackageVersion(
async function resolveMonorepoDependencies() {
const { packages } = await getPackages();
const resultDevDependencies: Record<string, string> = {};
const resultDependencies: Record<string, string> = {};
const resultDevDependencies: Record<string, string | undefined> = {};
const resultDependencies: Record<string, string | undefined> = {};
const pkgsMeta: Record<string, string> = {};
for (const { packageJson } of packages) {