Skip to content

Commit 59d3984

Browse files
devversionmmalerba
authored andcommitted
build: use genrule to generate example module (#17615)
* build: use genrule to generate example module Since we no longer use NGC for generating the package output of the examples, we can start using the genrule for the `ExampleModule` again. This means that we can fully remove the example module tasks from gulp. Additionally renames the `material-examples` package to `components-examples` and removes the `module.ts` workaround for the examples since we do not need a flat module index file with ngtsc. * fixup! build: use genrule to generate example module Make glob less confusing
1 parent 1255139 commit 59d3984

File tree

822 files changed

+397
-546
lines changed

Some content is hidden

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

822 files changed

+397
-546
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ jobs:
356356

357357
# TODO(devversion): Ideally the "build_release_packages" job should build all packages with
358358
# Bazel, but for now we mix up the Gulp and bazel setup, so we need to build the package here.
359-
- run: bazel build src/material-examples:npm_package --config=release
359+
- run: bazel build src/components-examples:npm_package --config=release
360360

361361
- run: ./scripts/circleci/publish-snapshots.sh
362362

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121

122122
# Docs examples & guides
123123
/guides/** @jelbourn
124-
/src/material-examples/** @jelbourn
124+
/src/components-examples/** @jelbourn
125125

126126
# Accessibility demos
127127
/src/a11y-demo/**/* @jelbourn

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
/deploy
77
/bazel-out
88

9-
# Example module file will be auto-generated.
10-
# TODO(devversion): re-add the example-module once angular#30259 is fixed.
11-
# /src/material-examples/example-module.ts
12-
139
# dependencies
1410
node_modules
1511
/bower_components

rollup-globals.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ create_globals(
105105
# Rollup globals the examples package. Since individual examples are
106106
# grouped by package and component, the primary entry-point imports
107107
# from entry-points which should be treated as external imports.
108-
create_globals("material-examples/cdk", CDK_ENTRYPOINTS)
109-
create_globals("material-examples/cdk-experimental", CDK_EXPERIMENTAL_ENTRYPOINTS)
108+
create_globals("components-examples/cdk", CDK_ENTRYPOINTS)
109+
create_globals("components-examples/cdk-experimental", CDK_EXPERIMENTAL_ENTRYPOINTS)
110110
create_globals(
111-
"material-examples/material",
111+
"components-examples/material",
112112
MATERIAL_ENTRYPOINTS + MATERIAL_TESTING_ENTRYPOINTS,
113113
)
114114
create_globals(
115-
"material-examples/material-experimental",
115+
"components-examples/material-experimental",
116116
MATERIAL_EXPERIMENTAL_ENTRYPOINTS + MATERIAL_EXPERIMENTAL_TESTING_ENTRYPOINTS,
117117
)

scripts/deploy/publish-docs-content.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ docsDistPath="${projectPath}/dist/docs"
2323
# Path to the cloned docs-content repository.
2424
docsContentPath="${projectPath}/tmp/material2-docs-content"
2525

26-
# Path to the release output of the Bazel "@angular/material-examples" NPM package.
27-
examplesPackagePath="$(bazel info bazel-bin)/src/material-examples/npm_package"
26+
# Path to the release output of the Bazel "@angular/components-examples" NPM package.
27+
examplesPackagePath="$(bazel info bazel-bin)/src/components-examples/npm_package"
2828

2929
# Git clone URL for the material2-docs-content repository.
3030
docsContentRepoUrl="https://github.com/angular/material2-docs-content"

src/components-examples/BUILD.bazel

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
load("//tools:defaults.bzl", "ng_module", "ng_package")
4+
load("//tools/highlight-files:index.bzl", "highlight_files")
5+
load("//tools/package-docs-content:index.bzl", "package_docs_content")
6+
7+
EXAMPLE_PACKAGES = [
8+
# TODO(devversion): try to have for each entry-point a bazel package so that
9+
# we can automate this using the "package.bzl" variables. Currently generated
10+
# with "bazel query 'kind("ng_module", //src/components-examples/...:*)' --output="label"
11+
"//src/components-examples/material/tree",
12+
"//src/components-examples/material/tooltip",
13+
"//src/components-examples/material/toolbar",
14+
"//src/components-examples/material/tabs",
15+
"//src/components-examples/material/table",
16+
"//src/components-examples/material/stepper",
17+
"//src/components-examples/material/sort",
18+
"//src/components-examples/material/snack-bar",
19+
"//src/components-examples/material/slider",
20+
"//src/components-examples/material/slide-toggle",
21+
"//src/components-examples/material/sidenav",
22+
"//src/components-examples/material/select",
23+
"//src/components-examples/material/radio",
24+
"//src/components-examples/material/progress-spinner",
25+
"//src/components-examples/material/progress-bar",
26+
"//src/components-examples/material/paginator",
27+
"//src/components-examples/material/menu",
28+
"//src/components-examples/material/list",
29+
"//src/components-examples/material/input",
30+
"//src/components-examples/material/icon",
31+
"//src/components-examples/material/grid-list",
32+
"//src/components-examples/material/form-field",
33+
"//src/components-examples/material/expansion",
34+
"//src/components-examples/material/divider",
35+
"//src/components-examples/material/dialog",
36+
"//src/components-examples/material/datepicker",
37+
"//src/components-examples/material/core",
38+
"//src/components-examples/material/chips",
39+
"//src/components-examples/material/checkbox",
40+
"//src/components-examples/material/card",
41+
"//src/components-examples/material/button-toggle",
42+
"//src/components-examples/material/button",
43+
"//src/components-examples/material/bottom-sheet",
44+
"//src/components-examples/material/badge",
45+
"//src/components-examples/material/autocomplete",
46+
"//src/components-examples/material-experimental/popover-edit",
47+
"//src/components-examples/cdk/tree",
48+
"//src/components-examples/cdk/text-field",
49+
"//src/components-examples/cdk/table",
50+
"//src/components-examples/cdk/stepper",
51+
"//src/components-examples/cdk/scrolling",
52+
"//src/components-examples/cdk/portal",
53+
"//src/components-examples/cdk/platform",
54+
"//src/components-examples/cdk/drag-drop",
55+
"//src/components-examples/cdk/clipboard",
56+
"//src/components-examples/cdk/a11y",
57+
"//src/components-examples/cdk-experimental/popover-edit",
58+
]
59+
60+
ng_module(
61+
name = "components-examples",
62+
srcs = glob(["*.ts"]) + [":example-module.ts"],
63+
module_name = "@angular/components-examples",
64+
deps = EXAMPLE_PACKAGES,
65+
)
66+
67+
filegroup(
68+
name = "example-source-files",
69+
srcs = ["%s:source-files" % pkg for pkg in EXAMPLE_PACKAGES],
70+
)
71+
72+
highlight_files(
73+
name = "highlighted-source-files",
74+
srcs = [":example-source-files"],
75+
tags = ["docs-package"],
76+
)
77+
78+
package_docs_content(
79+
name = "docs-content",
80+
srcs = {
81+
# We want to package the guides in to the docs content. These will be displayed
82+
# in the documentation.
83+
"//guides": "guides",
84+
85+
# Package the overviews for "@angular/material" and "@angular/cdk" into the docs content
86+
"//src/cdk:overviews": "overviews/cdk",
87+
"//src/material:overviews": "overviews/material",
88+
89+
# Package the API docs for the Material and CDK package into the docs-content
90+
"//src:api-docs": "api-docs",
91+
92+
# In order to be able to run examples in StackBlitz, we also want to package the
93+
# plain source files into the docs-content.
94+
":example-source-files": "examples-source",
95+
96+
# For the live-examples in our docs, we want to package the highlighted files
97+
# into the docs content. These will be used to show the source code for examples.
98+
":highlighted-source-files": "examples-highlighted",
99+
},
100+
tags = ["docs-package"],
101+
)
102+
103+
ng_package(
104+
name = "npm_package",
105+
srcs = ["package.json"],
106+
data = [":docs-content"],
107+
entry_point = ":public-api.ts",
108+
tags = ["docs-package"],
109+
deps = [":components-examples"] + EXAMPLE_PACKAGES,
110+
)
111+
112+
genrule(
113+
name = "example-module",
114+
srcs = [":example-source-files"],
115+
outs = [
116+
"example-module.ts",
117+
"_example_module.MF",
118+
],
119+
cmd = """
120+
# Create source file manifest
121+
echo "$(locations //src/components-examples:example-source-files)" \
122+
> $(location _example_module.MF)
123+
124+
# Run the bazel entry-point for generating the example module.
125+
./$(location //tools/example-module:bazel-bin) \
126+
"$(location _example_module.MF)" \
127+
"$(location example-module.ts)" \
128+
"$$PWD/src/components-examples"
129+
""",
130+
output_to_bindir = True,
131+
tools = ["//tools/example-module:bazel-bin"],
132+
)

src/material-examples/cdk-experimental/popover-edit/BUILD.bazel renamed to src/components-examples/cdk-experimental/popover-edit/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ng_module(
99
"**/*.html",
1010
"**/*.css",
1111
]),
12-
module_name = "@angular/material-examples/cdk-experimental/popover-edit",
12+
module_name = "@angular/components-examples/cdk-experimental/popover-edit",
1313
deps = [
1414
"//src/cdk-experimental/popover-edit",
1515
"//src/cdk/collections",
@@ -21,8 +21,8 @@ ng_module(
2121
filegroup(
2222
name = "source-files",
2323
srcs = glob([
24-
"*/*.html",
25-
"*/*.css",
26-
"*/*.ts",
24+
"**/*.html",
25+
"**/*.css",
26+
"**/*.ts",
2727
]),
2828
)

src/material-examples/cdk/a11y/BUILD.bazel renamed to src/components-examples/cdk/a11y/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ng_module(
99
"**/*.html",
1010
"**/*.css",
1111
]),
12-
module_name = "@angular/material-examples/cdk/a11y",
12+
module_name = "@angular/components-examples/cdk/a11y",
1313
deps = [
1414
"//src/cdk/a11y",
1515
"//src/material/select",
@@ -19,8 +19,8 @@ ng_module(
1919
filegroup(
2020
name = "source-files",
2121
srcs = glob([
22-
"*/*.html",
23-
"*/*.css",
24-
"*/*.ts",
22+
"**/*.html",
23+
"**/*.css",
24+
"**/*.ts",
2525
]),
2626
)

src/material-examples/cdk/clipboard/BUILD.bazel renamed to src/components-examples/cdk/clipboard/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ng_module(
99
"**/*.html",
1010
"**/*.css",
1111
]),
12-
module_name = "@angular/material-examples/cdk/clipboard",
12+
module_name = "@angular/components-examples/cdk/clipboard",
1313
deps = [
1414
"//src/cdk/clipboard",
1515
"@npm//@angular/forms",
@@ -19,8 +19,8 @@ ng_module(
1919
filegroup(
2020
name = "source-files",
2121
srcs = glob([
22-
"*/*.html",
23-
"*/*.css",
24-
"*/*.ts",
22+
"**/*.html",
23+
"**/*.css",
24+
"**/*.ts",
2525
]),
2626
)

src/material-examples/cdk/drag-drop/BUILD.bazel renamed to src/components-examples/cdk/drag-drop/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ng_module(
99
"**/*.html",
1010
"**/*.css",
1111
]),
12-
module_name = "@angular/material-examples/cdk/drag-drop",
12+
module_name = "@angular/components-examples/cdk/drag-drop",
1313
deps = [
1414
"//src/cdk/drag-drop",
1515
"//src/cdk/overlay",
@@ -20,8 +20,8 @@ ng_module(
2020
filegroup(
2121
name = "source-files",
2222
srcs = glob([
23-
"*/*.html",
24-
"*/*.css",
25-
"*/*.ts",
23+
"**/*.html",
24+
"**/*.css",
25+
"**/*.ts",
2626
]),
2727
)

src/material-examples/cdk/platform/BUILD.bazel renamed to src/components-examples/cdk/platform/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ng_module(
99
"**/*.html",
1010
"**/*.css",
1111
]),
12-
module_name = "@angular/material-examples/cdk/platform",
12+
module_name = "@angular/components-examples/cdk/platform",
1313
deps = [
1414
"//src/cdk/platform",
1515
],
@@ -18,8 +18,8 @@ ng_module(
1818
filegroup(
1919
name = "source-files",
2020
srcs = glob([
21-
"*/*.html",
22-
"*/*.css",
23-
"*/*.ts",
21+
"**/*.html",
22+
"**/*.css",
23+
"**/*.ts",
2424
]),
2525
)

src/material-examples/cdk/portal/BUILD.bazel renamed to src/components-examples/cdk/portal/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ng_module(
99
"**/*.html",
1010
"**/*.css",
1111
]),
12-
module_name = "@angular/material-examples/cdk/portal",
12+
module_name = "@angular/components-examples/cdk/portal",
1313
deps = [
1414
"//src/cdk/portal",
1515
],
@@ -18,8 +18,8 @@ ng_module(
1818
filegroup(
1919
name = "source-files",
2020
srcs = glob([
21-
"*/*.html",
22-
"*/*.css",
23-
"*/*.ts",
21+
"**/*.html",
22+
"**/*.css",
23+
"**/*.ts",
2424
]),
2525
)

src/material-examples/cdk/scrolling/BUILD.bazel renamed to src/components-examples/cdk/scrolling/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ng_module(
99
"**/*.html",
1010
"**/*.css",
1111
]),
12-
module_name = "@angular/material-examples/cdk/scrolling",
12+
module_name = "@angular/components-examples/cdk/scrolling",
1313
deps = [
1414
"//src/cdk/scrolling",
1515
],
@@ -18,8 +18,8 @@ ng_module(
1818
filegroup(
1919
name = "source-files",
2020
srcs = glob([
21-
"*/*.html",
22-
"*/*.css",
23-
"*/*.ts",
21+
"**/*.html",
22+
"**/*.css",
23+
"**/*.ts",
2424
]),
2525
)

src/material-examples/cdk/stepper/BUILD.bazel renamed to src/components-examples/cdk/stepper/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ng_module(
99
"**/*.html",
1010
"**/*.css",
1111
]),
12-
module_name = "@angular/material-examples/cdk/stepper",
12+
module_name = "@angular/components-examples/cdk/stepper",
1313
deps = [
1414
"//src/cdk/stepper",
1515
],
@@ -18,8 +18,8 @@ ng_module(
1818
filegroup(
1919
name = "source-files",
2020
srcs = glob([
21-
"*/*.html",
22-
"*/*.css",
23-
"*/*.ts",
21+
"**/*.html",
22+
"**/*.css",
23+
"**/*.ts",
2424
]),
2525
)

src/material-examples/cdk/table/BUILD.bazel renamed to src/components-examples/cdk/table/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ng_module(
99
"**/*.html",
1010
"**/*.css",
1111
]),
12-
module_name = "@angular/material-examples/cdk/table",
12+
module_name = "@angular/components-examples/cdk/table",
1313
deps = [
1414
"//src/cdk/table",
1515
],
@@ -18,8 +18,8 @@ ng_module(
1818
filegroup(
1919
name = "source-files",
2020
srcs = glob([
21-
"*/*.html",
22-
"*/*.css",
23-
"*/*.ts",
21+
"**/*.html",
22+
"**/*.css",
23+
"**/*.ts",
2424
]),
2525
)

0 commit comments

Comments
 (0)