Skip to content

Commit

Permalink
docs: update for generated aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Nov 8, 2021
1 parent cac9678 commit 3d5a09f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/npm_import.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions js/private/translate_package_lock.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Instead of manually declaring the `npm_imports`, this helper generates an extern
containing a helper starlark module `repositories.bzl`, which supplies a loadable macro
`npm_repositories`. This macro creates an `npm_import` for each package.
The generated repository also contains BUILD files declaring targets for the packages
listed as `dependencies` or `devDependencies` in `package.json`, so you can declare
dependencies on those packages without having to repeat version information.
Bazel will only fetch the packages which are required for the requested targets to be analyzed.
Thus it is performant to convert a very large package-lock.json file without concern for
users needing to fetch many unnecessary packages.
Expand All @@ -27,6 +31,18 @@ load("@npm_deps//:repositories.bzl", "npm_repositories")
npm_repositories()
```
Next, in your BUILD files you can declare dependencies on the packages using the same external repository.
Following the same example, this might look like:
```starlark
nodejs_test(
name = "test_test",
data = ["@npm_deps//@types/node"],
entry_point = "test.js",
)
```
"""

_ATTRS = {
Expand Down

0 comments on commit 3d5a09f

Please sign in to comment.