package(default_visibility = ["//visibility:public"])

load("@angular//:index.bzl", "ng_module", "ng_package")
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_binary")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test_suite")

sass_binary(
    name = "hello-world-styles",
    src = "hello-world.component.scss",
)

ng_module(
    name = "hello-world",
    srcs = glob(
        ["*.ts"],
        exclude = ["*.spec.ts"],
    ),
    assets = [":hello-world-styles"],
    deps = [
        "@angular//packages/core",
        "@npm//@types",
    ],
)

ng_package(
    name = "npm_package",
    entry_point = "src/hello-world/index.js",
    deps = [":hello-world"],
)

ts_library(
    name = "test_lib",
    testonly = 1,
    srcs = glob(["*.spec.ts"]),
    deps = [
        ":hello-world",
        "@angular//packages/core",
        "@angular//packages/core/testing",
        "@angular//packages/platform-browser",
        "@angular//packages/platform-browser-dynamic/testing",
        "@npm//@types",
        "@npm//jasmine",
    ],
)

ts_web_test_suite(
    name = "test",
    srcs = ["@npm//node_modules/tslib:tslib.js"],
    bootstrap = [
        "@npm//node_modules/zone.js:dist/zone-testing-bundle.js",
        "@npm//node_modules/reflect-metadata:Reflect.js",
    ],
    browsers = [
        "@io_bazel_rules_webtesting//browsers:chromium-local",
        # TODO(gregmagolan): re-enable firefox testing once fixed
        # See https://github.com/bazelbuild/rules_typescript/issues/296
        # "@io_bazel_rules_webtesting//browsers:firefox-local",
    ],
    deps = [
        ":test_lib",
    ],
)
