Releases: bazelbuild/rules_nodejs
4.1.0
Note, the @bazel/worker
package changed in this release and now uses google-protobuf rather than protobufjs, however this change shouldn't be user-visible. Thanks @thesayyn !
To upgrade:
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "b32a4713b45095e9e1921a7fcb1adf584bc05959f3336e7351bcf77f015a2d7c",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.1.0/rules_nodejs-4.1.0.tar.gz"],
)
and update @bazel
-scoped npm packages.
Features
- builtin: add support for using a local .nvmrc file for providing a node version (#2911) (44740df) Thanks @josephperrott !
- decouple @bazel/worker from rules_typescript (#2918) (bda0472)
Bug Fixes
- typescript: write json srcs to generated tsconfig for resolveJsonModule+composite projects (c70a07b)
- readme (52ee4ef)
- remove dependency on shelljs in esbuild-update script (0f17126)
- update
tsutils
to version3.21.0
(bba5494), closes /github.com/bazelbuild/rules_nodejs/blob/9b454e38f7e2bbc64f75ee9a7dcb6ff45f1c7a12/third_party/github.com/bazelbuild/rules_typescript/internal/tsetse/rules/check_return_value_rule.ts#L60-L62 - use execSync to call npm (acc64f9)
4.0.0
π£ This is our twice-yearly major release with some breaking changes.
To upgrade, use this WORKSPACE
snippet:
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "8a7c981217239085f78acc9898a1f7ba99af887c1996ceb3b4504655383a2c3c",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.0.0/rules_nodejs-4.0.0.tar.gz"],
)
and upgrade your @bazel
-scoped npm packages to latest
Updated dependency versions
-
rules_nodejs only supports the current LTS of Bazel, 4.0.0 or later. This is a policy restriction to save us time tracking down support issues on older versions of Bazel, not a technical one. You can patch this check out locally if you really need to continue using older Bazel, but this puts you on unsupported track since we only test against LTS. (a9c5966)
-
We updated the default nodejs version to the current LTS (14.17.5). If you want to keep the same nodejs version as the default in 3.x, use
node_repositories(node_version="12.13.0")
in yourWORKSPACE
-
We updated the default yarn version to current latest (1.22.11). If you want to keep the same yarn version as the default in 3.x, use
node_repositories(yarn_version="1.19.1")
in yourWORKSPACE
BREAKING CHANGES
-
typescript: ts_project tsconfig attribute now defaults to just 'tsconfig.json' rather than '[name].json'
-
builtin: flipped default for pkg_npm#validate to True (16a099e) Just follow the printed instructions to either set the right package_name or disable the validation
-
builtin: The
@bazel/runfiles
lookupDirectory
method has been removed. Use theresolve
method instead -
esbuild: Add toolchain support for esbuild, removing the need for the tool attribute. Load the
esbuild_repositories
macro and call it within theWORKSPACE
, this will by default define esbuild binaries for Windows, MacOS and Linux (all amd64). -
esbuild: Refactor esbuild rule to use esbuild's API:
args
now takes adict
(wasstring_list
), where the keys are the arg names from the JS API for esbuild.
define
now takes adict
(wasstring_list
), following the format of the define esbuild JS API. -
esbuild: Only enable code splitting when setting
splitting = True
Previously there was no way to produce an output directory without also enabling code splitting. -
typescript:
module_name
will no longer turn on linking for thets_library
target; insteadpackage_name
must now be specified to enable linking.package_path
may also be specified to control the link location (#2799) -
docs: We used to maintain a GitHub Pages based documentation site at https://bazelbuild.github.io/rules_nodejs/ - however this was too much maintenance burden for our small team of OSS contributors, and we never found a way to properly version documentation on GitHub Pages hosting. We now suggest you use the markdown files in the docs/ folder of this repo, which are always up-to-date with respect to the branch you're viewing. For example, https://github.com/bazelbuild/rules_nodejs/blob/4.0.0/docs/index.md is the entry point for the 4.0.0 release. If you'd like to have features like versioning, search, sidenavs, copy-paste code snippets, and more, we recommend using a third-party site: https://docs.aspect.dev/rules_nodejs
Code Refactoring
- typescript: tsconfig default to tsconfig.json (c6ae95c)
Features
- esbuild: allow for .ts, .tsx and .jsx entry points (e3edb28)
- esbuild: add support for plugins via supplying a configuration file (5551bff)
- esbuild: add support for plugins via supplying a configuration file (#2840) (c95d9ca)
- esbuild: support stamping via config file (413f73d)
- labs: ts_proto_library directly exports commonjs (5f26d0f)
- add package_name to ts_library (d2d4d16)
- builtin: document how nodejs_binary#entry_point can use a direc⦠(#2579) (fcdcf63)
- cypress: cypress executable toolchain (#2668) (f1f5ee6)
- esbuild: add support for toolchains (#2704) (ae011bf)
- esbuild: filter ts declaration files by default (f83cf48)
- add opt-in exports_directories_only mode to yarn_install and npm_install (defaults to False) (a7200aa)
- support dict style directory_file_path entry_point in nodejs_binary, nodejs_test & jasmine_node_test (5fafe19)
- support directory_file_path entry_point in npm_umd_bundle (8bee1b3)
- builtin: add package_json_remove and package_json_replace attributes to yarn_install & npm_install (b68be36)
Performance Improvements
- cypress: export cypress as a directory symlink (8ea7ff4)
Bug Fixes
- add missing SHA for rules_proto (#2830) (e822b95)
- esbuild: generate correct path mappings as mappings aspect no longer produces an array (#2834) (b79e3f4)
- typescript: fix bug in ts_project (write_tsconfig_rule) when extending from a generated tsconfig in same folder (4e396eb)
- builtin: generated nodejs repository for windows references non-existent file (4487698)
- builtin: propogate tags to both generated targets in generated_file_test (e980107)
- builtin: runfile resolution incorrect if entry starts similarly (3be2902)
- builtin: write stdout/stderr to correct path under chdir (#2681) (99760a5), closes #2680
- esbuild: prefer finding entry_point files in deps rather than srcs (#2692) (5f4bb15)
- esbuild: provide JSModuleInfo of output bundle (#2685) (82ef1a1)
- esbuild: update update script file paths after removal of _README.md (#2695) (f320ef0)
- jasmine: don't assume entry_point is a label as it may now be a dict (3fa2e5f)
- jasmine: unhanded promise rejection causes tests suit to pass (a511f3d), closes 3.7.0/lib/jasmine.js#L267 #2688
- terser: make terser resolve more robust by not assuming a single /terser/ segment in the path (95fc9ba)
- allow for only stderr to be set on npm_package_bin (a04a7ef)
- builtin: add two missing locations where Mac M1 support needs to be declared (ad20275), closes #2733
- builtin: support directory_file_path entry_point in nodejs_binary & nodejs_test when --bazel_patch_module_resolver is set (50e6d1d)
- typescript: fixed "output was not created" error for ts_project with supports_workers (9a3e5c9)
- typescript: repair error reporting when a ts_project is missing declaration=True (5f0be65)
- make generated_file_test
.update
's visibility same as test rule (#2677) (1ce9dce) - remove current directory prefix when running from execroot (9771b74)
- builtin: correctly calculate pkg._directDependency when a mapped node_module is used (32551a5)
- typescript: do not re-declare .json output files in src...
4.0.0-rc.1
Please use the 4.0.0 release instead.
4.0.0-rc.0
Please use rc.1 instead
3.8.0
Upgrade with
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "e79c08a488cc5ac40981987d862c7320cee8741122a2649e9b08e850b6f20442",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.8.0/rules_nodejs-3.8.0.tar.gz"],
)
and update @bazel
-scoped npm packages
Features
@bazel/worker
package no longer checks whether the major version of rules_nodejs matches what it was built against.
Needed for our 4.0.0 release so that dependencies like the worker mode of rules_sass doesn't throw.
Bug Fixes
- remove current directory prefix when running from execroot (6be5186)
- builtin: correctly calculate pkg._directDependency when a mapped node_module is used (9e23f8a)
- labs: fix ts_proto_library handling of external proto_library (57c6576)
- runfiles: don't use false as a no-error value (#2837) (be8b27c)
- typescript: do not re-declare .json output files in srcs if they are already generated files (6508c6a)
- typescript: document tsc_test for typecheck-only (bc4d34a)
- typescript: fix bug in ts_project (write_tsconfig_rule) when extending from a generated tsconfig in same folder (10cca5c)
4.0.0-beta.1
Use 4.0.0-rc.0 instead
4.0.0-beta.0
chore(release): 4.0.0-beta.0
3.7.0
π£ This is likely the last 3.x release of rules_nodejs. We are entering the beta and RC period for 4.0
Upgrade with this WORKSPACE
snippet
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "8f5f192ba02319254aaf2cdcca00ec12eaafeb979a80a1e946773c520ae0a2c9",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.7.0/rules_nodejs-3.7.0.tar.gz"],
)
and upgrade your @bazel
-scoped npm packages as well.
Features
- builtin: add validate attribute on pkg_npm (5d30c5b), closes #2782
- typescript: support typescript 4.3 (847ef5d)
Bug Fixes
3.6.0
Upgrade with
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "0fa2d443571c9e02fcb7363a74ae591bdcce2dd76af8677a95965edf329d778a",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.6.0/rules_nodejs-3.6.0.tar.gz"],
)
and update @bazel
-scoped npm packages as well.
Features
major performance improvement: node_modules can now be directories
In every prior release of rules_nodejs, third-party libraries from npm (node_modules) were given generated BUILD files that used a filegroup
to expose all the files in the package. Since npm typically has a very high library re-use, it's easy for a project using something like create-react-scripts (or any high-level workflow/build tool) to have tens of thousands of these files. This doesn't work well under Bazel's sandbox or runfiles features, because these do some filesystem operation for every file.
This release adds an add opt-in exports_directories_only mode to yarn_install and npm_install. It defaults to False, but we intend to flip the default to True in our next major release (4.0)
To opt-in, in your WORKSPACE:
npm_install(
name = "npm",
...
# export only top-level package directory artifacts from node_modules
exports_directories_only = True,
)
Then, to avoid warnings from Bazel about directories as sources, add this to your .bazelrc
:
startup --host_jvm_args=-DBAZEL_TRACK_SOURCE_DIRECTORIES=1
Turning this on will decrease the time it takes for Bazel to setup runfiles and sandboxing when
there are a large number of npm dependencies as inputs to an action. One user observed an improvement from ~48m to ~30m on their build.
This breaks compatibilty for labels that reference files within npm packages such as @npm//:node_modules/prettier/bin-prettier.js
.
To reference files within npm packages, you can use the directory_file_path
rule and/or DirectoryFilePathInfo
provider.
Note, some rules still need upgrading to support consuming DirectoryFilePathInfo
where needed.
NB: This feature requires runfiles be enabled due to an issue in Bazel which we are still investigating.
On Windows runfiles are off by default and must be enabled with the --enable_runfiles
flag when
using this feature.
NB: ts_library
does not support directory artifact npm deps due to internal design choice of having all input sources files explicitly specified
NB: karma_web_test
and karma_web_test_suite
do not yet support directory artifact npm deps as they require node_modules/requirejs/require.js
& node_modules/karma-requirejs/lib/adapter.js
explicit source files in deps
For the nodejs_binary
& nodejs_test
entry_point
attribute (which often needs to reference a file within
an npm package) you can set the entry_point to a dict with a single entry, where the key corresponds to the directory artifact
label and the value corresponds to the path within that directory to the entry point.
For example,
nodejs_binary(
name = "prettier",
data = ["@npm//prettier"],
entry_point = "@npm//:node_modules/prettier/bin-prettier.js",
)
becomes,
nodejs_binary(
name = "prettier",
data = ["@npm//prettier"],
entry_point = { "@npm//:node_modules/prettier": "bin-prettier.js" },
)
For other labels that are passed to $(rootpath)
, $(execpath)
, or $(location)
you can simply break these apart into
the directory artifact label that gets passed to the expander & path part to follows it.
For example,
$(rootpath @npm//:node_modules/prettier/bin-prettier.js")
becomes,
$(rootpath @npm//:node_modules/prettier)/bin-prettier.js
Other features
- support dict style directory_file_path entry_point in nodejs_binary, nodejs_test & jasmine_node_test (737674f)
- support directory_file_path entry_point in npm_umd_bundle (4e44178)
Bug Fixes
- allow for only stderr to be set on npm_package_bin (fa8f5b1)
- builtin: add two missing locations where Mac M1 support needs to be declared (2ad950f), closes #2733
- builtin: propogate tags to both generated targets in generated_file_test (c4403fc)
- builtin: support directory_file_path entry_point in nodejs_binary & nodejs_test when --bazel_patch_module_resolver is set (51676ef)
- jasmine: don't assume entry_point is a label as it may now be a dict (3683466)
- jasmine: unhanded promise rejection causes tests suit to pass (3c4ef58), closes 3.7.0/lib/jasmine.js#L267 #2688
- terser: make terser resolve more robust by not assuming a single /terser/ segment in the path (4709ffb)
- typescript: fixed "output was not created" error for ts_project with supports_workers (807b07b)
- typescript: repair error reporting when a ts_project is missing declaration=True (cd08efe)
3.5.1
Upgrade with:
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "4a5d654a4ccd4a4c24eca5d319d85a88a650edf119601550c95bf400c8cc897e",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.5.1/rules_nodejs-3.5.1.tar.gz"],
)
and update your @bazel
-scoped npm packages.
Bug Fixes
- builtin: support for Apple Silicon (
darwin_arm64
) nodejs toolchain (Node 16 only) - builtin: document how nodejs_binary#entry_point can use a direc⦠(#2579) (ceddd1d)
- builtin: generated nodejs repository for windows references non-existent file (c1663c5)
- builtin: write stdout/stderr to correct path under chdir (#2681) (36311bb), closes #2680
- esbuild: prefer finding entry_point files in deps rather than srcs (#2692) (dd4c4f3)
- esbuild: provide JSModuleInfo of output bundle (#2685) (233254d)
- esbuild: update update script file paths after removal of _README.md (#2695) (25a5ac4)
- make generated_file_test
.update
's visibility same as test rule (#2677) (30bc86c)