Skip to content

Commit 75b58cf

Browse files
authored
Merge pull request #157 from derivita/bazel-4.2.2
Upgrade bazel and rules_nodejs.
2 parents 581127b + 030f617 commit 75b58cf

File tree

9 files changed

+17755
-20054
lines changed

9 files changed

+17755
-20054
lines changed

.bazelrc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ build:debug --compilation_mode=dbg
6161
# This prevents accidentally depending on this feature, which Bazel will remove.
6262
build --nolegacy_external_runfiles
6363

64-
# Turn on the "Managed Directories" feature.
65-
# This allows Bazel to share the same node_modules directory with other tools
66-
# NB: this option was introduced in Bazel 0.26
67-
# See https://docs.bazel.build/versions/master/command-line-reference.html#flag--experimental_allow_incremental_repository_updates
68-
common --experimental_allow_incremental_repository_updates
6964

7065
# Turn on --incompatible_strict_action_env which was on by default
7166
# in Bazel 0.21.0 but turned off again in 0.22.0. Follow

.bazelversion

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
3.0.0
2-
1+
4.2.2

BUILD.bazel

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
load("@npm//@bazel/typescript:index.bzl", "ts_project")
22
load("@npm//@bazel/esbuild:index.bzl", "esbuild")
3-
load("gen_tests.bzl", "gen_tests")
4-
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test", "pkg_npm", "copy_to_bin")
3+
load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin", "nodejs_test", "pkg_npm")
54

65
# Allow any ts_library rules in this workspace to reference the config
76
# Note: if you move the tsconfig.json file to a subdirectory, you can add an alias() here instead
@@ -15,92 +14,78 @@ exports_files(
1514
ts_project(
1615
name = "tsc",
1716
tsconfig = "tsconfig.json",
18-
deps = ["@npm//big-integer", "@npm//@types/node"],
17+
deps = [
18+
"@npm//@types/node",
19+
"@npm//big-integer",
20+
],
1921
)
2022

2123
copy_to_bin(
22-
name="copy_browser_main",
23-
srcs=["sources/browser_main.js"],
24+
name = "copy_browser_main",
25+
srcs = ["sources/browser_main.js"],
2426
)
2527

2628
# recommendation online seems to be to NOT minify NPM packages, because they are
2729
# loaded "locally" and they are part of larger pipelines that usually
2830
# minify things "down the line"
2931
esbuild(
30-
name="algebrite",
31-
deps=[":tsc"],
32+
name = "algebrite",
3233
entry_point = "index.ts",
33-
platform = "node",
3434
external = ["big-integer"],
35-
tool = select({
36-
"@bazel_tools//src/conditions:darwin": "@esbuild_darwin//:bin/esbuild",
37-
"@bazel_tools//src/conditions:windows": "@esbuild_windows//:esbuild.exe",
38-
"@bazel_tools//src/conditions:linux_x86_64": "@esbuild_linux//:bin/esbuild",
39-
}),
40-
visibility=["//visibility:public"],
35+
platform = "node",
36+
visibility = ["//visibility:public"],
37+
deps = [":tsc"],
4138
)
4239

4340
# let's also copy the sourcemaps. They are only loaded when opening the dev tools
4441
# and they actually show the original code file-by-file, which could be useful
4542
genrule(
46-
name="copy-to-dist-bundle-for-browser-min",
43+
name = "copy-to-dist-bundle-for-browser-min",
4744
srcs = ["algebrite.bundle-for-browser-min.js"],
4845
outs = ["copy-to-dist-bundle-for-browser-min.txt"],
4946
cmd = "echo 'done' > $(OUTS) ; cd dist ; rm -f algebrite.bundle-for-browser-min.js ; rm -f algebrite.bundle-for-browser-min.js.map ; cp bin/algebrite.bundle-for-browser-min.js . ; cp bin/algebrite.bundle-for-browser-min.js.map .",
5047
local = 1, # required
5148
)
5249

5350
genrule(
54-
name="copy-to-dist-bundle-for-browser",
51+
name = "copy-to-dist-bundle-for-browser",
5552
srcs = ["algebrite.bundle-for-browser.js"],
5653
outs = ["copy-to-dist-bundle-for-browser.txt"],
5754
cmd = "echo 'done' > $(OUTS) ; cd dist ; rm -f algebrite.bundle-for-browser.js ; cp bin/algebrite.bundle-for-browser.js .",
5855
local = 1, # required
5956
)
6057

6158
genrule(
62-
name="copy-to-dist-index-runtime-sources",
59+
name = "copy-to-dist-index-runtime-sources",
6360
srcs = ["index.js"],
6461
outs = ["copy-to-dist-index-runtime-sources.txt"],
6562
cmd = "echo 'done' > $(OUTS) ; cd dist ; rm -rf index.js ; rm -rf runtime ; rm -rf sources ; cp bin/index.js index.js ; cp -r bin/runtime . ; cp -r bin/sources .",
6663
local = 1, # required
6764
)
6865

69-
70-
7166
esbuild(
72-
name="algebrite.bundle-for-browser-min",
73-
deps=[":tsc"],
67+
name = "algebrite.bundle-for-browser-min",
7468
entry_point = ":copy_browser_main",
7569
minify = True,
76-
target = "safari13,chrome87,firefox85",
77-
tool = select({
78-
"@bazel_tools//src/conditions:darwin": "@esbuild_darwin//:bin/esbuild",
79-
"@bazel_tools//src/conditions:windows": "@esbuild_windows//:esbuild.exe",
80-
"@bazel_tools//src/conditions:linux_x86_64": "@esbuild_linux//:bin/esbuild",
81-
}),
82-
visibility=["//visibility:public"],
70+
target = "safari13",
71+
visibility = ["//visibility:public"],
72+
deps = [":tsc"],
8373
)
8474

8575
esbuild(
86-
name="algebrite.bundle-for-browser",
87-
deps=[":tsc"],
76+
name = "algebrite.bundle-for-browser",
8877
entry_point = ":copy_browser_main",
8978
minify = False,
90-
target = "safari13,chrome87,firefox85",
91-
tool = select({
92-
"@bazel_tools//src/conditions:darwin": "@esbuild_darwin//:bin/esbuild",
93-
"@bazel_tools//src/conditions:windows": "@esbuild_windows//:esbuild.exe",
94-
"@bazel_tools//src/conditions:linux_x86_64": "@esbuild_linux//:bin/esbuild",
95-
}),
96-
visibility=["//visibility:public"],
79+
target = "safari13",
80+
visibility = ["//visibility:public"],
81+
deps = [":tsc"],
9782
)
9883

9984
pkg_npm(
100-
name="npm",
85+
name = "npm",
86+
package_name = "algebrite",
10187
srcs = ["package.json"],
10288
deps = [
103-
":tsc",
10489
":algebrite",
10590
":algebrite.bundle-for-browser-min",
10691
":algebrite.bundle-for-browser",
@@ -115,7 +100,7 @@ pkg_npm(
115100
# this is for the so called "module" npm deliverable
116101
# see https://stackoverflow.com/questions/42708484/what-is-the-module-package-json-field-for
117102
":copy-to-dist-index-runtime-sources",
118-
]
103+
],
119104
)
120105

121106
nodejs_test(
@@ -277,8 +262,8 @@ nodejs_test(
277262
":tsc",
278263
"@npm//big-integer",
279264
],
280-
shard_count = 16,
281265
entry_point = ":tests/roots.ts",
266+
shard_count = 16,
282267
)
283268

284269
nodejs_test(

WORKSPACE.bazel

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,50 +13,24 @@ workspace(
1313
# Install the nodejs "bootstrap" package
1414
# This provides the basic tools for running and packaging nodejs programs in Bazel
1515
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
16+
1617
http_archive(
1718
name = "build_bazel_rules_nodejs",
18-
sha256 = "f533eeefc8fe1ddfe93652ec50f82373d0c431f7faabd5e6323f6903195ef227",
19-
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.3.0/rules_nodejs-3.3.0.tar.gz"],
19+
sha256 = "cfc289523cf1594598215901154a6c2515e8bf3671fd708264a6f6aefe02bf39",
20+
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.4.6/rules_nodejs-4.4.6.tar.gz"],
2021
)
2122

2223
# The npm_install rule runs yarn anytime the package.json or package-lock.json file changes.
2324
# It also extracts any Bazel rules distributed in an npm package.
2425
load("@build_bazel_rules_nodejs//:index.bzl", "npm_install")
26+
2527
npm_install(
2628
# Name this npm so that Bazel Label references look like @npm//package
2729
name = "npm",
2830
package_json = "//:package.json",
2931
package_lock_json = "//:package-lock.json",
3032
)
3133

34+
load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories")
3235

33-
_ESBUILD_VERSION = "0.11.5" # reminder: update SHAs below when changing this value
34-
http_archive(
35-
name = "esbuild_darwin",
36-
urls = [
37-
"https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-%s.tgz" % _ESBUILD_VERSION,
38-
],
39-
strip_prefix = "package",
40-
build_file_content = """exports_files(["bin/esbuild"])""",
41-
sha256 = "98436890727bdb0d4beddd9c9e07d0aeff0e8dfe0169f85e568eca0dd43f665e",
42-
)
43-
44-
http_archive(
45-
name = "esbuild_windows",
46-
urls = [
47-
"https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-%s.tgz" % _ESBUILD_VERSION,
48-
],
49-
strip_prefix = "package",
50-
build_file_content = """exports_files(["esbuild.exe"])""",
51-
sha256 = "589c8ff97210bd41de106e6317ce88f9e88d2cacfd8178ae1217f2b857ff6c3a",
52-
)
53-
54-
http_archive(
55-
name = "esbuild_linux",
56-
urls = [
57-
"https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-%s.tgz" % _ESBUILD_VERSION,
58-
],
59-
strip_prefix = "package",
60-
build_file_content = """exports_files(["bin/esbuild"])""",
61-
sha256 = "113c2e84895f4422a3676db4e15d9f01b2b4fac041edab25284fdb9574ba58a0",
62-
)
36+
esbuild_repositories(npm_repository = "npm")

dist/algebrite.bundle-for-browser-min.js

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)