1
1
load ("@npm//@bazel/typescript:index.bzl" , "ts_project" )
2
2
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" )
5
4
6
5
# Allow any ts_library rules in this workspace to reference the config
7
6
# Note: if you move the tsconfig.json file to a subdirectory, you can add an alias() here instead
@@ -15,92 +14,78 @@ exports_files(
15
14
ts_project (
16
15
name = "tsc" ,
17
16
tsconfig = "tsconfig.json" ,
18
- deps = ["@npm//big-integer" , "@npm//@types/node" ],
17
+ deps = [
18
+ "@npm//@types/node" ,
19
+ "@npm//big-integer" ,
20
+ ],
19
21
)
20
22
21
23
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" ],
24
26
)
25
27
26
28
# recommendation online seems to be to NOT minify NPM packages, because they are
27
29
# loaded "locally" and they are part of larger pipelines that usually
28
30
# minify things "down the line"
29
31
esbuild (
30
- name = "algebrite" ,
31
- deps = [":tsc" ],
32
+ name = "algebrite" ,
32
33
entry_point = "index.ts" ,
33
- platform = "node" ,
34
34
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" ],
41
38
)
42
39
43
40
# let's also copy the sourcemaps. They are only loaded when opening the dev tools
44
41
# and they actually show the original code file-by-file, which could be useful
45
42
genrule (
46
- name = "copy-to-dist-bundle-for-browser-min" ,
43
+ name = "copy-to-dist-bundle-for-browser-min" ,
47
44
srcs = ["algebrite.bundle-for-browser-min.js" ],
48
45
outs = ["copy-to-dist-bundle-for-browser-min.txt" ],
49
46
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 ." ,
50
47
local = 1 , # required
51
48
)
52
49
53
50
genrule (
54
- name = "copy-to-dist-bundle-for-browser" ,
51
+ name = "copy-to-dist-bundle-for-browser" ,
55
52
srcs = ["algebrite.bundle-for-browser.js" ],
56
53
outs = ["copy-to-dist-bundle-for-browser.txt" ],
57
54
cmd = "echo 'done' > $(OUTS) ; cd dist ; rm -f algebrite.bundle-for-browser.js ; cp bin/algebrite.bundle-for-browser.js ." ,
58
55
local = 1 , # required
59
56
)
60
57
61
58
genrule (
62
- name = "copy-to-dist-index-runtime-sources" ,
59
+ name = "copy-to-dist-index-runtime-sources" ,
63
60
srcs = ["index.js" ],
64
61
outs = ["copy-to-dist-index-runtime-sources.txt" ],
65
62
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 ." ,
66
63
local = 1 , # required
67
64
)
68
65
69
-
70
-
71
66
esbuild (
72
- name = "algebrite.bundle-for-browser-min" ,
73
- deps = [":tsc" ],
67
+ name = "algebrite.bundle-for-browser-min" ,
74
68
entry_point = ":copy_browser_main" ,
75
69
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" ],
83
73
)
84
74
85
75
esbuild (
86
- name = "algebrite.bundle-for-browser" ,
87
- deps = [":tsc" ],
76
+ name = "algebrite.bundle-for-browser" ,
88
77
entry_point = ":copy_browser_main" ,
89
78
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" ],
97
82
)
98
83
99
84
pkg_npm (
100
- name = "npm" ,
85
+ name = "npm" ,
86
+ package_name = "algebrite" ,
101
87
srcs = ["package.json" ],
102
88
deps = [
103
- ":tsc" ,
104
89
":algebrite" ,
105
90
":algebrite.bundle-for-browser-min" ,
106
91
":algebrite.bundle-for-browser" ,
@@ -115,7 +100,7 @@ pkg_npm(
115
100
# this is for the so called "module" npm deliverable
116
101
# see https://stackoverflow.com/questions/42708484/what-is-the-module-package-json-field-for
117
102
":copy-to-dist-index-runtime-sources" ,
118
- ]
103
+ ],
119
104
)
120
105
121
106
nodejs_test (
@@ -277,8 +262,8 @@ nodejs_test(
277
262
":tsc" ,
278
263
"@npm//big-integer" ,
279
264
],
280
- shard_count = 16 ,
281
265
entry_point = ":tests/roots.ts" ,
266
+ shard_count = 16 ,
282
267
)
283
268
284
269
nodejs_test (
0 commit comments