@@ -5,14 +5,17 @@ load("@build_bazel_rules_nodejs//:index.bzl", _pkg_npm = "pkg_npm")
5
5
load ("@io_bazel_rules_sass//:defs.bzl" , _npm_sass_library = "npm_sass_library" , _sass_binary = "sass_binary" , _sass_library = "sass_library" )
6
6
load ("@npm//@angular/bazel:index.bzl" , _ng_module = "ng_module" , _ng_package = "ng_package" )
7
7
load ("@npm//@angular/dev-infra-private/bazel/integration:index.bzl" , _integration_test = "integration_test" )
8
+ load ("@npm//@angular/dev-infra-private/bazel/esbuild:index.bzl" , _esbuild = "esbuild" , _esbuild_config = "esbuild_config" )
9
+ load ("@npm//@angular/dev-infra-private/bazel/spec-bundling:index.bzl" , _spec_bundle = "spec_bundle" )
10
+ load ("@npm//@angular/dev-infra-private/bazel:extract_js_module_output.bzl" , "extract_js_module_output" )
8
11
load ("@npm//@bazel/jasmine:index.bzl" , _jasmine_node_test = "jasmine_node_test" )
9
12
load ("@npm//@bazel/concatjs:index.bzl" , _karma_web_test = "karma_web_test" , _karma_web_test_suite = "karma_web_test_suite" )
10
13
load ("@npm//@bazel/protractor:index.bzl" , _protractor_web_test_suite = "protractor_web_test_suite" )
11
14
load ("@npm//@bazel/typescript:index.bzl" , _ts_library = "ts_library" )
12
15
load ("//:packages.bzl" , "NO_STAMP_NPM_PACKAGE_SUBSTITUTIONS" , "NPM_PACKAGE_SUBSTITUTIONS" )
13
16
load ("//:pkg-externals.bzl" , "PKG_EXTERNALS" )
14
17
load ("//tools/markdown-to-html:index.bzl" , _markdown_to_html = "markdown_to_html" )
15
- load ("//tools/spec-bundling :index.bzl" , "spec_bundle " )
18
+ load ("//tools/angular :index.bzl" , "LINKER_PROCESSED_FW_PACKAGES " )
16
19
17
20
_DEFAULT_TSCONFIG_BUILD = "//src:bazel-tsconfig-build.json"
18
21
_DEFAULT_TSCONFIG_TEST = "//src:tsconfig-test"
@@ -25,6 +28,8 @@ npmPackageSubstitutions = select({
25
28
# Re-exports to simplify build file load statements
26
29
markdown_to_html = _markdown_to_html
27
30
integration_test = _integration_test
31
+ esbuild = _esbuild
32
+ esbuild_config = _esbuild_config
28
33
29
34
def _compute_module_name (testonly ):
30
35
current_pkg = native .package_name ()
@@ -400,3 +405,57 @@ def ng_web_test_suite(deps = [], static_css = [], exclude_init_script = False, *
400
405
bootstrap = bootstrap ,
401
406
** kwargs
402
407
)
408
+
409
+ def spec_bundle (name , deps , ** kwargs ):
410
+ # TODO: Rename once devmode and prodmode have been combined.
411
+ # For spec bundling we also only consume devmode output as it is ESM in this repository.
412
+ # This helps speeding up development experience as ESBuild (used internally by the rule)
413
+ # would request both devmode and prodmode output flavor (resulting in 2x TS compilations).
414
+ extract_js_module_output (
415
+ name = "%s_devmode_deps" % name ,
416
+ deps = deps ,
417
+ provider = "JSModuleInfo" ,
418
+ forward_linker_mappings = True ,
419
+ include_external_npm_packages = True ,
420
+ include_default_files = False ,
421
+ include_declarations = False ,
422
+ testonly = True ,
423
+ )
424
+
425
+ _spec_bundle (
426
+ name = name ,
427
+ # For specs, we always add the pre-processed linker FW packages so that these
428
+ # are resolved instead of the unprocessed FW entry-points through the `node_modules`.
429
+ deps = ["%s_devmode_deps" % name ] + LINKER_PROCESSED_FW_PACKAGES ,
430
+ workspace_name = "angular_material" ,
431
+ run_angular_linker = select ({
432
+ # Pass through whether partial compilation is enabled or not. This is helpful
433
+ # for our integration tests which run all tests in partial compilation mode.
434
+ "//tools:partial_compilation_enabled" : True ,
435
+ "//conditions:default" : False ,
436
+ }),
437
+ ** kwargs
438
+ )
439
+
440
+ # TODO: Rename once devmode and prodmode have been combined.
441
+ def devmode_esbuild (name , deps , testonly = False , ** kwargs ):
442
+ """Extension of the default `@bazel/esbuild` rule so that only devmode ESM output
443
+ is requested. This is done to speed up local development because the ESBuild rule
444
+ by default requests all possible output flavors/modes."""
445
+ extract_js_module_output (
446
+ name = "%s_devmode_deps" % name ,
447
+ deps = deps ,
448
+ testonly = testonly ,
449
+ forward_linker_mappings = True ,
450
+ include_external_npm_packages = True ,
451
+ include_default_files = False ,
452
+ include_declarations = False ,
453
+ provider = "JSModuleInfo" ,
454
+ )
455
+
456
+ _esbuild (
457
+ name = name ,
458
+ deps = ["%s_devmode_deps" % name ],
459
+ testonly = testonly ,
460
+ ** kwargs
461
+ )
0 commit comments