forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup-globals.bzl
103 lines (92 loc) · 4.11 KB
/
rollup-globals.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
load("//src/cdk:config.bzl", "CDK_ENTRYPOINTS")
load("//src/cdk-experimental:config.bzl", "CDK_EXPERIMENTAL_ENTRYPOINTS")
load("//src/material:config.bzl", "MATERIAL_ENTRYPOINTS", "MATERIAL_TESTING_ENTRYPOINTS")
load(
"//src/material-experimental:config.bzl",
"MATERIAL_EXPERIMENTAL_ENTRYPOINTS",
"MATERIAL_EXPERIMENTAL_TESTING_ENTRYPOINTS",
)
load("//:packages.bzl", "MDC_PACKAGE_UMD_BUNDLES")
# Base rollup globals for everything in the repo. Note that we want to disable
# sorting of the globals as we manually group dict entries.
# buildifier: disable=unsorted-dict-items
ROLLUP_GLOBALS = {
# Framework packages.
"@angular/animations": "ng.animations",
"@angular/common": "ng.common",
"@angular/common/http": "ng.common.http",
"@angular/common/http/testing": "ng.common.http.testing",
"@angular/common/testing": "ng.common.testing",
"@angular/core": "ng.core",
"@angular/core/testing": "ng.core.testing",
"@angular/forms": "ng.forms",
"@angular/platform-browser": "ng.platformBrowser",
"@angular/platform-browser-dynamic": "ng.platformBrowserDynamic",
"@angular/platform-browser-dynamic/testing": "ng.platformBrowserDynamic.testing",
"@angular/platform-browser/animations": "ng.platformBrowser.animations",
"@angular/platform-server": "ng.platformServer",
"@angular/router": "ng.router",
# Primary entry-points in the project.
"@angular/cdk": "ng.cdk",
"@angular/cdk-experimental": "ng.cdkExperimental",
"@angular/google-maps": "ng.googleMaps",
"@angular/material": "ng.material",
"@angular/material-experimental": "ng.materialExperimental",
"@angular/material-moment-adapter": "ng.materialMomentAdapter",
"@angular/material-luxon-adapter": "ng.materialLuxonAdapter",
"@angular/material-date-fns-adapter": "ng.materialDateFnsAdapter",
"@angular/youtube-player": "ng.youtubePlayer",
# Third-party libraries.
"kagekiri": "kagekiri",
"moment": "moment",
"moment/locale/fr": "moment.locale.fr",
"moment/locale/ja": "moment.locale.ja",
"luxon": "luxon",
"date-fns": "dateFns",
"protractor": "protractor",
"rxjs": "rxjs",
"rxjs/operators": "rxjs.operators",
"selenium-webdriver": "selenium-webdriver",
}
# Converts a string from dash-case to lower camel case.
def to_lower_camel_case(input):
segments = input.split("-")
return segments[0] + "".join([x.title() for x in segments[1:]])
# Configures the rollup globals for all MDC packages.
def setup_mdc_globals():
for pkg_name in MDC_PACKAGE_UMD_BUNDLES:
entry_point_name = pkg_name[len("@material/"):]
pkg_umd_name = "mdc.%s" % to_lower_camel_case(entry_point_name)
ROLLUP_GLOBALS.update({pkg_name: pkg_umd_name})
# Converts an entry-point name to a UMD module name.
# e.g. "snack-bar/testing" will become "snackBar.testing".
def to_umd_name(name):
segments = name.split("/")
return ".".join([to_lower_camel_case(x) for x in segments])
# Creates globals for a given package and its entry-points.
def create_globals(packageName, entryPoints):
ROLLUP_GLOBALS.update({
"@angular/%s/%s" % (packageName, ep): "ng.%s.%s" % (to_umd_name(packageName), to_umd_name(ep))
for ep in entryPoints
})
setup_mdc_globals()
create_globals("cdk", CDK_ENTRYPOINTS)
create_globals("cdk-experimental", CDK_EXPERIMENTAL_ENTRYPOINTS)
create_globals("material", MATERIAL_ENTRYPOINTS + MATERIAL_TESTING_ENTRYPOINTS)
create_globals(
"material-experimental",
MATERIAL_EXPERIMENTAL_ENTRYPOINTS + MATERIAL_EXPERIMENTAL_TESTING_ENTRYPOINTS,
)
# Rollup globals the examples package. Since individual examples are
# grouped by package and component, the primary entry-point imports
# from entry-points which should be treated as external imports.
create_globals("components-examples/cdk", CDK_ENTRYPOINTS)
create_globals("components-examples/cdk-experimental", CDK_EXPERIMENTAL_ENTRYPOINTS)
create_globals(
"components-examples/material",
MATERIAL_ENTRYPOINTS + MATERIAL_TESTING_ENTRYPOINTS,
)
create_globals(
"components-examples/material-experimental",
MATERIAL_EXPERIMENTAL_ENTRYPOINTS + MATERIAL_EXPERIMENTAL_TESTING_ENTRYPOINTS,
)