1
1
# Re-export of Bazel rules with repository-wide defaults
2
2
3
+ load ("@rules_pkg//:pkg.bzl" , "pkg_tar" )
3
4
load ("@build_bazel_rules_nodejs//:index.bzl" , _pkg_npm = "pkg_npm" )
4
5
load ("@io_bazel_rules_sass//:defs.bzl" , _npm_sass_library = "npm_sass_library" , _sass_binary = "sass_binary" , _sass_library = "sass_library" )
5
6
load ("@npm//@angular/bazel:index.bzl" , _ng_module = "ng_module" , _ng_package = "ng_package" )
7
+ load ("@npm//@angular/dev-infra-private/bazel/integration:index.bzl" , _integration_test = "integration_test" )
6
8
load ("@npm//@bazel/jasmine:index.bzl" , _jasmine_node_test = "jasmine_node_test" )
7
9
load ("@npm//@bazel/concatjs:index.bzl" , _karma_web_test = "karma_web_test" , _karma_web_test_suite = "karma_web_test_suite" )
8
10
load ("@npm//@bazel/protractor:index.bzl" , _protractor_web_test_suite = "protractor_web_test_suite" )
9
11
load ("@npm//@bazel/typescript:index.bzl" , _ts_library = "ts_library" )
10
- load ("//:packages.bzl" , "VERSION_PLACEHOLDER_REPLACEMENTS " )
12
+ load ("//:packages.bzl" , "NPM_PACKAGE_SUBSTITUTIONS" , "TEST_NPM_PACKAGE_SUBSTITUTIONS " )
11
13
load ("//:pkg-externals.bzl" , "PKG_EXTERNALS" )
12
14
load ("//tools/markdown-to-html:index.bzl" , _markdown_to_html = "markdown_to_html" )
13
15
load ("//tools/spec-bundling:index.bzl" , "spec_bundle" )
14
16
15
17
_DEFAULT_TSCONFIG_BUILD = "//src:bazel-tsconfig-build.json"
16
18
_DEFAULT_TSCONFIG_TEST = "//src:tsconfig-test"
17
19
20
+ npmPackageSubstitutions = select ({
21
+ "//tools:stamp" : NPM_PACKAGE_SUBSTITUTIONS ,
22
+ "//conditions:default" : TEST_NPM_PACKAGE_SUBSTITUTIONS ,
23
+ })
24
+
18
25
# Re-exports to simplify build file load statements
19
26
markdown_to_html = _markdown_to_html
27
+ integration_test = _integration_test
20
28
21
29
def _compute_module_name (testonly ):
22
30
current_pkg = native .package_name ()
@@ -147,7 +155,7 @@ def ng_module(
147
155
** kwargs
148
156
)
149
157
150
- def ng_package (name , data = [], deps = [], externals = PKG_EXTERNALS , readme_md = None , ** kwargs ):
158
+ def ng_package (name , data = [], deps = [], externals = PKG_EXTERNALS , readme_md = None , visibility = None , ** kwargs ):
151
159
# If no readme file has been specified explicitly, use the default readme for
152
160
# release packages from "src/README.md".
153
161
if not readme_md :
@@ -183,12 +191,24 @@ def ng_package(name, data = [], deps = [], externals = PKG_EXTERNALS, readme_md
183
191
package_name = None ,
184
192
validate = False ,
185
193
readme_md = readme_md ,
186
- substitutions = VERSION_PLACEHOLDER_REPLACEMENTS ,
194
+ substitutions = npmPackageSubstitutions ,
195
+ visibility = visibility ,
187
196
** kwargs
188
197
)
189
198
190
- def pkg_npm (** kwargs ):
199
+ pkg_tar (
200
+ name = name + "_archive" ,
201
+ srcs = [":%s" % name ],
202
+ extension = "tar.gz" ,
203
+ strip_prefix = "./%s" % name ,
204
+ # Target should not build on CI unless it is explicitly requested.
205
+ tags = ["manual" ],
206
+ visibility = visibility ,
207
+ )
208
+
209
+ def pkg_npm (name , visibility = None , ** kwargs ):
191
210
_pkg_npm (
211
+ name = name ,
192
212
# We never set a `package_name` for NPM packages, neither do we enable validation.
193
213
# This is necessary because the source targets of the NPM packages all have
194
214
# package names set and setting a similar `package_name` on the NPM package would
@@ -204,10 +224,21 @@ def pkg_npm(**kwargs):
204
224
# https://github.com/bazelbuild/rules_nodejs/issues/2810.
205
225
package_name = None ,
206
226
validate = False ,
207
- substitutions = VERSION_PLACEHOLDER_REPLACEMENTS ,
227
+ substitutions = npmPackageSubstitutions ,
228
+ visibility = visibility ,
208
229
** kwargs
209
230
)
210
231
232
+ pkg_tar (
233
+ name = name + "_archive" ,
234
+ srcs = [":%s" % name ],
235
+ extension = "tar.gz" ,
236
+ strip_prefix = "./%s" % name ,
237
+ # Target should not build on CI unless it is explicitly requested.
238
+ tags = ["manual" ],
239
+ visibility = visibility ,
240
+ )
241
+
211
242
def jasmine_node_test (** kwargs ):
212
243
kwargs ["templated_args" ] = ["--bazel_patch_module_resolver" ] + kwargs .get ("templated_args" , [])
213
244
_jasmine_node_test (** kwargs )
@@ -306,6 +337,23 @@ def protractor_web_test_suite(name, deps, **kwargs):
306
337
** kwargs
307
338
)
308
339
340
+ def node_integration_test (data = [], tool_mappings = {}, ** kwargs ):
341
+ """Macro for defining an integration test with `node` and `yarn` being
342
+ declared as global tools."""
343
+
344
+ integration_test (
345
+ data = data + [
346
+ # The Yarn files also need to be part of the integration test as runfiles
347
+ # because the `yarn_bin` target is not a self-contained standalone binary.
348
+ "@nodejs//:yarn_files" ,
349
+ ],
350
+ tool_mappings = dict (tool_mappings , ** {
351
+ "@nodejs//:yarn_bin" : "yarn" ,
352
+ "@nodejs//:node_bin" : "node" ,
353
+ }),
354
+ ** kwargs
355
+ )
356
+
309
357
def ng_web_test_suite (deps = [], static_css = [], exclude_init_script = False , ** kwargs ):
310
358
bootstrap = [
311
359
# This matches the ZoneJS bundles used in default CLI projects. See:
0 commit comments