fix(js): failing e2e test due to dependency (#31676)

This PR updates our `e2e-js` test to include dependencies for all
package managers and not just pnpm.

E2E Matrix for `e2e-js` is now passing:
https://github.com/nrwl/nx/actions/runs/15786673606/job/44504580439
This commit is contained in:
Nicholas Cunningham 2025-06-20 14:28:49 -06:00 committed by GitHub
parent 1f493bf251
commit df75799ed7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -90,28 +90,34 @@ ${content}`
addImports(viteParentLib); addImports(viteParentLib);
const pm = getSelectedPackageManager(); const pm = getSelectedPackageManager();
// Add local packages as dependencies to each consumer package.json
// This is required for all package managers to satisfy dependency checks
const addDeps = (parentLib: string, includeRollupChildLib = false) => {
updateJson(`packages/${parentLib}/package.json`, (json) => {
json.dependencies ??= {};
json.dependencies[`@proj/${esbuildChildLib}`] =
pm === 'pnpm' ? 'workspace:*' : '*';
if (includeRollupChildLib) {
json.dependencies[`@proj/${rollupChildLib}`] =
pm === 'pnpm' ? 'workspace:*' : '*';
}
json.dependencies[`@proj/${swcChildLib}`] =
pm === 'pnpm' ? 'workspace:*' : '*';
json.dependencies[`@proj/${tscChildLib}`] =
pm === 'pnpm' ? 'workspace:*' : '*';
json.dependencies[`@proj/${viteChildLib}`] =
pm === 'pnpm' ? 'workspace:*' : '*';
return json;
});
};
addDeps(esbuildParentLib);
addDeps(rollupParentLib, true);
addDeps(swcParentLib);
addDeps(tscParentLib);
addDeps(viteParentLib);
if (pm === 'pnpm') { if (pm === 'pnpm') {
// for pnpm we need to add the local packages as dependencies to each consumer package.json
const addDeps = (parentLib: string, includeRollupChildLib = false) => {
updateJson(`packages/${parentLib}/package.json`, (json) => {
json.dependencies ??= {};
json.dependencies[`@proj/${esbuildChildLib}`] = 'workspace:*';
if (includeRollupChildLib) {
json.dependencies[`@proj/${rollupChildLib}`] = 'workspace:*';
}
json.dependencies[`@proj/${swcChildLib}`] = 'workspace:*';
json.dependencies[`@proj/${tscChildLib}`] = 'workspace:*';
json.dependencies[`@proj/${viteChildLib}`] = 'workspace:*';
return json;
});
};
addDeps(esbuildParentLib);
addDeps(rollupParentLib, true);
addDeps(swcParentLib);
addDeps(tscParentLib);
addDeps(viteParentLib);
const pmc = getPackageManagerCommand({ packageManager: pm }); const pmc = getPackageManagerCommand({ packageManager: pm });
runCommand(pmc.install); runCommand(pmc.install);
} }