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

load("//tools:defaults.bzl", "ng_module", "ng_package")

ng_module(
    name = "core",
    srcs = glob(
        [
            "*.ts",
            "src/**/*.ts",
        ],
        exclude = ["src/ivy_switch.ts"],
    ) + [
        ":ivy_switch",
    ],
    module_name = "@angular/core",
    deps = [
        "//packages:types",
        "//packages/compiler",
        "@rxjs",
        "@rxjs//operators",
    ],
)

ng_package(
    name = "npm_package",
    srcs = glob(["**/*.externs.js"]) + [
        "package.json",
        "//packages/core/testing:package.json",
    ],
    entry_point = "packages/core/index.js",
    tags = [
        "ivy-jit",
        "ivy-local",
        "release-with-framework",
    ],
    deps = [
        ":core",
        "//packages/core/testing",
    ],
)

## Controls if Ivy is enabled. (Temporary target until we permanently switch over to Ivy)
##
## This file generates `src/ivy_switch.ts` file which reexports symbols for `ViewEngine` or `Ivy.`
## - append `--define=compile=legacy` (default) to `bazel` command to reexport `./ivy_switch_legacy`
##   and use `ViewEngine`
## - append `--define=compile=jit` to `bazel` command to rexport `./ivy_switch_jit` and use `Ivy`
## - append `--define=compile=local` to `bazel` command to rexport `./ivy_switch_jit` and use `Ivy`
##   in the local analysis mode. (run as part of `ngtsc`)
##
## NOTE: `--define=compile=jit` works with any `bazel` command or target across the repo.
##
## See: `//tools/bazel.rc` where `--define=ivy=false` is defined as default.
## See: `./src/ivy_switch.ts` for more details.
genrule(
    name = "ivy_switch",
    outs = ["src/ivy_switch.ts"],
    cmd = "echo export '*' from \"'./ivy_switch_$(compile)';\" > $@",
)
