-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat(nodejs): support yarn workspaces #4664
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments, @nikpivkin please check them out.
LGTM. |
@nikpivkin can you resolve conflicts, please? |
var pkgs []packagejson.Package | ||
|
||
required := func(path string, _ fs.DirEntry) bool { | ||
return filepath.Base(path) == types.NpmPkg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is node_modules
created? Only root?
- monorepo
- package.json
- node_modules <- only root?
- c
- package.json
- node_modules <- ?
- packages
- package1
- package.json
- node_modules <- ?
- package2
- package.json
- node_modules <- ?
- package1
Should we skip package.json
under node_modules
just in case?
return filepath.Base(path) == types.NpmPkg | |
// Skip package.json files under node_modules | |
if slices.Contains(strings.Split(path, "/"), "node_modules") { | |
return false | |
} | |
return filepath.Base(path) == types.NpmPkg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node_modules
is created only at the root
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is ok if you're sure irrelevant package.json files must not be present in workspace projects. Since we use WalkDir
, all package.json files will be parsed under the workspace paths. That is my concern.
if err := fsutils.WalkDir(fsys, match, required, walkDirFunc); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can extract the names of all the packages of the monorepository from yarn.lock
and then check them so as not to capture an extra package.json. But as far as I know, at the moment go-dep-parser
does not include local packages from workspaces in the list of dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I might be too concerned. If we see any issue, we can fix it.
* feat(nodejs): add the workspaces field to the package * fix go.mod * update go.mod * compare workspaces by length
Description
When using workspaces, yarn creates yarn.lock only in the root of the monorepository. And since the
package.json
of the monorepository does not contain information about dependencies in workspaces, they are skipped. So we have to get all the dependencies from the package.json of workspaces.go-dep-parser refers to this commit.
Related issues
Related PRs
Checklist