Skip to content

Commit ef98f3e

Browse files
crisbetowagnermaciel
authored andcommitted
build: clean up MDC exports config (#23107)
Most of the exports we've excluded from the exports config are underscored APIs. These changes add an option that allows us to exclude exports based on on a regex and removes the underscored APIs from the config since they're private anyway. (cherry picked from commit c958afd)
1 parent a685559 commit ef98f3e

File tree

2 files changed

+9
-106
lines changed

2 files changed

+9
-106
lines changed

scripts/check-mdc-exports-config.ts

Lines changed: 3 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
export const config = {
22
// The MDC sidenav hasn't been implemented yet.
33
skippedPackages: ['mdc-sidenav'],
4+
// We have to export some underscored symbols so that they can be used with MDC.
5+
// Exclude them from this check since they aren't part of the public API.
6+
skippedSymbols: [/^_/],
47
skippedExports: {
58
'mdc-chips': [
69
// These components haven't been implemented for MDC due to a different accessibility pattern.
@@ -12,114 +15,11 @@ export const config = {
1215
'MatChipListHarness',
1316
'ChipListHarnessFilters'
1417
],
15-
'mdc-autocomplete': [
16-
// Private base classes that are only exported for MDC.
17-
'_MatAutocompleteBase',
18-
'_MatAutocompleteTriggerBase',
19-
'_MatAutocompleteOriginBase'
20-
],
21-
'mdc-autocomplete/testing': [
22-
// Private base classes that are only exported for MDC.
23-
'_MatAutocompleteHarnessBase'
24-
],
25-
'mdc-core': [
26-
// Private base classes that are only exported for MDC.
27-
'_MatOptionBase',
28-
'_MatOptgroupBase'
29-
],
30-
'mdc-dialog': [
31-
// Private base classes and utility function that are only exported for MDC.
32-
'_MatDialogBase',
33-
'_MatDialogContainerBase',
34-
'_closeDialogVia',
35-
],
36-
'mdc-form-field/testing': [
37-
// Private base class that is only exported for MDC.
38-
'_MatFormFieldHarnessBase'
39-
],
40-
'mdc-menu': [
41-
// Private base class that is only exported for MDC.
42-
'_MatMenuBase'
43-
],
44-
'mdc-menu/testing': [
45-
// Private base class that is only exported for MDC.
46-
'_MatMenuHarnessBase',
47-
'_MatMenuItemHarnessBase'
48-
],
49-
'mdc-paginator': [
50-
// Private base class that is only exported for MDC.
51-
'_MatPaginatorBase'
52-
],
53-
'mdc-paginator/testing': [
54-
// Private base class that is only exported for MDC.
55-
'_MatPaginatorHarnessBase'
56-
],
57-
'mdc-radio': [
58-
// Private base classes that are only exported for MDC.
59-
'_MatRadioGroupBase',
60-
'_MatRadioButtonBase',
61-
],
62-
'mdc-radio/testing': [
63-
// Private base classes that are only exported for MDC.
64-
'_MatRadioGroupHarnessBase',
65-
'_MatRadioButtonHarnessBase',
66-
],
67-
'mdc-select': [
68-
// Private base class that is only exported for MDC.
69-
'_MatSelectBase'
70-
],
71-
'mdc-select/testing': [
72-
// Private base class that is only exported for MDC.
73-
'_MatSelectHarnessBase'
74-
],
75-
'mdc-slide-toggle': [
76-
// Private module used to provide some common functionality.
77-
'_MatSlideToggleRequiredValidatorModule'
78-
],
79-
'mdc-slide-toggle/testing': [
80-
// Private base class that is only exported for MDC.
81-
'_MatSlideToggleHarnessBase'
82-
],
8318
'mdc-slider': [
8419
// ControlValueAccessor implementation detail.
8520
'MAT_SLIDER_VALUE_ACCESSOR',
8621
// Irrelevant for the MDC implementation, because the slider doesn't dispatch any events.
8722
'MatSliderChange'
88-
],
89-
'mdc-snack-bar': [
90-
// Private interface used to ensure consistency for MDC package.
91-
'_SnackBarContainer'
92-
],
93-
'mdc-tabs': [
94-
// Private base classes that are only exported for MDC.
95-
'_MatTabBodyBase',
96-
'_MatTabHeaderBase',
97-
'_MatTabNavBase',
98-
'_MatTabLinkBase',
99-
'_MatTabGroupBase'
100-
],
101-
'mdc-table': [
102-
// Private symbols that are only exported for MDC.
103-
'_MatTableDataSource',
104-
'_MAT_TEXT_COLUMN_TEMPLATE'
105-
],
106-
'mdc-table/testing': [
107-
// Private symbols that are only exported for MDC.
108-
'_MatTableHarnessBase',
109-
'_MatRowHarnessBase'
110-
],
111-
'mdc-tooltip': [
112-
// Private symbols that are only exported for MDC.
113-
'_MatTooltipBase',
114-
'_TooltipComponentBase'
115-
],
116-
'mdc-tooltip/testing': [
117-
// Private symbols that are only exported for MDC.
118-
'_MatTooltipHarnessBase'
119-
],
120-
'mdc-checkbox/testing': [
121-
// Private symbols that are only exported for MDC.
122-
'_MatCheckboxHarnessBase'
12323
]
12424
}
12525
};

scripts/check-mdc-exports.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ if (hasFailed) {
4040

4141
/** Checks whether the public API of a package matches up with its MDC counterpart. */
4242
function checkPackage(name: string) {
43-
const missingSymbols = getMissingSymbols(name, config.skippedExports[`mdc-${name}`] || []);
43+
const missingSymbols = getMissingSymbols(name,
44+
config.skippedExports[`mdc-${name}`] || [],
45+
config.skippedSymbols || []);
4446

4547
if (missingSymbols.length) {
4648
console.log(chalk.redBright(`\nMissing symbols from mdc-${name}:`));
@@ -53,7 +55,7 @@ function checkPackage(name: string) {
5355
* Gets the names of symbols that are present in a Material package,
5456
* but not its MDC counterpart.
5557
*/
56-
function getMissingSymbols(name: string, skipped: string[]): string[] {
58+
function getMissingSymbols(name: string, skipped: string[], skippedPatterns: RegExp[]): string[] {
5759
const mdcExports = getExports(`material-experimental/mdc-${name}`);
5860
const materialExports = getExports(`material/${name}`);
5961

@@ -66,7 +68,8 @@ function getMissingSymbols(name: string, skipped: string[]): string[] {
6668
}
6769

6870
return materialExports.filter(exportName => {
69-
return !skipped.includes(exportName) && !mdcExports.includes(exportName);
71+
return !skipped.includes(exportName) && !mdcExports.includes(exportName) &&
72+
!skippedPatterns.some(pattern => pattern.test(exportName));
7073
});
7174
}
7275

0 commit comments

Comments
 (0)