Skip to content

Commit 43047c1

Browse files
devversionzarend
authored andcommitted
build: no longer keep track of UMD globals for package output
As of APF v13, we no longer ship UMD files. This means that we can remove all the logic for keeping track of the UMD global names. Instead we just keep track of external packages which should not be bundled into the package output (this includes cross-entry point imports; e.g. slider should not bundle the core entry-point; so we still need to keep track of all the entry-points as externals)
1 parent c30fc63 commit 43047c1

File tree

8 files changed

+164
-219
lines changed

8 files changed

+164
-219
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,10 @@ jobs:
338338
- *setup_bazel_binary
339339

340340
- run:
341-
name: Checking rollup globals
341+
name: Checking package externals
342342
command: |
343-
bazel build //:rollup_globals
344-
yarn check-rollup-globals $(bazel info bazel-bin)/rollup_globals.json
343+
bazel build //:package_externals
344+
yarn check-package-externals $(bazel info bazel-bin)/package_externals.json
345345
346346
- run:
347347
name: Checking entry-points configuration

BUILD.bazel

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//:rollup-globals.bzl", "ROLLUP_GLOBALS")
1+
load("//:pkg-externals.bzl", "PKG_EXTERNALS")
22
load("//src/cdk:config.bzl", "CDK_ENTRYPOINTS")
33
load("//src/cdk-experimental:config.bzl", "CDK_EXPERIMENTAL_ENTRYPOINTS")
44
load("//src/material:config.bzl", "MATERIAL_ENTRYPOINTS", "MATERIAL_TESTING_ENTRYPOINTS")
@@ -11,10 +11,13 @@ exports_files([
1111
"package.json",
1212
])
1313

14+
# Target which writes the list of package externals into a JSON file so that the
15+
# Starlark-configured externals (for the NPM package bundling) can be passed to
16+
# the `check-package-externals` Yarn script, which validates our module imports.
1417
genrule(
15-
name = "rollup_globals",
16-
outs = ["rollup_globals.json"],
17-
cmd = "echo '%s' > $@" % ROLLUP_GLOBALS,
18+
name = "package_externals",
19+
outs = ["package_externals.json"],
20+
cmd = "echo '%s' > $@" % PKG_EXTERNALS,
1821
)
1922

2023
entryPoints = ["cdk/%s" % e for e in CDK_ENTRYPOINTS] + \

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"breaking-changes": "ts-node --project scripts/tsconfig.json scripts/breaking-changes.ts",
2929
"gulp": "gulp",
3030
"check-entry-point-setup": "node ./scripts/check-entry-point-setup.js",
31-
"check-rollup-globals": "ts-node --project scripts/tsconfig.json scripts/check-rollup-globals.ts",
31+
"check-package-externals": "ts-node --project scripts/tsconfig.json scripts/check-package-externals.ts",
3232
"format": "yarn ng-dev format changed",
3333
"cherry-pick-patch": "ts-node --project tools/cherry-pick-patch/tsconfig.json tools/cherry-pick-patch/cherry-pick-patch.ts",
3434
"ownerslint": "ts-node --project scripts/tsconfig.json scripts/ownerslint.ts",

packages.bzl

Lines changed: 54 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -22,98 +22,61 @@ VERSION_PLACEHOLDER_REPLACEMENTS = {
2222
"0.0.0-RXJS": RXJS_PACKAGE_VERSION,
2323
}
2424

25-
# Map of MDC packages and their UMD bundles. These are used for unit tests and the dev-app.
26-
MDC_PACKAGE_UMD_BUNDLES = {
27-
"@material/animation": "@npm//:node_modules/@material/animation/dist/mdc.animation.js",
28-
"@material/auto-init": "@npm//:node_modules/@material/auto-init/dist/mdc.autoInit.js",
29-
"@material/base": "@npm//:node_modules/@material/base/dist/mdc.base.js",
30-
"@material/checkbox": "@npm//:node_modules/@material/checkbox/dist/mdc.checkbox.js",
31-
"@material/chips": "@npm//:node_modules/@material/chips/dist/mdc.chips.js",
32-
"@material/circular-progress": "@npm//:node_modules/@material/circular-progress/dist/mdc.circularProgress.js",
33-
"@material/data-table": "@npm//:node_modules/@material/data-table/dist/mdc.dataTable.js",
34-
"@material/dialog": "@npm//:node_modules/@material/dialog/dist/mdc.dialog.js",
35-
"@material/dom": "@npm//:node_modules/@material/dom/dist/mdc.dom.js",
36-
"@material/drawer": "@npm//:node_modules/@material/drawer/dist/mdc.drawer.js",
37-
"@material/floating-label": "@npm//:node_modules/@material/floating-label/dist/mdc.floatingLabel.js",
38-
"@material/form-field": "@npm//:node_modules/@material/form-field/dist/mdc.formField.js",
39-
"@material/icon-button": "@npm//:node_modules/@material/icon-button/dist/mdc.iconButton.js",
40-
"@material/line-ripple": "@npm//:node_modules/@material/line-ripple/dist/mdc.lineRipple.js",
41-
"@material/linear-progress": "@npm//:node_modules/@material/linear-progress/dist/mdc.linearProgress.js",
42-
"@material/list": "@npm//:node_modules/@material/list/dist/mdc.list.js",
43-
"@material/menu-surface": "@npm//:node_modules/@material/menu-surface/dist/mdc.menuSurface.js",
44-
"@material/menu": "@npm//:node_modules/@material/menu/dist/mdc.menu.js",
45-
"@material/notched-outline": "@npm//:node_modules/@material/notched-outline/dist/mdc.notchedOutline.js",
46-
"@material/radio": "@npm//:node_modules/@material/radio/dist/mdc.radio.js",
47-
"@material/ripple": "@npm//:node_modules/@material/ripple/dist/mdc.ripple.js",
48-
"@material/select": "@npm//:node_modules/@material/select/dist/mdc.select.js",
49-
"@material/slider": "@npm//:node_modules/@material/slider/dist/mdc.slider.js",
50-
"@material/snackbar": "@npm//:node_modules/@material/snackbar/dist/mdc.snackbar.js",
51-
"@material/switch": "@npm//:node_modules/@material/switch/dist/mdc.switch.js",
52-
"@material/tab-bar": "@npm//:node_modules/@material/tab-bar/dist/mdc.tabBar.js",
53-
"@material/tab-indicator": "@npm//:node_modules/@material/tab-indicator/dist/mdc.tabIndicator.js",
54-
"@material/tab-scroller": "@npm//:node_modules/@material/tab-scroller/dist/mdc.tabScroller.js",
55-
"@material/tab": "@npm//:node_modules/@material/tab/dist/mdc.tab.js",
56-
"@material/textfield": "@npm//:node_modules/@material/textfield/dist/mdc.textfield.js",
57-
"@material/tooltip": "@npm//:node_modules/@material/tooltip/dist/mdc.tooltip.js",
58-
"@material/top-app-bar": "@npm//:node_modules/@material/top-app-bar/dist/mdc.topAppBar.js",
59-
}
60-
61-
# List of default Angular library UMD bundles which are not processed by ngcc.
62-
ANGULAR_NO_NGCC_BUNDLES = [
63-
("@angular/compiler", ["compiler.umd.js"]),
64-
("@angular/localize", ["localize.umd.js", "localize-init.umd.js"]),
25+
# List of MDC packages.
26+
MDC_PACKAGES = [
27+
"@material/animation",
28+
"@material/auto-init",
29+
"@material/base",
30+
"@material/checkbox",
31+
"@material/chips",
32+
"@material/circular-progress",
33+
"@material/data-table",
34+
"@material/dialog",
35+
"@material/dom",
36+
"@material/drawer",
37+
"@material/floating-label",
38+
"@material/form-field",
39+
"@material/icon-button",
40+
"@material/line-ripple",
41+
"@material/linear-progress",
42+
"@material/list",
43+
"@material/menu-surface",
44+
"@material/menu",
45+
"@material/notched-outline",
46+
"@material/radio",
47+
"@material/ripple",
48+
"@material/select",
49+
"@material/slider",
50+
"@material/snackbar",
51+
"@material/switch",
52+
"@material/tab-bar",
53+
"@material/tab-indicator",
54+
"@material/tab-scroller",
55+
"@material/tab",
56+
"@material/textfield",
57+
"@material/tooltip",
58+
"@material/top-app-bar",
6559
]
6660

67-
# List of Angular library UMD bundles which will are processed by ngcc.
68-
ANGULAR_NGCC_BUNDLES = [
69-
("@angular/animations", ["animations-browser.umd.js", "animations.umd.js"]),
70-
("@angular/common", ["common-http-testing.umd.js", "common-http.umd.js", "common-testing.umd.js", "common.umd.js"]),
71-
("@angular/compiler", ["compiler-testing.umd.js"]),
72-
("@angular/core", ["core-testing.umd.js", "core.umd.js"]),
73-
("@angular/forms", ["forms.umd.js"]),
74-
("@angular/platform-browser-dynamic", ["platform-browser-dynamic-testing.umd.js", "platform-browser-dynamic.umd.js"]),
75-
("@angular/platform-browser", ["platform-browser.umd.js", "platform-browser-testing.umd.js", "platform-browser-animations.umd.js"]),
76-
("@angular/router", ["router.umd.js"]),
61+
ANGULAR_PACKAGES_CONFIG = [
62+
("@angular/animations", struct(entry_points = ["browser"])),
63+
("@angular/common", struct(entry_points = ["http/testing", "http", "testing"])),
64+
("@angular/compiler", struct(entry_points = ["testing"])),
65+
("@angular/core", struct(entry_points = ["testing"])),
66+
("@angular/forms", struct(entry_points = [])),
67+
("@angular/platform-browser", struct(entry_points = ["testing", "animations"])),
68+
("@angular/platform-server", struct(entry_points = [], platform = "node")),
69+
("@angular/platform-browser-dynamic", struct(entry_points = ["testing"])),
70+
("@angular/router", struct(entry_points = [])),
71+
("@angular/localize", struct(entry_points = ["init"])),
7772
]
7873

79-
"""
80-
Gets a dictionary of all packages and their bundle names.
81-
"""
82-
83-
def getFrameworkPackageBundles():
84-
res = {}
85-
for pkgName, bundleNames in ANGULAR_NGCC_BUNDLES + ANGULAR_NO_NGCC_BUNDLES:
86-
res[pkgName] = res.get(pkgName, []) + bundleNames
87-
return res
88-
89-
"""
90-
Gets a list of labels which resolve to the UMD bundles of the given packages.
91-
"""
92-
93-
def getUmdFilePaths(packages, ngcc_artifacts):
94-
tmpl = "@npm//:node_modules/%s" + ("/__ivy_ngcc__" if ngcc_artifacts else "") + "/bundles/%s"
95-
return [
96-
tmpl % (pkgName, bundleName)
97-
for pkgName, bundleNames in packages
98-
for bundleName in bundleNames
99-
]
100-
101-
ANGULAR_PACKAGE_BUNDLES = getFrameworkPackageBundles()
102-
103-
ANGULAR_LIBRARY_VIEW_ENGINE_UMDS = getUmdFilePaths(ANGULAR_NO_NGCC_BUNDLES, False) + \
104-
getUmdFilePaths(ANGULAR_NGCC_BUNDLES, False)
105-
106-
ANGULAR_LIBRARY_IVY_UMDS = getUmdFilePaths(ANGULAR_NO_NGCC_BUNDLES, False) + \
107-
getUmdFilePaths(ANGULAR_NGCC_BUNDLES, True)
108-
109-
"""
110-
Gets the list of targets for the Angular library UMD bundles. Conditionally
111-
switches between View Engine or Ivy UMD bundles based on the
112-
"--config={ivy,view-engine}" flag.
113-
"""
114-
115-
def getAngularUmdTargets():
116-
return select({
117-
"//tools:view_engine_mode": ANGULAR_LIBRARY_VIEW_ENGINE_UMDS,
118-
"//conditions:default": ANGULAR_LIBRARY_IVY_UMDS,
119-
})
74+
ANGULAR_PACKAGES = [
75+
struct(
76+
name = name[len("@angular/"):],
77+
entry_points = config.entry_points,
78+
platform = config.platform if hasattr(config, "platform") else "browser",
79+
module_name = name,
80+
)
81+
for name, config in ANGULAR_PACKAGES_CONFIG
82+
]

pkg-externals.bzl

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
load("//src/cdk:config.bzl", "CDK_ENTRYPOINTS")
2+
load("//src/cdk-experimental:config.bzl", "CDK_EXPERIMENTAL_ENTRYPOINTS")
3+
load("//src/material:config.bzl", "MATERIAL_ENTRYPOINTS", "MATERIAL_TESTING_ENTRYPOINTS")
4+
load(
5+
"//src/material-experimental:config.bzl",
6+
"MATERIAL_EXPERIMENTAL_ENTRYPOINTS",
7+
"MATERIAL_EXPERIMENTAL_TESTING_ENTRYPOINTS",
8+
)
9+
load("//:packages.bzl", "MDC_PACKAGES")
10+
11+
# Base list of externals which should not be bundled into the APF package output.
12+
# Note that we want to disable sorting of the externals as we manually group entries.
13+
# buildifier: disable=unsorted-list-items
14+
PKG_EXTERNALS = [
15+
# Framework packages.
16+
"@angular/animations",
17+
"@angular/common",
18+
"@angular/common/http",
19+
"@angular/common/http/testing",
20+
"@angular/common/testing",
21+
"@angular/core",
22+
"@angular/core/testing",
23+
"@angular/forms",
24+
"@angular/platform-browser",
25+
"@angular/platform-browser-dynamic",
26+
"@angular/platform-browser-dynamic/testing",
27+
"@angular/platform-browser/animations",
28+
"@angular/platform-server",
29+
"@angular/router",
30+
31+
# Primary entry-points in the project.
32+
"@angular/cdk",
33+
"@angular/cdk-experimental",
34+
"@angular/google-maps",
35+
"@angular/material",
36+
"@angular/material-experimental",
37+
"@angular/material-moment-adapter",
38+
"@angular/material-luxon-adapter",
39+
"@angular/material-date-fns-adapter",
40+
"@angular/youtube-player",
41+
42+
# Third-party libraries.
43+
"kagekiri",
44+
"moment",
45+
"moment/locale/fr",
46+
"moment/locale/ja",
47+
"luxon",
48+
"date-fns",
49+
"protractor",
50+
"rxjs",
51+
"rxjs/operators",
52+
"selenium-webdriver",
53+
]
54+
55+
# Configures the externals for all MDC packages.
56+
def setup_mdc_externals():
57+
for pkg_name in MDC_PACKAGES:
58+
PKG_EXTERNALS.append(pkg_name)
59+
60+
# Creates externals for a given package and its entry-points.
61+
def setup_entry_point_externals(packageName, entryPoints):
62+
PKG_EXTERNALS.extend(["@angular/%s/%s" % (packageName, ep) for ep in entryPoints])
63+
64+
setup_mdc_externals()
65+
66+
setup_entry_point_externals("cdk", CDK_ENTRYPOINTS)
67+
setup_entry_point_externals("cdk-experimental", CDK_EXPERIMENTAL_ENTRYPOINTS)
68+
setup_entry_point_externals("material", MATERIAL_ENTRYPOINTS + MATERIAL_TESTING_ENTRYPOINTS)
69+
setup_entry_point_externals(
70+
"material-experimental",
71+
MATERIAL_EXPERIMENTAL_ENTRYPOINTS + MATERIAL_EXPERIMENTAL_TESTING_ENTRYPOINTS,
72+
)
73+
74+
# External module names in the examples package. Individual examples are grouped
75+
# by package and component, so we add configure such entry-points as external.
76+
setup_entry_point_externals("components-examples/cdk", CDK_ENTRYPOINTS)
77+
setup_entry_point_externals("components-examples/cdk-experimental", CDK_EXPERIMENTAL_ENTRYPOINTS)
78+
setup_entry_point_externals(
79+
"components-examples/material",
80+
MATERIAL_ENTRYPOINTS + MATERIAL_TESTING_ENTRYPOINTS,
81+
)
82+
setup_entry_point_externals(
83+
"components-examples/material-experimental",
84+
MATERIAL_EXPERIMENTAL_ENTRYPOINTS + MATERIAL_EXPERIMENTAL_TESTING_ENTRYPOINTS,
85+
)

rollup-globals.bzl

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

0 commit comments

Comments
 (0)