-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Conversation
All 636 screenshot tests passed for commit cc2224c vs. |
…tion, types, adapter, etc
…r foundation, types, adapter, etc" This reverts commit 3f70c99.
All 636 screenshot tests passed for commit 3f70c99 vs. |
All 636 screenshot tests passed for commit 3dedadd vs. |
packages/mdc-chips/chip-set/index.ts
Outdated
@@ -23,4 +23,8 @@ | |||
|
|||
export * from './adapter'; | |||
export * from './component'; | |||
export { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another idea would be for all of them do something like: export * as chipSetConstants from './constants';
. That way you don't have to rename all the individual symbols.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I like that idea...I"ll try that out :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that syntax actually works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting looks like you're right. I assumed it would since that style syntax works for import. In that case I think you could accomplish the same thing like this:
import * as chipSetConstants from './constants';
export {chipSetConstants};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah - I did try that but I forgot the *
...Not as clean as your original, but better than manually naming everything.
packages/mdc-tabs/tab-bar/index.ts
Outdated
@@ -23,5 +23,9 @@ | |||
|
|||
export * from './adapter'; | |||
export * from './component'; | |||
export { | |||
strings as tabBartrings, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tabBarStrings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're at it, we could also solve another problem for CDN users & consumers who directly consume dist/
build.
Problem
Since we're not exporting constants (cssClasses
, strings
, etc.) consumers have to rely on foundation static methods (e.g., MDCFooFoundation.cssClasses
) to access these constants. This is additional cost of bundle size and maintenance.
Proposal
Every constant file will have a default export with namespace prefix and named exports (for backward compatibility).
export {cssClasses, strings, numbers, CornerBit, Corner};
const MDCMenuSurfaceConstants = {cssClasses, strings, numbers, CornerBit, Corner};
export default MDCMenuSurfaceConstants;
Usage:
import MDCMenuSurfaceConstants from './constants';
const {cssClasses, strings} = MDCMenuSurfaceConstants;
This will also avoid variable name clashing when exporting multiple cssClasses
from different components.
Usage with UMD Module:
mdc.menuSurface.MDCMenuSurfaceConstants.cssClasses;
With this change as is, you should already be able to do something like:
Is that what you were proposing? |
All 636 screenshot tests passed for commit ff92450 vs. |
…mponents/material-components-web into chore/export-constants-index
All 636 screenshot tests passed for commit c5a18c8 vs. |
All 639 screenshot tests passed for commit 1dba3a2 vs. |
Codecov Report
@@ Coverage Diff @@
## master #4593 +/- ##
=========================================
- Coverage 99.26% 98.97% -0.3%
=========================================
Files 129 129
Lines 6294 6329 +35
Branches 821 821
=========================================
+ Hits 6248 6264 +16
- Misses 45 64 +19
Partials 1 1
Continue to review full report at Codecov.
|
All 642 screenshot tests passed for commit bb3f76e vs. |
All 645 screenshot tests passed for commit a2d7013 vs. |
We've decided to go the route of exporting all constants as |
All 645 screenshot tests passed for commit 16060ff vs. |
All 645 screenshot tests passed for commit 2641482 vs. |
All 645 screenshot tests passed for commit 6857c65 vs. |
All 645 screenshot tests passed for commit 408f681 vs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with one comment.
Since this is a breaking change, rebase your changes to develop
branch.
packages/mdc-chips/chip-set/index.ts
Outdated
export * from './adapter'; | ||
export * from './component'; | ||
export * from './foundation'; | ||
export {chipSetCssClasses, chipSetStrings}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can directly export without additional import statement.
export {cssClasses as chipSetCssClasses, strings as chipSetStrings} from './constants';
Also, Add |
I dont think this is a breaking change. This is a new feature, so its not going to break anyone currently using our components. |
…mponents/material-components-web into chore/export-constants-index
All 687 screenshot tests passed for commit e9016ec vs. |
All 687 screenshot tests passed for commit bbe16e8 vs. |
fixes #4579