Skip to content

Commit 2977ec7

Browse files
devversionzarend
authored andcommitted
build: run esbuild as build step before running browser or e2e tests
Similar to the reason why we switched the dev-app and e2e-app to use ESBuild, we will use ESBuild as a step in between for running browser Karma tests, or running e2e protractor/selenium-webdriver tests. This allows us to incorporate the framework linked ESM bundles and helps working around the change that no UMD bundles are available for APF v13 packages. Running ESBuild as a build step in between seems non-significant as on the other hand the module resolution in the browser for Karma seemed noticeable slower (due to it loading hundreds of files individually); and also the Karma browser setup required more manual maintenance (through RequireJS configurations).
1 parent 482d183 commit 2977ec7

File tree

16 files changed

+241
-105
lines changed

16 files changed

+241
-105
lines changed

.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ build:release --stamp
5151
build:snapshot-build --workspace_status_command="yarn -s ng-dev release build-env-stamp --mode=snapshot"
5252
build:snapshot-build --stamp
5353

54+
####################################
55+
# Bazel custom flags #
56+
####################################
57+
build --flag_alias=partial_compilation=@npm//@angular/bazel/src:partial_compilation
5458

5559
##################################
5660
# Always enable Ivy compilation #

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@
3939
"merge": "ng-dev pr merge",
4040
"approve-api": "node ./scripts/approve-api-golden.js",
4141
"approve-size-tests": "node ./scripts/approve-size-golden.js",
42-
"integration-tests": "bazel test --test_tag_filters=-view-engine-only,-linker-integration-test --build_tests_only -- //integration/... -//integration/size-test/...",
43-
"integration-tests:view-engine": "bazel test --test_tag_filters=view-engine-only --build_tests_only -- //integration/... -//integration/size-test/...",
44-
"integration-tests:partial-ivy": "bazel test --//tools:partial_compilation=True --test_tag_filters=partial-compilation-integration,-firefox --build_tests_only -- //integration/... //src/...",
42+
"integration-tests": "bazel test --test_tag_filters=-linker-integration-test --build_tests_only -- //integration/... -//integration/size-test/...",
43+
"integration-tests:partial-ivy": "bazel test --partial_compilation --test_tag_filters=partial-compilation-integration,-firefox --build_tests_only -- //integration/... //src/...",
4544
"integration-tests:size-test": "bazel test //integration/size-test/...",
4645
"check-mdc-tests": "ts-node --project scripts/tsconfig.json scripts/check-mdc-tests.ts",
4746
"check-mdc-exports": "ts-node --project scripts/tsconfig.json scripts/check-mdc-exports.ts",

src/cdk/a11y/focus-trap/focus-trap.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {PortalModule, CdkPortalOutlet, TemplatePortal} from '@angular/cdk/portal
1111
import {A11yModule, FocusTrap, CdkTrapFocus} from '../index';
1212
import {By} from '@angular/platform-browser';
1313

14-
1514
describe('FocusTrap', () => {
1615

1716
beforeEach(waitForAsync(() => {

src/cdk/testing/BUILD.bazel

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,7 @@ filegroup(
2929

3030
ng_web_test_suite(
3131
name = "unit_tests",
32-
# We need to load Kagekiri statically since it is not a named AMD module and needs to
33-
# be manually configured through "require.js" which is used by "karma_web_test_suite".
34-
static_files = [
35-
"@npm//kagekiri",
36-
],
3732
deps = [
38-
":require-config.js",
3933
"//src/cdk/testing/tests:unit_test_sources",
4034
],
4135
)

src/cdk/testing/require-config.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/cdk/testing/tests/webdriver-test.bzl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
load("//tools:defaults.bzl", "jasmine_node_test")
22
load("@io_bazel_rules_webtesting//web:web.bzl", "web_test")
33
load("//tools/server-test:index.bzl", "server_test")
4+
load("//tools/spec-bundling:index.bzl", "spec_bundle")
5+
6+
def webdriver_test(name, deps, tags = [], **kwargs):
7+
spec_bundle(
8+
name = "%s_bundle" % name,
9+
deps = deps,
10+
platform = "node",
11+
external = ["selenium-webdriver"],
12+
)
413

5-
def webdriver_test(name, tags = [], **kwargs):
614
jasmine_node_test(
715
name = "%s_jasmine_test" % name,
816
tags = tags + ["manual"],
17+
deps = ["%s_bundle" % name, "@npm//selenium-webdriver"],
918
**kwargs
1019
)
1120

src/material-date-fns-adapter/BUILD.bazel

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("//tools:defaults.bzl", "ng_module", "ng_package", "ng_test_library", "ng_web_test_suite")
2-
load("//tools/esbuild:index.bzl", "esbuild_amd")
32

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

@@ -33,28 +32,10 @@ ng_test_library(
3332
ng_web_test_suite(
3433
name = "unit_tests",
3534
deps = [
36-
":amd_date_fns",
37-
":amd_date_fns_locales",
3835
":unit_test_sources",
3936
],
4037
)
4138

42-
esbuild_amd(
43-
name = "amd_date_fns",
44-
testonly = True,
45-
entry_point = "@npm//:node_modules/date-fns/esm/index.js",
46-
module_name = "date-fns",
47-
deps = ["@npm//date-fns"],
48-
)
49-
50-
esbuild_amd(
51-
name = "amd_date_fns_locales",
52-
testonly = True,
53-
entry_point = "@npm//:node_modules/date-fns/esm/locale/index.js",
54-
module_name = "date-fns/locale",
55-
deps = ["@npm//date-fns"],
56-
)
57-
5839
ng_package(
5940
name = "npm_package",
6041
srcs = ["package.json"],

src/material-luxon-adapter/BUILD.bazel

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@ ng_test_library(
3333

3434
ng_web_test_suite(
3535
name = "unit_tests",
36-
# We need to load Luxon statically since it is not a named AMD module and needs to
37-
# be manually configured through "require.js" which is used by "karma_web_test_suite".
38-
static_files = [
39-
"@npm//luxon",
40-
],
4136
deps = [
42-
":require-config.js",
4337
":unit_test_sources",
4438
],
4539
)

src/material-moment-adapter/BUILD.bazel

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ ng_module(
1616
],
1717
)
1818

19-
ts_config(
20-
name = "tsconfig",
21-
src = "tsconfig-build.json",
22-
deps = ["//src:bazel-tsconfig-build.json"],
23-
)
24-
2519
ng_test_library(
2620
name = "unit_test_sources",
2721
srcs = glob(
@@ -38,13 +32,7 @@ ng_test_library(
3832

3933
ng_web_test_suite(
4034
name = "unit_tests",
41-
# We need to load Moment statically since it is not a named AMD module and needs to
42-
# be manually configured through "require.js" which is used by "karma_web_test_suite".
43-
static_files = [
44-
"@npm//moment",
45-
],
4635
deps = [
47-
":require-config.js",
4836
":unit_test_sources",
4937
],
5038
)

src/material-moment-adapter/adapter/moment-date-adapter.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import {DEC, FEB, JAN, MAR} from '../../material/testing';
1313
import {MomentDateModule} from './index';
1414
import {MAT_MOMENT_DATE_ADAPTER_OPTIONS, MomentDateAdapter} from './moment-date-adapter';
1515

16-
import * as moment from 'moment';
16+
import moment from 'moment';
17+
18+
// Import all locales for specs relying on non-US locales.
19+
import 'moment/min/locales';
1720

1821
describe('MomentDateAdapter', () => {
1922
let adapter: MomentDateAdapter;

0 commit comments

Comments
 (0)