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

exports_files(["tsconfig.json"])

# NOTE: this will move to node_modules/BUILD in a later release
filegroup(
    name = "node_modules",
    # NB: rxjs is not in this list, because we build it from sources using the
    # label @rxjs//:rxjs
    srcs = glob(["/".join([
        "node_modules",
        pkg,
        "**",
        ext,
    ]) for pkg in [
        "@angular",
        "@nrwl",
        "@ngrx",
        "tsickle",
        "tsutils",
        "typescript",
        "@types",
    ] for ext in [
        "*.js",
        "*.json",
        "*.d.ts",
    ]] + [
        "node_modules/http-server/**",
    ]),
)

ANGULAR_TESTING = [
    "node_modules/@angular/*/bundles/*-testing.umd.js",
    # We use AOT, so the compiler and the dynamic platform-browser should be
    # visible only in tests
    "node_modules/@angular/compiler/bundles/*.umd.js",
    "node_modules/@angular/platform-browser-dynamic/bundles/*.umd.js",
]

# TODO: it's messy for users to need to specify the following
# Angular dependency lists. It should live somewhere else.
# See https://github.com/angular/angular/issues/21048

filegroup(
    name = "angular_bundles",
    srcs = glob(
        [
            "node_modules/@angular/*/bundles/*.umd.js",

            "node_modules/@ngrx/store/bundles/store.umd.js",
            "node_modules/@ngrx/router-store/bundles/router-store.umd.js",
            "node_modules/@ngrx/effects/bundles/effects.umd.js",

            "node_modules/@nrwl/nx/bundles/nrwl-nx.umd.js",
        ],
        exclude = ANGULAR_TESTING + [
            "node_modules/@angular/bazel/**/*",
            "node_modules/@angular/cli/**/*",
            "node_modules/@angular/compiler-cli/**/*",
            "node_modules/@angular/language-service/**/*",
        ],
    ),
)

filegroup(
    name = "angular_test_bundles",
    testonly = 1,
    srcs = glob(ANGULAR_TESTING),
)

filegroup(
    name = "angular_bootstrap_scripts",
    # do not sort
    srcs = [
        "//:node_modules/zone.js/dist/zone.min.js",
        "//:node_modules/zone.js/dist/async-test.js",
        "//:node_modules/zone.js/dist/sync-test.js",
        "//:node_modules/zone.js/dist/proxy.min.js",
        "//:node_modules/zone.js/dist/jasmine-patch.js",
    ],
)
