Skip to content

Releases: bazel-contrib/rules_nodejs

1.4.1

06 Mar 23:58
Compare
Choose a tag to compare

To upgrade:

http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "2eca5b934dee47b5ff304f502ae187c40ec4e33e12bcbce872a2eeb786e23269",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.4.1/rules_nodejs-1.4.1.tar.gz"],
)

and update all your @bazel-scoped npm packages to the matching versions.
yarn: yarn upgrade --scope @bazel
npm: there is no built-in command but you can try npx update-by-scope @bazel

Bug Fixes

  • builtin: Bazel build failing when project is not on the system drive on Windows (C:) (#1641) (d9cbb99f
  • windows_utils: Escaping \ and " before passing args to bash scrip… (#1685) (f9be953d

1.4.0

03 Mar 00:25
Compare
Choose a tag to compare

To upgrade:

http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "c9e59009049fa42198f7087b80398fc4b2698a0f0c7fdde4fb3540c899c9b309",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.4.0/rules_nodejs-1.4.0.tar.gz"],
)

and update all your @bazel-scoped npm packages to the matching versions.
yarn: yarn upgrade --scope @bazel
npm: there is no built-in command but you can try npx update-by-scope @bazel

Bug Fixes

  • builtin: don't include external files when pkg_npm is in root package (#1677) (8089999), closes #1499
  • examples: change build target label to //src:prodapp (a7f07d1)
  • examples: fix angular examples to use bazelisk (02e6462)
  • ensure BAZEL_NODE_RUNFILES_HELPER & BAZEL_NODE_PATCH_REQUIRE are absolute (#1634) (25600ea)
  • expand_variables helper should handle external labels (3af3a0d)
  • logic error in expand_variables (#1631) (32c003f)
  • yarn cache path should be a string (#1679) (a43809b)
  • builtin: use posix paths in assembler (d635dca), closes #1635
  • create: use latest typescript (a8ba18e), closes #1602
  • examples: add fixes to angular architect (f6f40c3)
  • remove empty arguments from launcher (#1650) (aa3cd6c)

Features

  • @bazel/jasmine: update dependencies to jasmine v3.5.0 (98fab93)
  • docs: add authroing instructions (4dde728)
  • docs: add header anchor links (2002046)
  • docs: add vscode debugging section (78d308f)
  • examples: add serve to angular architect (1569f4b)
  • jasmine: configure XML reporter to capture detailed testlogs (8abd20d)
  • rollup: add args attribute to rollup_bundle rule (#1681) (94c6182)
  • rollup: add silent attr to rollup_bundle to support --silent flag (#1680) (18e8001)
  • typescript: use run_node helper to execute tsc (066a52c)

1.3.0

07 Feb 20:38
Compare
Choose a tag to compare

To upgrade:

http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "b6670f9f43faa66e3009488bbd909bc7bc46a5a9661a33f6bc578068d1837f37",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.3.0/rules_nodejs-1.3.0.tar.gz"],
)

and run yarn upgrade --scope @bazel to update all your @bazel-scoped npm packages to the latest versions.
(or manually do the npm equivalent - they don't have a way to update a scope)

We now recommend using @bazel/bazelisk rather than @bazel/bazel. See https://github.com/bazelbuild/rules_nodejs/wiki

This release includes a fix so that Bazel 2.1 no longer needs the @bazel/hide-build-files workaround.

Bug Fixes

  • builtin: strip leading v prefix from stamp (#1591) (39bb821)
  • angular example ts_scripts path in Windows (30d0f37), closes #1604
  • html script injection is broken on windows (7f7a45b), closes #1604
  • unset YARN_IGNORE_PATH before calling yarn in @nodejs targets (aee3003), closes #1588

Features

  • builtin: add environment attribute to yarn_install & npm_install (#1596) (87b2a64)
  • builtin: expose @npm//foo__all_files filegroup that includes all files in the npm package (#1600) (8d77827)
  • examples: add protractor angular architect (#1594) (d420019)

1.2.4

31 Jan 23:13
Compare
Choose a tag to compare

To upgrade:

http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "9473b207f1c5a61b603442cbfeeea8aaf2aa62870673fce2a1c52087f6ff4dc9",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.2.4/rules_nodejs-1.2.4.tar.gz"],
)

and run yarn upgrade --scope @bazel to update all your @bazel-scoped npm packages to the latest versions.
(or manually do the npm equivalent - they don't have a way to update a scope)

Bug Fixes

  • builtin: fix logic error in linker conflict resolution (#1597) (b864223)

1.2.2

31 Jan 06:00
Compare
Choose a tag to compare

To upgrade:

http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "6bcef105e75cac3c5f8212e0d0431b6ec1aaa1963e093b0091474ab98ecf29d2",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.2.2/rules_nodejs-1.2.2.tar.gz"],
)

and run yarn upgrade --scope @bazel to update all your @bazel-scoped npm packages to the latest versions.
(or manually do the npm equivalent - they don't have a way to update a scope)

Bug Fixes

  • unset YARN_IGNORE_PATH in yarn_install before calling yarn (5a2af71)
  • fixes #1567 Recursively copy files from subdirectories into mirrored structure in the npm archive (c83b026)

Code Refactoring

  • Replace grep with bash's regex operator (9fb080b)

Examples

  • enable test file crawling for jest example (8854bfd)
  • add angular bazel architect (6dc919d)

1.2.1

30 Jan 07:07
Compare
Choose a tag to compare

To upgrade:

http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "ecaa54955b314b5e33948bd8f39e35c35ee89e905d8de1c03868100293510573",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.2.1/rules_nodejs-1.2.1.tar.gz"],
)

and run yarn upgrade --scope @bazel to update all your @bazel-scoped npm packages to the latest versions.
(or manually do the npm equivalent - they don't have a way to update a scope)

Bug Fixes

  • allow "src" and "bin" module mappings to win over "runfiles" (110e00e)
  • also link "runfiles" mappings from *_test rules (79bedc5)
  • osx hide-bazel-files issue with fsevents (#1578) (64a31ab)
  • yarn_install failure if yarn is a dependency (#1581) (f712377)

1.2.0

24 Jan 20:19
Compare
Choose a tag to compare

To upgrade:

http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "591d2945b09ecc89fde53e56dd54cfac93322df3bc9d4747cb897ce67ba8cdbf",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.2.0/rules_nodejs-1.2.0.tar.gz"],
)

and run yarn upgrade --scope @bazel to update all your @bazel-scoped npm packages to the latest versions.
(or manually do the npm equivalent - they don't have a way to update a scope)

Bug Fixes

  • builtin: legacy module_mappings_runtime_aspect handles dep with module_name but no module_root (9ac0534)
  • builtin: nodejs_binary collects module_mappings for linker (4419f95)
  • builtin: set cwd before running yarn for yarn_install (#1569) (d7083ac)

Features

  • builtin: add configuration_env_vars to npm_package_bin (07d9f5d)

1.1.0

12 Jan 21:17
Compare
Choose a tag to compare

To upgrade:

http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "c97bf38546c220fa250ff2cc052c1a9eac977c662c1fc23eda797b0ce8e70a43",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.1.0/rules_nodejs-1.1.0.tar.gz"],
)

and run yarn upgrade --scope @bazel to update all your @bazel-scoped npm packages to the latest versions.
(or manually do the npm equivalent - they don't have a way to update a scope)

Bug Fixes

  • nodejs_binary, nodejs_test, jasmine_node_test: scripts loaded with templated_args via --node_options=--require=/path/to/script.js now get node require patches by default
    • separate nodejs require patches from loader and —require them first (b10d230)
  • Fixes for putting protractor & karma rules into debug mode with --node_options=--inspect-brk:
    • karma: pass --node_options to karma (d48f237)
    • protractor: pass --node_options to protractor (a3b39ab)

Features

  • builtin: add support for Predefined variables and Custom variable to npm_package_bin (34176e5)
  • examples: add nestjs test (f448931)
  • examples: add nodejs_binary cluster example (#1515) (f217519)

1.0.1

03 Jan 01:49
Compare
Choose a tag to compare

To upgrade:

http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "e1a0d6eb40ec89f61a13a028e7113aa3630247253bcb1406281b627e44395145",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.0.1/rules_nodejs-1.0.1.tar.gz"],
)

and run yarn upgrade --scope @bazel to update all your @bazel-scoped npm packages to the latest versions.
(or manually do the npm equivalent - they don't have a way to update a scope)

Bug Fixes

  • don't bake COMPILATION_MODE into launcher as exported environment var (8a931d8)
  • builtin: make .pack and .publish targets work again (43716d3), closes #1493
  • create: @bazel/create should verbose log based on VERBOSE_LOGS instead of COMPILATION_MODE (c1b97d6)

Features

  • builtin: allow patching require in bootstrap scripts (842dfb4)

First stable release!

20 Dec 15:09
Compare
Choose a tag to compare

As indicated in earlier release notes, we have been working through a list of API changes that improve consistency and reduce the surface area that needs support. In the 1.0 final release we have made a lot of breaking changes to our APIs. We realize this churn costs you time but we hope the better API is worth it.

We now enter a period of stability where we expect to work only on bugfixes. Any future breaking changes will be subject to much more scrutiny. We intend to continue following semantic versioning, with a 2.0 after several months.

To upgrade:

http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "3887b948779431ac443e6a64f31b9e1e17b8d386a31eebc50ec1d9b0a6cabd2b",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.0.0/rules_nodejs-1.0.0.tar.gz"],
)

and run yarn upgrade --scope @bazel to update all your @bazel-scoped npm packages to the latest versions.
(or manually do the npm equivalent - they don't have a way to update a scope)

Thanks to our awesome community!

This is a community-supported project. Now that we have reached 1.0 we expect the stability to make it easier than ever to contribute. See the list of committers https://github.com/bazelbuild/rules_nodejs/graphs/contributors and show your appreciation for one of these people if you get a chance. Also thanks to everyone who submitted an issue, helped us think through design, or attended our meetings. These contributions are just as valuable as commits.

Known issues

The .pack and .publish targets in pkg_npm (previously npm_package) are broken. They fail with an error that npm cannot find the package.json file. See #1493

New Stuff

  • copy_to_bin rule that simply copies a list of files from the source directory to the output directory (bazel-bin)
    This is useful to make a fully self-contained output directory, allowing relative paths to be resolved without needing a runfiles tree or runfiles helper library.

  • params_file rule that generates a params file from a list of arguments. This is similar to the write_file rule provided by skylib with the additional feature that the arguments are subject to $(location) expansion.

Breaking Changes

defs.bzl -> index.bzl

Replace any load statements from @build_bazel_rules_nodejs//:defs.bzl with @build_bazel_rules_nodejs//:index.bzl.
We print a useful error if you load from the old location, pointing to a wiki page with some help.

npm_install and yarn_install

Removed unused exclude_packages attribute

New args attribute can be used to pass arbitrary arguments. This replaces the following attributes:

  • prod_only; should be replaced by args = ["--prod"] (yarn_install) and args = ["--production"] (npm_install)
  • frozen_lockfile from yarn_install; should be replaced by args = ["--frozen-lockfile"]
  • network_timeout from yarn_install; should be replaced by args = ["--network_timeout", "<time in ms>"]

npm_package -> pkg_npm

The npm_package rule is renamed to pkg_npm.
This is to match the naming convention for package rules https://docs.bazel.build/versions/master/be/pkg.html.

  • attribute packages renamed to nested_packages
  • attribute replacements renamed to substitutions
  • attribute rename_build_files renamed to hide_build_files

Cleanup non-public entry points

It's not likely you're using these, but just in case:

  • @build_bazel_rules_nodejs//:declaration_provider.bzl deleted; load from @build_bazel_rules_nodejs//:providers.bzl instead
  • @build_bazel_rules_nodejs//internal/common:npm_pacakge_info.bzl removed; load from @build_bazel_rules_nodejs//:providers.bzl instead
  • transitive_js_ecma_script_module_info macro removed; use js_ecma_script_module_info instead
  • @npm_bazel_karma//:browser_repositories.bzl removed; use @io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl instead
  • @npm_bazel_protractor//:browser_repositories.bzl removed; use @io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl instead
  • ts_web_test & ts_web_test_suite macros removed; use karma_web_test & karma_web_test_suite instead
  • @build_bazel_rules_nodejs//internal/jasmine_node_test removed; use jasmine_node_test from @bazel/jasmine npm package instead

nodejs_binary, nodejs_test, jasmine_node_test

bootstrap attribute removed

The bootstrap attribute in nodejs_binary, nodejs_test & jasmine_node_test is removed

This can be replaced with the --node_options=--require=./path/to/script argument. You can use the $(location) expansion to turn a label into a path. For windows compatibility, you should also wrap it in an $(rlocation) expansion so the script can be looked up in the runfiles.

For example, instead of bootstrap = ["bootstrap.js"] you can do this:

nodejs_test(
    name = "bootstrap_test",
    templated_args = ["--node_options=--require=$(rlocation $(location :bootstrap.js))"],
    entry_point = ":entry.js",
    data = ["bootstrap.js"],
)

Path is returned in runfiles manifest path format such as repo/path/to/file.

This differs from how $(location) and $(locations) expansions behave in the args attribute of a *_binary or *_test targets which expands to the runfiles short path in the format ./path/to/file for user repo and ../external_repo/path/to/file for external repositories. We may change this behavior in the future with $(mlocation) and $(mlocations) used to expand to the runfiles manifest path and $(location) and $(locations) expanding to the runfiles short path to be consistent with args. See https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes-binaries. This would be a breaking change and done on a major release.

templated_args_file removed

The templated_args_file attribute is removed from nodejs_binary, nodejs_test & jasmine_node_test. This was a separation of concerns as templated_args_file complicated node.bzl more than necessary while also being rigid on the params file formatting. It is more flexible to expose this functionality as another simple rule named params_file.

To match the legacy templated_args_file and current templated_args behavior of $(location) and $(locations) expansion, params_file args $(location) expansion returns paths that in the runfiles manifest file format such as repo/path/to/file.

As for templated_args, this differs from how $(location) and $(locations) expansions behave in the args attribute of a *_binary or *_test targets which expands to the runfiles short path in the format ./path/to/file for user repo and ../external_repo/path/to/file for external repositories. We may change this behavior in the future with $(mlocation) and $(mlocations) used to expand to the runfiles manifest path and $(location) and $(locations) expanding to the runfiles short path to be consistent with args. See https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes-binaries. This would be a breaking change and done on a major release.

Usage example:

load("@build_bazel_rules_nodejs//:index.bzl", "params_file", "nodejs_binary")

params_file(
    name = "params_file",
    args = [
        "--some_param",
        "$(location //path/to/some:file)",
        "--some_other_param",
        "$(location //path/to/some/other:file)",
    ],
    data = [
        "//path/to/some:file",
        "//path/to/some/other:file",
    ],
)

nodejs_binary(
    name = "my_binary",
    data = [":params_file"],
    entry_point = ":my_binary.js",
    templated_args = ["$(location :params_file)"],
)

Other changes

Bug Fixes

  • builtin: bin folder was included in runfiles path for tests when link type was 'bin' (f938ab7)
  • builtin: link module_name to directories recursively to avoid directory clashes (#1432) (0217724), closes #1411
  • builtin: strip BOM when parsing package.json (#1453) (c65d9b7), closes #1448
  • typescript: remove stray references to ts_auto_deps (#1449) (aacd924)

chore

Code Refactoring

  • pkg_npm attributes renames packages=>nested_packages & replacements=>substitutions (7e1b7df)
  • remove bootstrap attribute & fix $(location) expansions in nodejs_binary templated_args (1860a6a)
  • remove templated_args_file from nodejs_binary & nodejs_test (799acb4)
  • builtin: add args to yarn_install & npm_install (#1462) (d245d09)
  • builtin: remove legacy jasmine_node_test (6d731cf)
  • builtin: renamed npm_package to pkg_npm to match naming convention (7df4109)
  • pre-1.0 release breaking changes ([cc64818](htt...
Read more