forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
packages.bzl
72 lines (60 loc) · 2.8 KB
/
packages.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Each individual package uses a placeholder for the version of Angular to ensure they're
# all in-sync. This map is passed to each ng_package rule to stamp out the appropriate
# version for the placeholders.
ANGULAR_PACKAGE_VERSION = "^11.0.0-0 || ^12.0.0-0"
MDC_PACKAGE_VERSION = "^8.0.0-canary.911014711.0"
TSLIB_PACKAGE_VERSION = "^2.0.0"
VERSION_PLACEHOLDER_REPLACEMENTS = {
"0.0.0-MDC": MDC_PACKAGE_VERSION,
"0.0.0-NG": ANGULAR_PACKAGE_VERSION,
"0.0.0-TSLIB": TSLIB_PACKAGE_VERSION,
}
# List of default Angular library UMD bundles which are not processed by ngcc.
ANGULAR_NO_NGCC_BUNDLES = [
("@angular/compiler", ["compiler.umd.js"]),
]
# List of Angular library UMD bundles which will are processed by ngcc.
ANGULAR_NGCC_BUNDLES = [
("@angular/animations", ["animations-browser.umd.js", "animations.umd.js"]),
("@angular/common", ["common-http-testing.umd.js", "common-http.umd.js", "common-testing.umd.js", "common.umd.js"]),
("@angular/compiler", ["compiler-testing.umd.js"]),
("@angular/core", ["core-testing.umd.js", "core.umd.js"]),
("@angular/elements", ["elements.umd.js"]),
("@angular/forms", ["forms.umd.js"]),
("@angular/platform-browser-dynamic", ["platform-browser-dynamic-testing.umd.js", "platform-browser-dynamic.umd.js"]),
("@angular/platform-browser", ["platform-browser.umd.js", "platform-browser-testing.umd.js", "platform-browser-animations.umd.js"]),
("@angular/router", ["router.umd.js"]),
]
"""
Gets a dictionary of all packages and their bundle names.
"""
def getFrameworkPackageBundles():
res = {}
for pkgName, bundleNames in ANGULAR_NGCC_BUNDLES + ANGULAR_NO_NGCC_BUNDLES:
res[pkgName] = res.get(pkgName, []) + bundleNames
return res
"""
Gets a list of labels which resolve to the UMD bundles of the given packages.
"""
def getUmdFilePaths(packages, ngcc_artifacts):
tmpl = "@npm//:node_modules/%s" + ("/__ivy_ngcc__" if ngcc_artifacts else "") + "/bundles/%s"
return [
tmpl % (pkgName, bundleName)
for pkgName, bundleNames in packages
for bundleName in bundleNames
]
ANGULAR_PACKAGE_BUNDLES = getFrameworkPackageBundles()
ANGULAR_LIBRARY_VIEW_ENGINE_UMDS = getUmdFilePaths(ANGULAR_NO_NGCC_BUNDLES, False) + \
getUmdFilePaths(ANGULAR_NGCC_BUNDLES, False)
ANGULAR_LIBRARY_IVY_UMDS = getUmdFilePaths(ANGULAR_NO_NGCC_BUNDLES, False) + \
getUmdFilePaths(ANGULAR_NGCC_BUNDLES, True)
"""
Gets the list of targets for the Angular library UMD bundles. Conditionally
switches between View Engine or Ivy UMD bundles based on the
"--config={ivy,view-engine}" flag.
"""
def getAngularUmdTargets():
return select({
"//tools:view_engine_mode": ANGULAR_LIBRARY_VIEW_ENGINE_UMDS,
"//conditions:default": ANGULAR_LIBRARY_IVY_UMDS,
})