|
| 1 | +load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin") |
| 2 | +load("//tools:defaults.bzl", "esbuild", "jasmine_node_test", "pkg_npm", "spec_bundle", "ts_library") |
| 3 | + |
| 4 | +package(default_visibility = ["//visibility:public"]) |
| 5 | + |
| 6 | +STATIC_ASSETS = [ |
| 7 | + "schema.json", |
| 8 | +] |
| 9 | + |
| 10 | +ts_library( |
| 11 | + name = "m3_theme_lib", |
| 12 | + srcs = glob( |
| 13 | + ["**/*.ts"], |
| 14 | + exclude = ["**/*.spec.ts"] + ["rules/components/test-setup-helper.ts"], |
| 15 | + ), |
| 16 | + deps = [ |
| 17 | + "//src/cdk/schematics", |
| 18 | + "@npm//@angular-devkit/schematics", |
| 19 | + "@npm//@material/material-color-utilities", |
| 20 | + "@npm//@types/node", |
| 21 | + "@npm//sass", |
| 22 | + "@npm//typescript", |
| 23 | + ], |
| 24 | +) |
| 25 | + |
| 26 | +esbuild( |
| 27 | + name = "m3_theme_bundle", |
| 28 | + entry_point = ":index.ts", |
| 29 | + external = [ |
| 30 | + "@angular/cdk/schematics", |
| 31 | + "@angular/material-experimental/", |
| 32 | + "@angular-devkit/schematics", |
| 33 | + "@angular-devkit/core", |
| 34 | + "typescript", |
| 35 | + ], |
| 36 | + format = "cjs", |
| 37 | + output = "index_bundled.js", |
| 38 | + platform = "node", |
| 39 | + target = "es2015", |
| 40 | + deps = [ |
| 41 | + ":m3_theme_lib", |
| 42 | + "//src/material:sass_lib", |
| 43 | + "//src/material-experimental:sass_lib", |
| 44 | + ], |
| 45 | +) |
| 46 | + |
| 47 | +pkg_npm( |
| 48 | + name = "npm_package", |
| 49 | + srcs = STATIC_ASSETS, |
| 50 | + deps = [":m3_theme_bundle"], |
| 51 | +) |
| 52 | + |
| 53 | +######################################## |
| 54 | +# Testing configuration # |
| 55 | +######################################## |
| 56 | + |
| 57 | +ts_library( |
| 58 | + name = "unit_tests_lib", |
| 59 | + testonly = True, |
| 60 | + srcs = glob(["**/*.spec.ts"] + ["rules/components/test-setup-helper.ts"]), |
| 61 | + devmode_module = "commonjs", |
| 62 | + deps = [ |
| 63 | + ":m3_theme_lib", |
| 64 | + "//src/cdk/schematics/testing", |
| 65 | + "//tools/sass:sass_lib", |
| 66 | + "@npm//@angular-devkit/schematics", |
| 67 | + "@npm//@bazel/runfiles", |
| 68 | + "@npm//@material/material-color-utilities", |
| 69 | + "@npm//@types/jasmine", |
| 70 | + "@npm//@types/node", |
| 71 | + "@npm//sass", |
| 72 | + ], |
| 73 | +) |
| 74 | + |
| 75 | +spec_bundle( |
| 76 | + name = "unit_tests_bundle", |
| 77 | + # Exclude the `node` devkit entry-point to avoid bundling native modules like |
| 78 | + # `chokidar` and `fsevents`. These rely on native bindings and break with ESBuild. |
| 79 | + external = ["@angular-devkit/core/node"], |
| 80 | + platform = "node", |
| 81 | + target = "es2020", |
| 82 | + deps = [":unit_tests_lib"], |
| 83 | +) |
| 84 | + |
| 85 | +copy_to_bin( |
| 86 | + name = "unit_tests_assets", |
| 87 | + testonly = True, |
| 88 | + srcs = STATIC_ASSETS, |
| 89 | +) |
| 90 | + |
| 91 | +jasmine_node_test( |
| 92 | + name = "unit_tests", |
| 93 | + data = [ |
| 94 | + ":m3_theme_bundle", |
| 95 | + ":unit_tests_assets", |
| 96 | + "//src/material/schematics:collection_assets", |
| 97 | + "//src/material/schematics:ng_generate_assets", |
| 98 | + ], |
| 99 | + shard_count = 10, |
| 100 | + deps = [ |
| 101 | + ":unit_tests_bundle", |
| 102 | + # Runtime dependencies needed by the test and actual migration sources. These need |
| 103 | + # to be specified explicitly here because they are not captured by the bundling. |
| 104 | + "@npm//@schematics/angular", |
| 105 | + "//src/material:sass_lib", |
| 106 | + "//src/material-experimental:sass_lib", |
| 107 | + ], |
| 108 | +) |
0 commit comments