anki/ts/graphs/BUILD.bazel
Damien Elmes 03f3dfa3d9 switch to full lodash library
Individual packages are going away in v5, and we can rely on tree
shaking to only get what we need.
2021-04-16 20:14:17 +10:00

113 lines
2.1 KiB
Python

load("@npm//@bazel/typescript:index.bzl", "ts_library")
load("//ts/svelte:svelte.bzl", "compile_svelte", "svelte_check")
load("//ts:prettier.bzl", "prettier_test")
load("//ts:eslint.bzl", "eslint_test")
load("//ts:esbuild.bzl", "esbuild")
load("//ts:compile_sass.bzl", "compile_sass")
compile_sass(
srcs = ["graphs-base.scss"],
group = "base_css",
visibility = ["//visibility:public"],
deps = [
"//ts/sass:base_lib",
"//ts/sass:scrollbar_lib",
],
)
svelte_files = glob(["*.svelte"])
svelte_names = [f.replace(".svelte", "") for f in svelte_files]
compile_svelte(
name = "svelte",
srcs = svelte_files,
)
ts_library(
name = "index",
srcs = ["index.ts"],
deps = [
"GraphsPage",
"lib",
"//ts/lib",
"//ts/sveltelib",
"@npm//svelte",
"@npm//svelte2tsx",
],
)
ts_library(
name = "lib",
srcs = glob(
["*.ts"],
exclude = ["index.ts"],
),
deps = [
"//ts/lib",
"//ts/lib:backend_proto",
"//ts/sveltelib",
"@npm//@types/d3",
"@npm//@types/lodash",
"@npm//d3",
"@npm//lodash-es",
"@npm//svelte",
],
)
esbuild(
name = "graphs",
srcs = [
"//ts:protobuf-shim.js",
],
args = [
"--global-name=anki",
"--inject:$(location //ts:protobuf-shim.js)",
"--resolve-extensions=.mjs,.js",
"--log-level=warning",
],
entry_point = "index.ts",
external = [
"protobufjs/light",
],
output_css = "graphs.css",
visibility = ["//visibility:public"],
deps = [
"//ts/sveltelib",
"//ts/lib",
"//ts/lib:backend_proto",
":index",
":base_css",
] + svelte_names,
)
exports_files(["graphs.html"])
# Tests
################
prettier_test(
name = "format_check",
srcs = glob([
"*.ts",
"*.svelte",
]),
)
eslint_test(
name = "eslint",
srcs = glob(
[
"*.ts",
],
),
)
svelte_check(
name = "svelte_check",
srcs = glob([
"*.ts",
"*.svelte",
]),
)