From b9b36170f7a3e2cb6544531f324bdebea6a22b02 Mon Sep 17 00:00:00 2001 From: Rene Buchmayer Date: Wed, 7 Oct 2020 15:13:54 +0200 Subject: [PATCH] build(event-chart): Bazelify event-chart component. --- angular.json | 7 -- .../event-chart/BUILD.bazel | 93 ++++++++++++++++++- .../event-chart/jest.config.js | 21 ----- .../event-chart/jest.config.json | 8 ++ .../event-chart/tsconfig.json | 2 +- .../event-chart/tsconfig.lib.json | 8 -- 6 files changed, 101 insertions(+), 38 deletions(-) delete mode 100644 libs/barista-components/event-chart/jest.config.js create mode 100644 libs/barista-components/event-chart/jest.config.json diff --git a/angular.json b/angular.json index c5adf7d613..5befbffe50 100644 --- a/angular.json +++ b/angular.json @@ -1533,13 +1533,6 @@ "!libs/barista-components/event-chart/**/*" ] } - }, - "test": { - "builder": "@nrwl/jest:jest", - "options": { - "jestConfig": "libs/barista-components/event-chart/jest.config.js", - "passWithNoTests": true - } } }, "schematics": {} diff --git a/libs/barista-components/event-chart/BUILD.bazel b/libs/barista-components/event-chart/BUILD.bazel index 72205aa7f9..3ca719567c 100644 --- a/libs/barista-components/event-chart/BUILD.bazel +++ b/libs/barista-components/event-chart/BUILD.bazel @@ -1,7 +1,40 @@ -load("//tools/bazel_rules:index.bzl", "stylelint") +load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library") +load("@npm//@bazel/typescript:index.bzl", "ts_config") +load("//tools/bazel_rules:index.bzl", "jest", "ng_module_view_engine", "stylelint") package(default_visibility = ["//visibility:public"]) +ng_module_view_engine( + name = "compile", + srcs = glob( + include = ["**/*.ts"], + exclude = [ + "**/*.spec.ts", + "src/test-setup.ts", + ], + ), + angular_assets = [ + ":styles", + ":styles_legend", + "src/event-chart-legend.html", + "src/event-chart.html", + ], + module_name = "@dynatrace/barista-components/event-chart", + tsconfig = "tsconfig_lib", + deps = [ + "//libs/barista-components/core:compile", + "//libs/barista-components/formatters:compile", + "//libs/barista-components/legend:compile", + "//libs/barista-components/overlay:compile", + "@npm//@angular/core", + "@npm//@angular/cdk", + "@npm//@angular/common", + "@npm//rxjs", + "@npm//@types/d3-scale", + "@npm//d3-scale", + ], +) + filegroup( name = "event-chart", srcs = glob( @@ -16,7 +49,65 @@ filegroup( ]), ) +sass_binary( + name = "styles", + src = "src/event-chart.scss", + deps = ["styles_lib_constants"] +) + +sass_binary( + name = "styles_legend", + src = "src/event-chart-legend.scss", + deps = ["styles_lib_constants"] +) + +sass_library( + name = "styles_lib_constants", + srcs = ["src/_event-chart-constants.scss"], +) + stylelint( name = "stylelint", srcs = glob(["**/*.scss"]), ) + +jest( + name = "test", + srcs = glob(include = ["**/*.spec.ts"]), + jest_config = ":jest.config.json", + setup_file = ":src/test-setup.ts", + ts_config = ":tsconfig_test", + deps = [ + ":compile", + "//libs/testing/browser", + "@npm//@angular/platform-browser", + "//libs/barista-components/core:compile", + "//libs/barista-components/formatters:compile", + "//libs/barista-components/legend:compile", + "//libs/barista-components/overlay:compile", + "@npm//@angular/core", + "@npm//@angular/cdk", + "@npm//@angular/common", + "@npm//rxjs", + "@npm//@types/d3-scale", + "@npm//d3-scale", + ], +) + +ts_config( + name = "tsconfig_lib", + src = "tsconfig.lib.json", + deps = [ + "tsconfig.json", + "//libs/barista-components:tsconfig", + ], +) + +ts_config( + name = "tsconfig_test", + src = "tsconfig.spec.json", + deps = [ + "tsconfig.json", + "//libs/barista-components:tsconfig", + ], +) diff --git a/libs/barista-components/event-chart/jest.config.js b/libs/barista-components/event-chart/jest.config.js deleted file mode 100644 index c2d485a7da..0000000000 --- a/libs/barista-components/event-chart/jest.config.js +++ /dev/null @@ -1,21 +0,0 @@ -module.exports = { - name: 'event-chart', - preset: '../../../jest.config.js', - coverageDirectory: '../../../coverage/components/event-chart', - snapshotSerializers: [ - 'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js', - 'jest-preset-angular/build/AngularSnapshotSerializer.js', - 'jest-preset-angular/build/HTMLCommentSerializer.js', - ], - setupFilesAfterEnv: ['/src/test-setup.ts'], - globals: { - 'ts-jest': { - tsConfig: '/tsconfig.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - astTransformers: [ - 'jest-preset-angular/build/InlineFilesTransformer', - 'jest-preset-angular/build/StripStylesTransformer', - ], - }, - }, -}; diff --git a/libs/barista-components/event-chart/jest.config.json b/libs/barista-components/event-chart/jest.config.json new file mode 100644 index 0000000000..ad9e948831 --- /dev/null +++ b/libs/barista-components/event-chart/jest.config.json @@ -0,0 +1,8 @@ +{ + "name": "event-chart", + "snapshotSerializers": [ + "jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js", + "jest-preset-angular/build/AngularSnapshotSerializer.js", + "jest-preset-angular/build/HTMLCommentSerializer.js" + ] +} diff --git a/libs/barista-components/event-chart/tsconfig.json b/libs/barista-components/event-chart/tsconfig.json index 1b6ee0bf6f..c8711dad2f 100644 --- a/libs/barista-components/event-chart/tsconfig.json +++ b/libs/barista-components/event-chart/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../../tsconfig.base.json", + "extends": "../tsconfig.json", "compilerOptions": { "types": ["node", "jest"] }, diff --git a/libs/barista-components/event-chart/tsconfig.lib.json b/libs/barista-components/event-chart/tsconfig.lib.json index 94cf26a99e..4152dd407a 100644 --- a/libs/barista-components/event-chart/tsconfig.lib.json +++ b/libs/barista-components/event-chart/tsconfig.lib.json @@ -8,14 +8,6 @@ "types": [], "lib": ["dom", "es2018"] }, - "angularCompilerOptions": { - "annotateForClosureCompiler": true, - "skipTemplateCodegen": true, - "strictMetadataEmit": true, - "fullTemplateTypeCheck": true, - "strictInjectionParameters": true, - "enableResourceInlining": true - }, "exclude": ["src/test-setup.ts", "**/*.spec.ts"], "include": ["**/*.ts"] }