v2.0.0
This is our first semver-major release since 1.0 and has some breaking changes.
These are documented in the rules_js 2.0 migration guide.
Note that you'll need to upgrade other rules that depend on rules_js at the same time.
There is a known issue with usage on Windows: #1739
If you use rules_js on Windows we'd love to know about it. Having active users justifies prioritizing the fix.
Using Bzlmod (recommended):
Add to your MODULE.bazel
file:
bazel_dep(name = "aspect_rules_js", version = "2.0.0")
####### Node.js version #########
# By default you get the node version from DEFAULT_NODE_VERSION in @rules_nodejs//nodejs:repositories.bzl
# Optionally you can pin a different node version:
bazel_dep(name = "rules_nodejs", version = "6.2.0")
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
node.toolchain(node_version = "16.14.2")
#################################
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
npm.npm_translate_lock(
name = "npm",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")
pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm")
# Allows developers to use the matching pnpm version, for example:
# bazel run -- @pnpm --dir /home/runner/work/rules_js/rules_js install
use_repo(pnpm, "pnpm")
Using WORKSPACE
Paste this snippet into your WORKSPACE
file:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "aspect_rules_js",
sha256 = "6b7e73c35b97615a09281090da3645d9f03b2a09e8caa791377ad9022c88e2e6",
strip_prefix = "rules_js-2.0.0",
url = "https://github.com/aspect-build/rules_js/releases/download/v2.0.0/rules_js-v2.0.0.tar.gz",
)
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
rules_js_dependencies()
load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains")
rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION)
load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")
npm_translate_lock(
name = "npm",
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
load("@npm//:repositories.bzl", "npm_repositories")
npm_repositories()
What's Changed
- chore: update aspect.dev URL references to aspect.build by @gregmagolan in #1747
- chore: add pnpm versions 8.15.4 through 9.1.1 by @gregmagolan in #1730
- test: generate fresh lockfile each time for pnpm lockfile test by @jbedard in #1750
- refactor: normalize pnpm lockfile data in parser by @jbedard in #1735
- Fix typo in onlyBuiltDependencies by @surma in #1752
- chore: bump miminum dep to aspect_bazel_lib 2.7.6 by @gregmagolan in #1755
- refactor: simplify handling of #423, package aliases by @jbedard in #1757
- refactor: move npm_registry_url to utils by @jbedard in #1758
- refactor: do not include registry url in package keys by @jbedard in #1759
- feat: add include_npm_sources to npm_package by @gregmagolan in #1760
- docs: update section on "Exec failed due to IOException" by @fmeum in #1761
- fix: include package store directory in default output of npm_link_package_store by @gregmagolan in #1762
- chore: bump minimum aspect_bazel_lib to 2.7.7 by @gregmagolan in #1763
- test: add lockfile test cases by @jbedard in #1764
- chore: automate pnpm version mirroring by @alexeagle in #1766
- fix(pnpm): support pnpm9 URL, github version package versions by @jbedard in #1765
- fix(pnpm): support npm: alias dependencies with pnpm lockfile v5 by @jbedard in #1767
- chore: bump to rules_oci 1.7.6 by @gregmagolan in #1768
- refactor: sort generated npm_translate_lock store targets by @jbedard in #1769
- fix(pnpm): support npm: aliases to packages in alternate registries by @jbedard in #1770
- fix(pnpm): npm aliases to url specifiers by @jbedard in #1772
- test: add test cases for individual pnpm lockfile issues by @jbedard in #1773
- refactor(pnpm): remove .parse_pnpm_package_key util by @jbedard in #1774
- fix(pnpm): pnpm9 transitive npm: dependenies by @jbedard in #1775
- fix(pnpm): pnpm9 npm: dependencies with peers by @jbedard in #1776
- refactor: remote non-functional exclude_declarations_from_npm_packages alias by @gregmagolan in #1778
- Changes by create-pull-request action by @github-actions in #1771
- refactor(pnpm): move pnpm parsing logic to pnpm.bzl by @jbedard in #1777
- Changes by create-pull-request action by @github-actions in #1779
- fix: fix issue with bzlmod toolchain registration by bumping minimum rules_nodejs to 6.1.2 by @gregmagolan in #1780
- chore: fixup pattern for try-import of user.bazelrc by @gregmagolan in #1789
- perf: do not put files_runfiles in files + transitive_files by @jbedard in #1782
- perf: avoid cloning data_files when not copy_data_files_to_bin by @jbedard in #1783
- perf: avoid large temp arrays, use single loop by @jbedard in #1784
- perf: avoid js_info param validation on default values by @jbedard in #1785
- chore: bump minimum rules_nodejs to 6.2.0 by @gregmagolan in #1792
- chore: fixup load statement ordering in generated bzl by @gregmagolan in #1795
- fix: handle malformed npm packages gracefully in extract action by @gregmagolan in #1794
- perf: minimize cost of checking bazel version by @dzbarsky in #1800
- perf: use string.elems for char iteration by @DavidZbarsky-at in #1802
- Changes by create-pull-request action by @github-actions in #1804
- [perf] Optimize npm_package_store by @DavidZbarsky-at in #1801
- Optimize _is_gnu_tar check by @DavidZbarsky-at in #1807
- refactor: remove optional empty depset direct by @jbedard in #1790
- perf: do not check JsInfo hasattr for always-set attributes by @jbedard in #1786
- perf: only validate deprecated js_info params when extra params specified by @jbedard in #1799
- refactor: sort lock translation action cache content by @jbedard in #1796
- perf: do not include sources,types when transitive_sources,type already included by @jbedard in #1803
- perf: reduce use of bazel_skylib paths.join by @jbedard in #1812
- Changes by create-pull-request action by @github-actions in #1809
- perf: do not double process lifecycle_hooks* attributes in bzlmod by @jbedard in #1805
- perf: change js_helpers gather_* utils to accept list, not depset by @jbedard in #1787
- refactor: change npm_import(is_gnu_tar) to system_tar by @jbedard in #1811
- perf: Allow opting out of arg/env expansion by @DavidZbarsky-at in #1810
- test: npm: dependencies by @jbedard in #1815
- perf: remove unused template vars by @jbedard in #1819
- fix: use .cjs extension for fs patches by @jbedard in #1818
- fix(pnpm): npm: aliases to packages with peer deps by @jbedard in #1824
- refactor(pnpm): strip special characters from pkg labels by @jbedard in #1821
- refactor: remove unused peer_dependencies field by @jbedard in #1826
- perf: reduce string concatenation in lockfile parsing by @jbedard in #1817
- chore(deps): update aspect by @renovate in #1631
- chore(deps): update bazel rulesets by @renovate in #1633
- Revert "chore(deps): update bazel (#1633)" by @jbedard in #1831
- Revert "chore(deps): update aspect rulesets (#1631)" by @jbedard in #1833
- test: align pnpm_workspace[_rerooted] tests by @jbedard in #1832
- refactor: cleanup npm_package_store.bzl by @jbedard in #1834
- fix: transitive js_library npm package deps by @jbedard in #1836
- perf: reduce use of starlark .split by @jbedard in #1820
- chore: remove stray TODO by @alexeagle in #1839
- Changes by create-pull-request action by @github-actions in #1841
- test(pnpm): normalize typescript version across lockfile version tests by @jbedard in #1845
- fix(pnpm): npm: aliases to self by @jbedard in #1846
- Changes by create-pull-request action by @github-actions in #1851
- test: consuming linked js_library vs npm_package by @jbedard in #1852
- test: strip system dependent system_tar attribute from repositories.bzl snapshot by @jbedard in #1856
- Changes by create-pull-request action by @github-actions in #1861
- test: add additional npm: dependency lockfile tests by @jbedard in #1854
- fix(npm): invalid export of package/resolved.json by @jbedard in #1855
- test(npm): add tests for odd package names by @jbedard in #1860
- test: include package.json files in npm_translate_lock(data) by @jbedard in #1853
- refactor(npm): change string template var from overused "name" to "pkg" by @jbedard in #1867
- test: remove platform specific system_tar from test snapshots by @jbedard in #1866
- perf(npm): reduce package_name() calls by @jbedard in #1864
- perf(npm): reduce use of string.split by @jbedard in #1865
- fix(npm): expost package_json.bzl and resolved.json for each package alias by @jbedard in #1857
- refactor: remove pkg_glob api by @jbedard in #1862
- perf(npm): reduce array concatenation by @jbedard in #1859
- test(npm): add test using git+ssh protocol in version by @jbedard in #1868
- fix: do not put sources+types into NpmPackageStoreInfo.files by @jbedard in #1850
- fix(npm): npm_link_package() in subdirectory to js_library() package by @jbedard in #1871
- fix: handle js_library 1p deps correctly in js_run_devserver by @gregmagolan in #1872
- fix: delete old files & folders on each js_run_devserver sync by @gregmagolan in #1873
- Use canonical repo name for cross-repo
npm_translate_lock
by @fmeum in #1876 - perf: do not sanitize npm package labels multiple times by @jbedard in #1822
- Changes by create-pull-request action by @github-actions in #1878
- docs(npm): document support for pnpm9 by @jbedard in #1882
- chore: docs updates for 2.0 by @alexeagle in #1887
- test: add npm_translate_lock_replace_packages by @jbedard in #1888
New Contributors
- @surma made their first contribution in #1752
- @fmeum made their first contribution in #1761
- @github-actions made their first contribution in #1771
- @DavidZbarsky-at made their first contribution in #1802
Full Changelog: v1.42.3...v2.0.0