Skip to content

Commit ce68b4d

Browse files
manekinekkobenlesh
authored andcommitted
style: enforce buildifier lint on CI (angular#28186)
PR Close angular#28186
1 parent dc33519 commit ce68b4d

File tree

129 files changed

+334
-303
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+334
-303
lines changed

BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
2+
13
package(default_visibility = ["//visibility:public"])
24

35
load("@build_bazel_rules_nodejs//:defs.bzl", "node_modules_filegroup")
@@ -44,8 +46,6 @@ filegroup(
4446
],
4547
)
4648

47-
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
48-
4949
# A nodejs_binary for @angular/bazel/ngc-wrapped to use by default in
5050
# ng_module that depends on @npm//@angular/bazel instead of the
5151
# output of the //packages/bazel/src/ngc-wrapped ts_library rule. This

WORKSPACE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ Angular has a dependency on the @bazel/bazel package which supplies it.
4141
Try running `yarn bazel` instead.
4242
(If you did run that, check that you've got a fresh `yarn install`)
4343
44-
""")
44+
""",
45+
minimum_bazel_version = "0.21.0",
46+
)
4547

4648
# Setup the Node.js toolchain
4749
node_repositories(

integration/bazel/src/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "http_server", "nodejs_binary", "ro
55
load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package")
66
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
77

8+
package(default_visibility = ["//visibility:public"])
9+
810
# Allow targets under sub-packages to reference the tsconfig.json file
911
exports_files(["tsconfig.json"])
1012

integration/bazel/src/hello-world/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ load("@npm_bazel_typescript//:defs.bzl", "ts_library")
55
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_binary")
66
load("@npm_angular_bazel//:index.bzl", "ng_module", "ng_package")
77

8+
package(default_visibility = ["//visibility:public"])
9+
810
sass_binary(
911
name = "hello-world-styles",
1012
src = "hello-world.component.scss",

modules/benchmarks/src/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package(default_visibility = ["//visibility:public"])
2-
31
load("//tools:defaults.bzl", "ts_library")
42

3+
package(default_visibility = ["//visibility:public"])
4+
55
ts_library(
66
name = "util_lib",
77
srcs = ["util.ts"],

modules/benchmarks/src/largetable/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package(default_visibility = ["//visibility:public"])
2-
31
load("//tools:defaults.bzl", "ts_library")
42

3+
package(default_visibility = ["//visibility:public"])
4+
55
ts_library(
66
name = "util_lib",
77
srcs = ["util.ts"],

modules/benchmarks/src/largetable/render3/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle")
44
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
55
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
66

7+
package(default_visibility = ["//visibility:public"])
8+
79
ng_module(
810
name = "largetable_lib",
911
srcs = glob(["**/*.ts"]),

modules/benchmarks/src/tree/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package(default_visibility = ["//visibility:public"])
2-
31
load("//tools:defaults.bzl", "ts_library")
42

3+
package(default_visibility = ["//visibility:public"])
4+
55
ts_library(
66
name = "util_lib",
77
srcs = ["util.ts"],

modules/benchmarks/src/tree/render3/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle")
44
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
55
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
66

7+
package(default_visibility = ["//visibility:public"])
8+
79
ng_module(
810
name = "tree_lib",
911
srcs = glob(["**/*.ts"]),

modules/e2e_util/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package(default_visibility = ["//visibility:public"])
2-
31
load("//tools:defaults.bzl", "ts_library")
42

3+
package(default_visibility = ["//visibility:public"])
4+
55
ts_library(
66
name = "e2e_util",
77
testonly = 1,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"url": "https://github.com/angular/angular.git"
1717
},
1818
"scripts": {
19-
"bazel:format": "find . -type f \\( -name \"*.bzl\" -or -name BUILD -or -name BUILD.bazel -or -name WORKSPACE \\) ! -path \"*/node_modules/*\" | xargs buildifier -v",
19+
"bazel:format": "find . -type f \\( -name \"*.bzl\" -or -name WORKSPACE -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs buildifier -v --warnings=args-order,attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,constant-glob,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,git-repository,http-archive,integer-division,load,load-on-top,native-build,native-package,out-of-order-load,output-group,package-name,package-on-top,positional-args,redefined-variable,repository-name,same-origin-load,string-iteration,unsorted-dict-items,unused-variable",
2020
"bazel:lint": "yarn bazel:format --lint=warn",
2121
"bazel:lint-fix": "yarn bazel:format --lint=fix",
2222
"preinstall": "node tools/yarn/check-yarn.js",

packages/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("//tools:defaults.bzl", "ts_library")
2+
13
package(default_visibility = ["//visibility:public"])
24

35
exports_files([

packages/animations/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package(default_visibility = ["//visibility:public"])
2-
31
load("//tools:defaults.bzl", "ng_module", "ng_package")
42

3+
package(default_visibility = ["//visibility:public"])
4+
55
ng_module(
66
name = "animations",
77
srcs = glob(

packages/animations/browser/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
load("//tools:defaults.bzl", "ng_module")
2+
13
package(default_visibility = ["//visibility:public"])
24

35
exports_files(["package.json"])
46

5-
load("//tools:defaults.bzl", "ng_module")
6-
77
ng_module(
88
name = "browser",
99
srcs = glob(

packages/animations/browser/testing/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
load("//tools:defaults.bzl", "ng_module")
2+
13
package(default_visibility = ["//visibility:public"])
24

35
exports_files(["package.json"])
46

5-
load("//tools:defaults.bzl", "ng_module")
6-
77
ng_module(
88
name = "testing",
99
srcs = glob(["**/*.ts"]),

packages/bazel/index.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
Users should not load files under "/src"
88
"""
99

10-
load("//packages/bazel/src:ng_module.bzl", _ng_module = "ng_module")
11-
load("//packages/bazel/src:ng_setup_workspace.bzl", _ng_setup_workspace = "ng_setup_workspace")
1210
load("//packages/bazel/src/ng_package:ng_package.bzl", _ng_package = "ng_package")
1311
load(
1412
"//packages/bazel/src/protractor:protractor_web_test.bzl",
1513
_protractor_web_test = "protractor_web_test",
1614
_protractor_web_test_suite = "protractor_web_test_suite",
1715
)
16+
load("//packages/bazel/src:ng_module.bzl", _ng_module = "ng_module")
17+
load("//packages/bazel/src:ng_setup_workspace.bzl", _ng_setup_workspace = "ng_setup_workspace")
1818

1919
ng_module = _ng_module
2020
ng_package = _ng_package

packages/bazel/src/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ filegroup(
88
# For generating skydoc
99
exports_files(glob(["*.bzl"]))
1010

11-
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
12-
1311
nodejs_binary(
1412
name = "rollup_with_build_optimizer",
1513
data = [

packages/bazel/src/builders/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("//tools:defaults.bzl", "ts_library")
2+
13
package(default_visibility = ["//visibility:public"])
24

35
filegroup(
@@ -8,8 +10,6 @@ filegroup(
810
visibility = ["//packages/bazel:__subpackages__"],
911
)
1012

11-
load("//tools:defaults.bzl", "ts_library")
12-
1313
ts_library(
1414
name = "builders",
1515
srcs = [

packages/bazel/src/esm5.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ esm5_outputs_aspect = aspect(
170170
executable = True,
171171
cfg = "host",
172172
),
173+
"_tsc_wrapped": attr.label(
174+
default = Label("@build_bazel_rules_typescript//:@bazel/typescript/tsc_wrapped"),
175+
executable = True,
176+
cfg = "host",
177+
),
173178
},
174179
)
175180

packages/bazel/src/ng_module.bzl

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ def _expected_outs(ctx):
244244
# TODO(alxhub): i18n is only produced by the legacy compiler currently. This should be re-enabled
245245
# when ngtsc can extract messages
246246
if is_legacy_ngc:
247+
# TODO(manekinekko): due to bazelbuild/bazel#4858 we cannot fix the call to ctx.new_file(genfiles_dir)
248+
# so the rule is turned off for now.
247249
i18n_messages_files = [ctx.new_file(ctx.genfiles_dir, ctx.label.name + "_ngc_messages.xmb")]
248250
else:
249251
i18n_messages_files = []
@@ -268,9 +270,9 @@ def _ngc_tsconfig(ctx, files, srcs, **kwargs):
268270
expected_outs = outs.closure_js
269271

270272
angular_compiler_options = {
271-
"enableResourceInlining": ctx.attr.inline_resources,
272-
"generateCodeForLibraries": False,
273273
"allowEmptyCodegenFiles": True,
274+
"enableIvy": _enable_ivy_value(ctx),
275+
"enableResourceInlining": ctx.attr.inline_resources,
274276
# Summaries are only enabled if Angular outputs are to be produced.
275277
"enableSummariesForJit": is_legacy_ngc,
276278
"enableIvy": _enable_ivy_value(ctx),
@@ -537,8 +539,8 @@ def ng_module_impl(ctx, ts_compile_actions):
537539

538540
if is_legacy_ngc:
539541
providers["angular"] = {
540-
"summaries": outs.summaries,
541542
"metadata": outs.metadata,
543+
"summaries": outs.summaries,
542544
}
543545
providers["ngc_messages"] = outs.i18n_messages
544546

@@ -568,13 +570,6 @@ local_deps_aspects = [collect_node_modules_aspect, _collect_summaries_aspect]
568570

569571
NG_MODULE_ATTRIBUTES = {
570572
"srcs": attr.label_list(allow_files = [".ts"]),
571-
572-
# Note: DEPS_ASPECTS is already a list, we add the cast to workaround
573-
# https://github.com/bazelbuild/skydoc/issues/21
574-
"deps": attr.label_list(
575-
doc = "Targets that are imported by this target",
576-
aspects = local_deps_aspects,
577-
),
578573
"assets": attr.label_list(
579574
doc = ".html and .css files needed by the Angular compiler",
580575
allow_files = [
@@ -583,14 +578,6 @@ NG_MODULE_ATTRIBUTES = {
583578
".html",
584579
],
585580
),
586-
"factories": attr.label_list(
587-
allow_files = [".ts", ".html"],
588-
mandatory = False,
589-
),
590-
"filter_summaries": attr.bool(default = False),
591-
"type_check": attr.bool(default = True),
592-
"inline_resources": attr.bool(default = True),
593-
"no_i18n": attr.bool(default = False),
594581
"compiler": attr.label(
595582
doc = """Sets a different ngc compiler binary to use for this library.
596583
@@ -605,16 +592,40 @@ NG_MODULE_ATTRIBUTES = {
605592
executable = True,
606593
cfg = "host",
607594
),
595+
"factories": attr.label_list(
596+
allow_files = [".ts", ".html"],
597+
mandatory = False,
598+
),
599+
"filter_summaries": attr.bool(default = False),
600+
"inline_resources": attr.bool(default = True),
608601
"ng_xi18n": attr.label(
609602
default = Label(DEFAULT_NG_XI18N),
610603
executable = True,
611604
cfg = "host",
612605
),
606+
"no_i18n": attr.bool(default = False),
607+
"type_check": attr.bool(default = True),
608+
609+
# Note: DEPS_ASPECTS is already a list, we add the cast to workaround
610+
# https://github.com/bazelbuild/skydoc/issues/21
611+
"deps": attr.label_list(
612+
doc = "Targets that are imported by this target",
613+
aspects = local_deps_aspects,
614+
),
613615
"_supports_workers": attr.bool(default = True),
614616
}
615617

616618
NG_MODULE_RULE_ATTRS = dict(dict(COMMON_ATTRIBUTES, **NG_MODULE_ATTRIBUTES), **{
617-
"tsconfig": attr.label(allow_files = True, single_file = True),
619+
"entry_point": attr.string(),
620+
621+
# Default is %{name}_public_index
622+
# The suffix points to the generated "bundle index" files that users import from
623+
# The default is intended to avoid collisions with the users input files.
624+
# Later packaging rules will point to these generated files as the entry point
625+
# into the package.
626+
# See the flatModuleOutFile documentation in
627+
# https://github.com/angular/angular/blob/master/packages/compiler-cli/src/transformers/api.ts
628+
"flat_module_out_file": attr.string(),
618629
"node_modules": attr.label(
619630
doc = """The npm packages which should be available during the compile.
620631

packages/bazel/src/ng_package/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
package(default_visibility = ["//visibility:public"])
2-
31
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
42

53
# BEGIN-DEV-ONLY

packages/bazel/src/ng_package/ng_package.bzl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ specification of this format at https://goo.gl/jB3GVv
1616
load("@build_bazel_rules_nodejs//internal/common:collect_es6_sources.bzl", "collect_es6_sources")
1717
load("@build_bazel_rules_nodejs//internal/common:node_module_info.bzl", "NodeModuleInfo")
1818
load("@build_bazel_rules_nodejs//internal/common:sources_aspect.bzl", "sources_aspect")
19+
load(
20+
"@build_bazel_rules_nodejs//:internal/npm_package/npm_package.bzl",
21+
"NPM_PACKAGE_ATTRS",
22+
"NPM_PACKAGE_OUTPUTS",
23+
"create_package",
24+
)
1925
load(
2026
"@build_bazel_rules_nodejs//:internal/rollup/rollup_bundle.bzl",
2127
"ROLLUP_ATTRS",
@@ -32,6 +38,7 @@ load(
3238
load("//packages/bazel/src:external.bzl", "FLAT_DTS_FILE_SUFFIX")
3339
load("//packages/bazel/src:esm5.bzl", "esm5_outputs_aspect", "esm5_root_dir", "flatten_esm5")
3440
load("//packages/bazel/src/ng_package:collect-type-definitions.bzl", "collect_type_definitions")
41+
load("//packages/bazel/src:esm5.bzl", "esm5_outputs_aspect", "esm5_root_dir", "flatten_esm5")
3542

3643
_DEFAULT_NG_PACKAGER = "@npm//@angular/bazel/bin:packager"
3744

@@ -336,8 +343,8 @@ def _ng_package_impl(ctx):
336343
packager_inputs.extend([m.metadata_file])
337344
metadata_arg[m.module_name] = {
338345
"index": m.typings_file.path.replace(".d.ts", ".js"),
339-
"typings": m.typings_file.path,
340346
"metadata": m.metadata_file.path,
347+
"typings": m.typings_file.path,
341348
}
342349
packager_args.add(str(metadata_arg))
343350

@@ -401,7 +408,6 @@ DEPS_ASPECTS = [esm5_outputs_aspect, sources_aspect]
401408

402409
NG_PACKAGE_ATTRS = dict(NPM_PACKAGE_ATTRS, **dict(ROLLUP_ATTRS, **{
403410
"srcs": attr.label_list(allow_files = True),
404-
"deps": attr.label_list(aspects = DEPS_ASPECTS),
405411
"data": attr.label_list(
406412
doc = "Additional, non-Angular files to be added to the package, e.g. global CSS assets.",
407413
allow_files = True,
@@ -412,11 +418,15 @@ NG_PACKAGE_ATTRS = dict(NPM_PACKAGE_ATTRS, **dict(ROLLUP_ATTRS, **{
412418
"entry_point_name": attr.string(
413419
doc = "Name to use when generating bundle files for the primary entry-point.",
414420
),
421+
"globals": attr.string_dict(default = {}),
422+
"include_devmode_srcs": attr.bool(default = False),
415423
"ng_packager": attr.label(
416424
default = Label(_DEFAULT_NG_PACKAGER),
417425
executable = True,
418426
cfg = "host",
419427
),
428+
"readme_md": attr.label(allow_single_file = [".md"]),
429+
"deps": attr.label_list(aspects = DEPS_ASPECTS),
420430
"_rollup": attr.label(
421431
default = Label("@build_bazel_rules_nodejs//internal/rollup"),
422432
executable = True,
@@ -479,8 +489,8 @@ def ng_package_outputs(name, entry_point, entry_point_name):
479489

480490
basename = primary_entry_point_name(name, entry_point, entry_point_name)
481491
outputs = {
482-
"fesm5": "fesm5/%s.js" % basename,
483492
"fesm2015": "fesm2015/%s.js" % basename,
493+
"fesm5": "fesm5/%s.js" % basename,
484494
"umd": "%s.umd.js" % basename,
485495
"umd_min": "%s.umd.min.js" % basename,
486496
}

0 commit comments

Comments
 (0)