blob: 30ca257758639db38bab864c02cad7a3fc6e36e4 [file]
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_web")
load("@npm//@babel/cli:index.bzl", "babel")
load("//internal/node:context.bzl", "node_context_data")
load("//packages/jasmine:index.bzl", "jasmine_node_test")
load("//packages/rollup:index.bzl", "rollup_bundle")
load("//packages/terser:index.bzl", "terser_minified")
load("//packages/typescript:index.bzl", "ts_library")
package(default_visibility = ["//visibility:public"])
ts_library(
name = "script",
srcs = ["script.ts"],
)
rollup_bundle(
name = "bundle",
entry_point = ":script.ts",
sourcemap = "true",
deps = [":script"],
)
babel(
name = "bundle.es2015",
outs = [
"bundle.es2015.js",
"bundle.es2015.js.map",
],
args = [
"$(execpath :bundle.js)",
"--no-babelrc",
"--source-maps",
"--presets=@babel/preset-env",
"--out-file",
"$(execpath :bundle.es2015.js)",
],
data = [
"bundle.js",
"bundle.js.map",
"@npm//@babel/preset-env",
],
)
terser_minified(
name = "bundle.min",
src = ":bundle",
)
terser_minified(
name = "bundle.min_debug",
src = ":bundle",
debug = True,
)
terser_minified(
name = "bundle.min.es2015",
src = ":bundle.es2015.js",
)
terser_minified(
name = "bundle.min_debug.es2015",
src = ":bundle.es2015.js",
debug = True,
)
node_context_data(
name = "force_stamp",
stamp = True,
)
pkg_web(
name = "pkg",
srcs = [
"index.html",
":bundle",
":bundle.es2015",
":bundle.min",
":bundle.min.es2015",
":bundle.min_debug",
":bundle.min_debug.es2015",
],
node_context_data = ":force_stamp",
substitutions = {
"${version}": "{BUILD_SCM_VERSION}",
},
)
jasmine_node_test(
name = "test",
srcs = ["spec.js"],
data = [":pkg"],
)