Releases: bazel-contrib/rules_nodejs
3.3.0
Upgrade with
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "f533eeefc8fe1ddfe93652ec50f82373d0c431f7faabd5e6323f6903195ef227",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.3.0/rules_nodejs-3.3.0.tar.gz"],
)
and update your @bazel
-scoped npm packages
Features
- introduce package for runfile helpers (2c883d1)
- make node toolchain_type public so new toolchains can be added (#2591) (b606b79), closes #2565
- esbuild: Script to update esbuild to the latest available version (#2492) (472ed62)
- esbuild: support location expansion in esbuild args (#2564) (eb3bd7e)
- typescript: add support for "jsx: preserve" compiler option (#2574) (425dbd6)
Bug Fixes
- builtin: provide proper error if npm_package_bin has no outs (#2557) (c47b770)
- esbuild: 'output' is passed twice when used (#2587) (57218a6)
- esbuild: files not being found when building external repo (#2563) (d10e17c)
- esbuild: update to esbuild 0.11 (#2559) (e9e8fe7), closes #2552
- jasmine: transitive specs are no longer added to the test suite (#2576) (e7eaf34)
3.2.3
Upgrade with
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "dd7ea7efda7655c218ca707f55c3e1b9c68055a70c31a98f264b3445bc8f4cb1",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.2.3/rules_nodejs-3.2.3.tar.gz"],
)
And update @bazel
-scoped npm packages.
Bug Fixes
- builtin: add transitive typings to runfiles provider produced by js_library (#2547) (41117fa)
- builtin: always install source-map-support (#2538) (97b3886), closes #2520
- esbuild: allow empty string as an input to sourcemap for bazel 2.x support (#2549) (3b3e020)
- typescript: update documentation now that ts_project is recommended (#2548) (a8d8b0f)
- tsconfig validator fails on chained tsconfig references (#2512) (bfd74e5)
- examples: remove relativeLinkResolution (#2530) (8ef60e5)
Features
3.2.2
To upgrade:
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "55a25a762fcf9c9b88ab54436581e671bc9f4f523cb5a1bd32459ebec7be68a8",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.2.2/rules_nodejs-3.2.2.tar.gz"],
)
and update your @bazel
-scoped npm packages.
Bug Fixes
- esbuild: run npm version check as postinstall (#2500) (2efe437)
- esbuild: set correct base url when rule is at root (#2506) (92e8169)
- rollup: include externals config in worker cache key (de9dd86)
Features
3.2.1
upgrade with
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "bfacf15161d96a6a39510e7b3d3b522cf61cb8b82a31e79400a84c5abcab5347",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.2.1/rules_nodejs-3.2.1.tar.gz"],
)
and update your @bazel
-scoped npm dependencies.
Bug Fixes
- remove
--keep-names
(4a26898) - update node versions map (#2484) (9506fe0)
- esbuild: add --preserve-symlinks flag by default (eb71285)
- esbuild: add link_workspace_root for workspace absolute imports (#2476) (ba7e48e), closes #2474
- esbuild: use ':' instead of '=' for esbuild 'define' argument (#2469) (b0fddae)
- esbuild: use ':' instead of '=' for esbuild 'external' argument (#2475) (bc7dc82)
Features
3.2.0
Upgrade with:
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "fcc6dccb39ca88d481224536eb8f9fa754619676c6163f87aa6af94059b02b12",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.2.0/rules_nodejs-3.2.0.tar.gz"],
)
and update your @bazel
-scoped npm dependencies to match.
Features
multi-linker
Previously we restricted a given Node program under Bazel to get all dependencies from a single node_modules
tree, which in practice meant that all monorepo dependencies had to go in the root package.json
file. This is now fixed! A target can depend on multiple, so long as the package_path
attribute is set on yarn_install/npm_install
in the WORKSPACE
. (2c2cc6e)
@bazel/esbuild
We now support a custom rule to use the extremely fast bundler esbuild (e7e5286)
coverage
add coverage all: true support (8386b97)
Bug Fixes
- multi-linker linking when only output files in sandbox (ebb9481)
- builtin: fix coverage source file paths (ae4ec78)
- docs: fix formatting of nodejs_binary#chdir (1caced8)
- docs: fix regex that replaces //packages with @bazel (c31c0b6)
- docs: version selector shows 3.x (38f4f78)
- typescript: allow up to typescript 4.2, add tests for 3.7-4.1 (ea168a7)
- typescript: fixed build for external ts_project targets (c89e0aa)
- version number not edited after release candidate (ac2bb62)
3.1.0
Upgrade with
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "dd4dc46066e2ce034cba0c81aa3e862b27e8e8d95871f567359f7a534cccb666",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.1.0/rules_nodejs-3.1.0.tar.gz"],
)
and upgrade your @bazel
-scoped npm packages.
Bug Fixes
- forward srcs, deps and visibility of dummy_bzl_library to the filegroup when publishing (0466084)
- linker fix for invalid symlink creation path in createSymlinkAndPreserveContents (14086a8)
- relative data paths in yarn_install & npm_install when symlink_node_modules=False and package.json is not at root (3c12dfe)
- builtin: only generate a .tar pkg_npm output when requested (#2428) (4d8f15c)
- builtin: pass quiet attr though to build file generation on npm / yarn install (#2400) (ceb76d6)
- builtin: when using chdir attribute, don't write to source dir (3eb4260)
- typescript: capture js files in outputs of ts_project if allow_js (9d7827b)
- remove mirror.bazel.build from list of node_urls used to fetch NodeJS by default (#2408) (67b494b)
- skip update NodeJS versions action on forks (#2396) (4e40d25)
- examples: angualr universal_server (d5e8413)
- update-nodejs-versions: Fix NodeJS version for running GitHub Action (4ab8252)
Features
2.3.3
upgrade with
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "9d93d4e1340c43dbf6b2fd66b683d89630a6310bf8be3bf40ec96685dcacc26c",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/2.3.3/rules_nodejs-2.3.3.tar.gz"],
)
This is just a maintenance release for 2.x.
Bug Fixes
- linker fix for invalid symlink creation path in createSymlinkAndPreserveContents (d18a1ff)
3.0.0
Following our usual 6-month cadence for major releases, here is 3.0.0 just in time for your winter vacation!
As usual, we've done our best to make breaking changes that improve the long-term health of the project and which are easy to adopt. Give us feedback in the #javascript
channel on slack.bazel.build
👏🏻 Thanks to our awesome contributors for this release! 👏🏻
@mistic, @lukasholzer, @duarten, @jbedard, @mrmeku , @opelhoward , @Schibum , @mattinsler , @JiaLiPassion , @fredrikredflag , @KrauseStefan , @comius , @lovepocky , @tylerhou and @OlaviSau
To upgrade:
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "6142e9586162b179fdd570a55e50d1332e7d9c030efd853453438d607569721d",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.0.0/rules_nodejs-3.0.0.tar.gz"],
)
and upgrade your @bazel
-scoped npm packages (you'll get an error when installing 2.x version packages with rules_nodejs 3.x)
Finally, read the 📚 Migration instructions from 2.x for breaking changes:
https://github.com/bazelbuild/rules_nodejs/wiki#migrating-to-30
BREAKING CHANGES
Stricter installs
For both yarn_install
and npm_install
we now fail if the lockfile is out-of-date, rather than update it.
This assumes you'll use the tooling to manually update the lockfile as needed.
yarn_install
now passes --frozen_lockfile
by default, but you can use yarn_install(frozen_lockfile = False)
to go back to the old behavior.
npm_install
now has an attribute npm_command
that defaults to ci
but you can set it to install
to go back to the old behavior.
We also flipped the default for strict_visibility
on these two rules. This prevents you adding a Bazel dependency on a library that isn't listed as a dependency in package.json
. You can set it back to False
if you need the old behavior.
--bazel_patch_module_resolver defaults to false
By default, we no longer patch the require() function, instead you should rely on the linker to make node modules resolvable at the standard location
if this breaks you, the quickest fix is to flip the flag back on a nodejs_binary/nodejs_test/npm_package_bin with templated_args = ["--bazel_patch_module_resolver"]
, see #2344 as an example.
Another fix is to explicitly use our runfiles helper library, see #2341 as an example.
karma and ts_devserver rules moved to new package @bazel/concatjs
packages/karma:package.bzl
is gone, in your WORKSPACE replace
load("//packages/karma:package.bzl", "npm_bazel_karma_dependencies")
npm_bazel_karma_dependencies()
with the equivalent
http_archive(
name = "io_bazel_rules_webtesting",
sha256 = "9bb461d5ef08e850025480bab185fd269242d4e533bca75bfb748001ceb343c3",
urls = ["https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.3/rules_webtesting.tar.gz"],
)
Then in BUILD files replace
load("@npm//@bazel/karma:index.bzl", "karma_web_test_suite")
with
load("@npm//@bazel/concatjs:index.bzl", "concatjs_web_test_suite")
finally drop npm dependencies on @bazel/karma
and depend on @bazel/concatjs
instead
Removed node_modules
attribute
We removed the node_modules attribute from nodejs_binary
, nodejs_test
, jasmine_node_test
& ts_library
.
If you are using the node_modules
attribute, you can simply add the target specified there to the data
or deps
attribute of the rule instead.
For example,
nodejs_test(
name = "test",
data = [
"test.js",
"@npm//:node_modules",
],
entry_point = "test.js",
)
or
ts_library(
name = "lib",
srcs = glob(["*.ts"]),
tsconfig = ":tsconfig.json",
deps = ["@npm//:node_modules"],
)
We also dropped support for filegroup based node_modules target and removed node_modules_filegroup
from index.bzl
.
If you are using this feature for user-managed deps, you must now use a js_library
target
with external_npm_package
set to True
instead.
For example,
js_library(
name = "node_modules",
srcs = glob(
include = [
"node_modules/**/*.js",
"node_modules/**/*.d.ts",
"node_modules/**/*.json",
"node_modules/.bin/*",
],
exclude = [
# Files under test & docs may contain file names that
# are not legal Bazel labels (e.g.,
# node_modules/ecstatic/test/public/中文/檔案.html)
"node_modules/**/test/**",
"node_modules/**/docs/**",
# Files with spaces in the name are not legal Bazel labels
"node_modules/**/* */**",
"node_modules/**/* *",
],
),
# Provide ExternalNpmPackageInfo which is used by downstream rules
# that use these npm dependencies
external_npm_package = True,
)
nodejs_test(
name = "test",
data = [
"test.js",
":node_modules",
],
entry_point = "test.js",
)
See examples/user_managed_deps
for a working example of user-managed npm dependencies.
Others
- typescript: any ts_project rule that produces no outputs must be fixed or removed
- pkg_web#move_files helper is now a private API
- rollup_bundle config_file no longer has substitutions from a "bazel_stamp_file" - use bazel_version_file instead
- pkg_npm no longer has replace_with_version attribute, use substitutions instead
Bug Fixes
- builtin: add DeclarationInfo sources from dependencies as inputs to npm_package_bin driven actions (#2353) (a549411)
- builtin: --nobazel_run_linker implies --bazel_patch_module_resolver (7100277)
- remove jasmine-core as a peer dep (#2336) (bb2a302)
- builtin: give a longer timeout for _create_build_files (5d405a7), closes #2231
- builtin: give better error when linker runs on Node <10 (b9dc2c1), closes #2304
- builtin: make linker deterministic when resolving from manifest & fix link_workspace_root with no runfiles (f7c342f)
- examples: fix jest example on windows (3ffefa1), closes #1454
- exmaples/nestjs: add module_name field in ts_library (3a4155c)
- typescript: don't depend on protobufjs, it's transitive (1b344db)
- typescript: fail the build when ts_project produces zero outputs (3ca6cac), closes #2301
- npm_package.pack on Windows should not generate undefined.tgz (715ad22)
- typescript: specify rootDir as absolute path (535fa51)
- npm_package.pack should work in windows os (503d6fb)
- typescript: don't include _valid_options marker file in outs (570e34d), closes #2078
- builtin: only pass kwargs to the test, not the .update binary (#2361) (afa095b)
chore
Code Refactoring
- bazel_patch_module_resolver default to false (fdde32f), closes #1440 #2125
- make pkg_web#move_files private (815a3ca)
Features
- builtin: use npm ci as default behaviour for installing node_modules (#2328) (1d650fb), closes #159
- allow running NPM tools from execroot (#2297) (2a4ba8f)
- create symlink for build files present on node modules installed with relative paths (#2330) (6f4fc17)
- builtin: yarn install use --frozen-lockfile as default (b6a8cbb), closes #941
- builtin: flip the default of the strict_visibility flag on the n...
3.0.0-rc.1
Please upgrade to 3.0.0 instead.
To upgrade:
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "84b1d11b1f3bda68c24d992dc6e830bca9db8fa12276f2ca7fcb7761c893976b",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.0.0-rc.1/rules_nodejs-3.0.0-rc.1.tar.gz"],
)
And be sure to upgrade your @bazel
-scoped npm packages (they are tagged next
on npm)
2.3.2
Note: this is likely the last 2.x release of rules_nodejs, we expect 3.0.0 next week.
To upgrade:
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "b3521b29c7cb0c47a1a735cce7e7e811a4f80d8e3720cf3a1b624533e4bb7cb6",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/2.3.2/rules_nodejs-2.3.2.tar.gz"],
)
and update your @bazel
-scoped npm packages to latest
Bug Fixes
- builtin: add DeclarationInfo sources from dependencies as inputs to npm_package_bin driven actions (#2353) (85dc132)
- builtin: give better error when linker runs on Node <10 (c344401), closes #2304
- examples: fix jest example on windows (cc04f6c), closes #1454