Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ rules_js is just a part Aspect's monorepo developer platform:
- [rules_jasmine](https://github.com/aspect-build/rules_jasmine) - Bazel rules to run tests using [Jasmine](https://jasmine.github.io/)
- [rules_terser](https://github.com/aspect-build/rules_terser) - Bazel rules for [Terser](https://terser.org) - a JavaScript minifier
- [rules_cypress](https://github.com/aspect-build/rules_cypress) - Bazel rules to run tests using [Cypress](https://www.cypress.io)
- [rules_lint](https://github.com/aspect-build/rules_lint) includes [eslint support](https://registry.bazel.build/docs/aspect_rules_lint#lint-eslint-bzl).
- [rules_lint](https://github.com/aspect-build/rules_lint) includes [eslint support](https://registry.bazel.build/modules/aspect_rules_lint/latest/docs/lint/eslint.bzl).

## Known issues

Expand All @@ -51,7 +51,7 @@ Follow instructions from the release you wish to use:

## Usage

See the documentation in the [docs](docs/) folder and generated API docs at https://registry.bazel.build/docs/aspect_rules_js.
See the documentation in the [docs](docs/) folder and generated API docs at https://registry.bazel.build/modules/aspect_rules_js/latest/docs

## Examples

Expand Down
2 changes: 1 addition & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ my-workspace/

Note that when following option 2, it might require updating some configuration files which refer to the original output locations. For example, your `tsconfig.json` file might have a `paths` section which points to the `../../dist` folder.

To keep your legacy build system working during the migration, you might want to avoid changing those configuration files in-place. For this purpose, you can use [the `jq` rule](https://registry.bazel.build/docs/jq.bzl#function-jq) in place of `copy_to_bin`, using a `filter` expression so the copy of the configuration file in `bazel-bin` that's used by the Bazel build can have a different path than the configuration file in the source tree.
To keep your legacy build system working during the migration, you might want to avoid changing those configuration files in-place. For this purpose, you can use [the `jq` rule](https://registry.bazel.build/modules/jq.bzl/latest/docs/jq/jq.bzl/jq) in place of `copy_to_bin`, using a `filter` expression so the copy of the configuration file in `bazel-bin` that's used by the Bazel build can have a different path than the configuration file in the source tree.

## Does rules_js support path mapping?

Expand Down
10 changes: 5 additions & 5 deletions docs/pnpm.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and solves version constraints.
It also determines how the `node_modules` tree will be structured for runtime.
This information is encoded into a lockfile which is checked into the source repository.

The pnpm lockfile format includes all the information needed to define [`npm_import`](https://registry.bazel.build/docs/aspect_rules_js#function-npm_import) rules for each package,
The pnpm lockfile format includes all the information needed to define [`npm_import`](https://registry.bazel.build/modules/aspect_rules_js/latest/docs/npm/extensions.bzl/npm) rules for each package,
allowing Bazel's downloader to do the fetches individually. This info includes the integrity hash, as calculated by the package manager,
so that Bazel can guarantee supply-chain security.

Expand All @@ -16,16 +16,16 @@ Thus it is performant to convert a very large `pnpm-lock.yaml` file without conc
users needing to fetch many unnecessary packages. We have benchmarked this code with
800+ importers and ~15,000 npm packages to run in 3sec, when Bazel determines that an input changed.

While the [`npm_import`](https://registry.bazel.build/docs/aspect_rules_js#module_extension-npm_import) rule can be used to bring individual packages into Bazel,
While the [`npm_import`](https://registry.bazel.build/modules/aspect_rules_js/latest/docs/npm/extensions.bzl/npm) rule can be used to bring individual packages into Bazel,
most users will want to import their entire lockfile.
The `npm_translate_lock` rule does this, and its operation is described below.
You may wish to read the [generated API documentation](https://registry.bazel.build/docs/aspect_rules_js#tag-npm-npm_translate_lock) as well.
You may wish to read the [generated API documentation](https://registry.bazel.build/modules/aspect_rules_js/latest/docs/npm/extensions.bzl/npm) as well.

## Rules overview

As a high level overview, the primary rules and targets used by developers to fetch and link npm package dependencies are:

- [`npm.translate_lock()`](https://registry.bazel.build/docs/aspect_rules_js#tag-npm-npm_translate_lock) - generate targets representing packages from a pnpm lockfile.
- [`npm.translate_lock()`](https://registry.bazel.build/modules/aspect_rules_js/latest/docs/npm/extensions.bzl/npm) - generate targets representing packages from a pnpm lockfile.
- `npm_link_all_packages()`- defines a `node_modules` tree and the associated `node_modules/{package}` targets. This rule is required in the BUILD file of each package in the pnpm workspace that has npm packages linked into a `node_modules` folder as well the BUILD file of the package that corresponds to the root of the pnpm workspace where the pnpm lock file resides.
- `:node_modules/{package}` - targets generated by `npm_link_all_packages()` representing each package dependency from a `package.json` within the pnpm workspace.

Expand Down Expand Up @@ -222,7 +222,7 @@ npm_translate_lock(
```

Patching applied by rules_js may slightly deviate from standard pnpm patching behavior.
The [bazel-lib patch util](https://registry.bazel.build/docs/bazel_lib#function-patch)
The [bazel-lib patch util](https://registry.bazel.build/modules/bazel_lib/latest/docs/lib/repo_utils.bzl/patch)
is used for patching within rules_js instead of the internal pnpm patching mechanism.
For example a bad patch file may be partially applied when using pnpm outside of bazel but fail
when applied by rules_js, see [rules_js #1915](https://github.com/aspect-build/rules_js/issues/1915).
Expand Down
2 changes: 1 addition & 1 deletion docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Sometimes the package intentionally doesn't list dependencies, because it discov
This is used for tools that locate their "plugins"; `eslint` and `prettier` are common typical examples.

The solution is based on pnpm's [public-hoist-pattern](https://pnpm.io/settings#publichoistpattern).
Use the [`public_hoist_packages` attribute of `npm_translate_lock`](https://registry.bazel.build/docs/aspect_rules_js#npm-extensions-bzl).
Use the [`public_hoist_packages` attribute of `npm_translate_lock`](https://registry.bazel.build/modules/aspect_rules_js/latest/docs/npm/extensions.bzl/npm).
The documentation says the value provided to each element in the map is:

> a list of Bazel packages in which to hoist the package to the top-level of the node_modules tree
Expand Down
2 changes: 1 addition & 1 deletion e2e/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use_repo(npm, "npm")
# The following is just a demonstration that you can skip the npm_translate_lock feature
# and import npm packages directly, with no lock file.
# This is not typical use.
# See docs in https://registry.bazel.build/docs/aspect_rules_js#module_extension-npm_import about the difference.
# See docs in https://registry.bazel.build/modules/aspect_rules_js/latest/docs/npm/extensions.bzl/npm about the difference.
npm.npm_import(
name = "npm_meaning-of-life",
package = "meaning-of-life",
Expand Down
2 changes: 1 addition & 1 deletion js/private/js_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ _ATTRS = {
This must be a target that provides a single file or a `DirectoryPathInfo`
from `@bazel_lib//lib::directory_path.bzl`.

See https://registry.bazel.build/docs/bazel_lib#provider-directorypathinfo
See https://registry.bazel.build/modules/bazel_lib/latest/docs/lib/directory_path.bzl/DirectoryPathInfo
for more info on creating a target that provides a `DirectoryPathInfo`.
""",
mandatory = True,
Expand Down
2 changes: 1 addition & 1 deletion npm/private/npm_package_visibility.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Package visibility violation:
This package is not visible from {}.
Check the package_visibility configuration in your npm_translate_lock rule.

For more information, see: https://registry.bazel.build/docs/aspect_rules_js#module_extension-translate_lock
For more information, see: https://registry.bazel.build/modules/aspect_rules_js/latest/docs/npm/extensions.bzl/npm
"""

def validate_npm_package_visibility(accessing_package, package_locations, visibility_config):
Expand Down
2 changes: 1 addition & 1 deletion npm/private/npm_translate_lock_generate.docs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def npm_link_targets(name = "node_modules", package = None, prod = True, dev = T
def npm_link_all_packages(name = "node_modules", imported_links = [], prod = True, dev = True):
"""Generated list of npm_link_package() target generators and first-party linked packages corresponding to the packages in {pnpm_lock_label}

If you use manually-written [`npm_import`](https://registry.bazel.build/docs/aspect_rules_js#module_extension-npm_import) you can link these as well, for example,
If you use manually-written [`npm_import`](https://registry.bazel.build/modules/aspect_rules_js/latest/docs/npm/extensions.bzl/npm) you can link these as well, for example,

load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm_meaning-of-life__links//:defs.bzl", npm_link_meaning_of_life = "npm_link_imported_package")
Expand Down
Loading