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

Add support for scoped packages within monorepos #56

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

sfc-gh-jlai
Copy link
Contributor

This change fixes how NPM dependencies are determined within a monorepo. At the moment, a scoped package will fail to be associated with the correct package when that dependency is not defined at the root of the workspace.

The reason for this is within the isNpmDependency method, we would interrogate the package name by splitting the package on /, and evaluate only the first slice. This is deal for packages like lodash which export multiple subpackages(?), however, this is not ideal for scoped packages (such as @emotion/react), as there is no @emotion package defined in package.json.

This behavior would implicitly work for workspaces where the dependency was defined at the a root package.json, since the isNpmPackage would fall through to its default return, which wouldn't include the npmLabel (the package name). However, this doesn't work in typical monorepos where dependencies are defined in projects further up from root.

The solution introduced is straightforward, to simply evaluate the original import statement if the evaluation of the first slice has fallen through. We perform this for both dependencies and devDependencies.

@sfc-gh-jlai
Copy link
Contributor Author

@ewianda Pinging on this one

@ewianda ewianda merged commit 6542264 into benchsci:main Apr 23, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants