-
Notifications
You must be signed in to change notification settings - Fork 523
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
Project build files are deleted when running under yarn workspaces #871
Comments
I think the core issue is we just don't know the right way to support yarn workspaces right now. /cc @gregmagolan |
Ok, this might explain the next issue I'm facing 😁
The first library compiles fine, including dependencies to external stuff from
A relative import of Edit: However I see that a relative path is added to
|
BUILD files are no longer generated in node_modules as part of the fix for #802. Does this solve you issue? |
Unfortunately, while BUILD files may not be generated, the default
Adding |
Can you explain your use case some more? Are you building targets in Also, regarding your earlier comment about the ts_library issue you're facing, you should be able to use the |
The The project is a monorepo comprising a bunch of React components. We'd ultimately like to be able to both 1) import the project to other bazel workspaces to assemble actual applications, and 2) build independently to push the npm_packages to a registry. Currently it's all set up with lerna to build and publish. There's a top level Because of the internal workspace dependencies, during I'll work on getting a smaller reproducing project set up, and also give it a test with |
Sorry for the delay, but I've finally managed to set up the reproducing project: https://github.com/Zetten/bazelbuild_rules_nodejs_issue_871 As you suggested, I tried with The example project's WORKSPACE contains equivalent config to test both install rules (un/comment accordingly), and a detailed example in the readme. The difference indeed seems to be that with a yarn workspace, the local packages are installed to (The ts_library issue was solved by |
I second this, yarn workspaces are essential for our UI developers as well. This used to work fine up until version 0.29. |
@gregmagolan I'm running into the same issue with @Zetten faces. Here is the use case we have a directory with a bunch of ts files and a ts_library that builds them all with module_name attribute. Note: we don't add the first ts_library as a dependency in package.json Strangely, when we run yarn_install it responds back with an error like so
Important Note: the ts_library targets are also specified in package.json's workspaces property. npm_install works because it has nothing to do with workspaces. |
Is there any workaround for this @Zetten @gregmagolan ? Except downgrade the version |
Generates @gregmagolan Is it valid to remove workspace specific scopes from being generated as BUILD targets - since we include them as local dependencies, not external ones FYI, @thesayyn @Zetten to test this on your own repos remove your subpackage files from: |
We already have some logic to detect symlinks, seems easy enough to detect a symlink that points into the workspace. |
I'm happy to take a stab at this, assuming that: You want to edit |
yes, that sounds right. |
@soldair Can this be merged and closed? |
I've finally found some time to give this another try, and while the change works to preserve BUILD(.bazel) files, it doesn't quite enable building with nested yarn workspaces. The use of the
This means that there's now a package overlap. As tested with my repro project, updated to rules_nodejs 0.39.0 (and bazel 1.1.0, if that has any bearing):
A crude workaround would be to completely prevent indexing local symlink directories as packages, by adding another filter condition after https://github.com/bazelbuild/rules_nodejs/blob/master/internal/npm_install/generate_build_file.ts#L476. |
On a project I'm working on we are using Yarn workspaces currently. We'd like to incrementally migrate some of the build to Bazel in parallel with the existing setup, but it's not possible because of this issue (the issue mentioned above by @Zetten). |
🚀 feature request
Relevant Rules
yarn_install
/npm_install
, tested in revision v0.31.1 and d7e4554.Description
I'm trying to add Bazel rules to an existing monorepo of npm packages, currently managed with lerna (i.e. yarn workspaces). Some of these packages have dependencies on each other, which results in symlinks inside node_modules like:
When
rules_node
comes along and generatesBUILD.bazel
files for all the contents ofnode_modules
, it follows these symlinks and flattens any config I write myself (and leaves a_bazel marker
). Not only that, but it generates broken config. Any subsequent build throws errors like:Describe the solution you'd like
Maybe I'm just doing something wrong, but I would expect the automatic generation of BUILD targets in the
managed_directories
to not touch my own workspace contents.Describe alternatives you've considered
In a crude workaround, I've added an attribute to
yarn_install
/npm_install
:excluded_scopes
, which gets passed togenerate_build_file.js
. In my case all the local modules are namespaced in a single scope, so I can easily filter this whole scope out. I can file this as a PR if the approach is useful.Another option would be to (somehow) do some dereferencing and walk back up the tree to find out if a
node_modules
package is linked to a directory in the original workspace. This may be more complex than a manual exclusion though.The text was updated successfully, but these errors were encountered: