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

fix(module-federation): additionalShared should check node_modules when applying to support transitive deps #28137 #28216

Merged
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
12 changes: 8 additions & 4 deletions packages/webpack/src/utils/module-federation/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,14 @@ function addStringDependencyToSharedConfig(

sharedConfig[dependency] = config;
} else {
throw new Error(
`The specified dependency "${dependency}" in the additionalShared configuration does not exist in the project graph. ` +
`Please check your additionalShared configuration and make sure you are including valid workspace projects or npm packages.`
);
const pkgJsonPath = require.resolve(`${dependency}/package.json`);
if (!pkgJsonPath) {
throw new Error(
`Could not find package ${dependency} when applying it as a shared package. Are you sure it has been installed?`
);
}
const pkgJson = readJsonFile(pkgJsonPath);
const config = getNpmPackageSharedConfig(dependency, pkgJson.version);
}
}

Expand Down