Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Downgrade esbuild so a single version is shared between sub-dependencies #1045

Merged
merged 4 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions packages/wxt/e2e/tests/npm-packages.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { test, expect } from 'vitest';
import spawn from 'nano-spawn';
import {
NpmListDependency,
NpmListProject,
} from '../../src/core/package-managers/npm';

// Tests to ensure the total size of the WXT module is as small as possible
// https://pkg-size.dev/wxt

test('Only one version of esbuild should be installed (each version is ~20mb of node_modules)', async () => {
const { stdout } = await spawn('pnpm', [
'why',
'esbuild',
'--prod',
'--json',
]);
const projects: NpmListProject[] = JSON.parse(stdout);
const esbuildVersions = new Set<string>();
iterateDependencies(projects, (name, meta) => {
if (name === 'esbuild') esbuildVersions.add(meta.version);
});

expect([...esbuildVersions]).toHaveLength(1);
});

function iterateDependencies(
projects: NpmListProject[],
cb: (name: string, meta: NpmListDependency) => void,
) {
const recurse = (dependencies: Record<string, NpmListDependency>) => {
Object.entries(dependencies).forEach(([name, meta]) => {
cb(name, meta);
if (meta.dependencies) recurse(meta.dependencies);
});
};
projects.forEach((project) => {
if (project.dependencies) recurse(project.dependencies);
});
}
2 changes: 1 addition & 1 deletion packages/wxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"defu": "^6.1.4",
"dequal": "^2.0.3",
"dotenv": "^16.4.5",
"esbuild": "^0.24.0",
"esbuild": "^0.21.5",
"fast-glob": "^3.3.2",
"filesize": "^10.1.6",
"fs-extra": "^11.2.0",
Expand Down
Loading