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

Consider loading all public starlark API from @npm workspace #1149

Closed
alexeagle opened this issue Sep 18, 2019 · 4 comments
Closed

Consider loading all public starlark API from @npm workspace #1149

alexeagle opened this issue Sep 18, 2019 · 4 comments
Assignees
Labels
cleanup Tech debt, resolving it improves our own velocity
Milestone

Comments

@alexeagle
Copy link
Collaborator

In the https://hackmd.angular.io/f8OBi9KMTNKButSWsh1gCA?view proposal we suggest loading npm package rules for simple packages from
eg @npm//less:index.bzl

This raises the question, why not be consistent with the non-simple case? Maybe ts_library should be loaded from @npm//@bazel/typescript:index.bzl

In this case we would still keep @npm_bazel_typescript workspace but most users would not need to know about it. Anyone buliding from sources uses @npm_bazel_typescript//:index.from_src.bzl which would stay, but we would delete @npm_bazel_typescript//:index.bzl to be sure the public API is only loaded from one spot.

@alexeagle alexeagle added this to the 1.0 milestone Sep 18, 2019
@alexeagle alexeagle added cleanup Tech debt, resolving it improves our own velocity need: discussion labels Sep 18, 2019
@gregmagolan
Copy link
Collaborator

gregmagolan commented Sep 18, 2019

This would also solve the issue users are having if they have multiple npm workspaces.

Some users with monorepos want to manage multiple package.json files and have multiple yarn_installs. They have may an @npm workspace for pulling in @bazel/typescript and calling install_bazel_dependencies() from but they will also have @npm_a and @npm_b for different apps within their monorepo.

Currently, they need to override the ts_library defaults

_DEFAULT_COMPILER = "@npm//@bazel/typescript/bin:tsc_wrapped"
_DEFAULT_NODE_MODULES = Label("@npm//typescript:typescript__typings")

in a defaults.bzl for each app so that they point to the appropriate npm workspace. If the users load ts_library directly from the npm repo for the app such as @npm_a//@bazel/typescript:index.bzl then the correct defaults would already be set.

The same general pattern applies to other rule such as karma which as _DEFAULT_KARMA_BIN = "@npm//@bazel/karma/bin:karma" and less which has default = Label("@npm//@bazel/less/bin:less"), and protractor which has
``
_DEFUALT_PROTRACTOR = "@npm//@bazel/protractor"
_DEFUALT_PROTRACTOR_ENTRY_POINT = "@npm//:node_modules/@bazel/protractor/protractor.js"

@gregmagolan
Copy link
Collaborator

gregmagolan commented Sep 30, 2019

We should also consider making the WORKSPACE load locations for dependency setup such as,

load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace")
ts_setup_workspace()

consistent with @npm//@bazel/typescript:index.bzl. This will make it very clear what is being setup from the label.

@alexeagle alexeagle removed this from the 1.0 milestone Nov 14, 2019
@alexeagle alexeagle added this to the 2.0 milestone May 27, 2020
@alexeagle
Copy link
Collaborator Author

This is now mostly done, all the nested workspaces under packages/ are removed.

The only remaining task to maybe do is rename the dependencies functions like npm_bazel_karma_dependencies

@alexeagle alexeagle self-assigned this May 27, 2020
@alexeagle
Copy link
Collaborator Author

@gregmagolan and I decided the names aren't wrong or misleading, just long and has some historical baggage. so not worth the churn.

This is all done !

alexeagle pushed a commit to alexeagle/rules_nodejs that referenced this issue May 28, 2020
This function is no longer needed since bazel-contrib#1149 was finished. However, @angular/bazel relies on it, as might other third-party packages we know nothing about.
The conservative rollout is to warn on usage for now, then remove the feature in 3.0

This change also removes our own usage of the function except for angular_view_engine. We also stop writing it in new workspaces created with @bazel/create
alexeagle pushed a commit to alexeagle/rules_nodejs that referenced this issue May 28, 2020
This function is no longer needed since bazel-contrib#1149 was finished. However, @angular/bazel relies on it, as might other third-party packages we know nothing about.
The conservative rollout is to warn on usage for now, then remove the feature in 3.0

This change also removes our own usage of the function except for angular_view_engine. We also stop writing it in new workspaces created with @bazel/create
alexeagle pushed a commit that referenced this issue May 28, 2020
This function is no longer needed since #1149 was finished. However, @angular/bazel relies on it, as might other third-party packages we know nothing about.
The conservative rollout is to warn on usage for now, then remove the feature in 3.0

This change also removes our own usage of the function except for angular_view_engine. We also stop writing it in new workspaces created with @bazel/create
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Tech debt, resolving it improves our own velocity
Projects
None yet
Development

No branches or pull requests

2 participants