-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: update default npm export to ES5 js files #3245
Conversation
@@ -9,7 +9,6 @@ | |||
"material design", | |||
"tab" | |||
], | |||
"main": "index.js", |
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.
removed this because this isn't a package. Developer should be installing mdc-tabs
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.
This is incorrect. mdc-tab is part of the new tabs work being done in the feat/tabs/tabs branch. Users will be installing this as well as mdc-tab-bar, mdc-tab-scroller, and mdc-tab-indicator.
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 gotcha...I saw the export {MDCTabFoundation, MDCTab} from './tab';
line in mdc-tabs, and thought it to be this mdc-tab package. Just missing a .
to become ../tab
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.
This was never updated after my comment. Also, mdc-tab-bar, mdc-tab-scroller, and mdc-tab-indicator were added since this.
All 128 screenshot tests passed for commit b55f5cc vs. |
Codecov Report
@@ Coverage Diff @@
## master #3245 +/- ##
=======================================
Coverage 98.46% 98.46%
=======================================
Files 120 120
Lines 5212 5212
Branches 654 654
=======================================
Hits 5132 5132
Misses 80 80 Continue to review full report at Codecov.
|
All 128 screenshot tests passed for commit e43c556 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.
I would rather hold off on merging this until we can try and test a few things...
For instance, does this actually break every README we have which states import {MDCFoo} from '@material/foo';
because main
no longer points to the main ES6 module?
I think we'll also need to do a similar change as this PR: material-components/material-components-web-react#198 |
That's precisely the kind of thing I'm concerned about. I think that corroborates my concern about needing to update any ES2015 examples in our READMEs, because they would need to explicitly point to Incidentally, our modules themselves should already be referencing |
Would we want to point to the Currently our readmes don't point to |
Do transpilers honor |
I wrote up a blog post of my learnings of the benefits of having npm packages export ES5 instead of ES6. https://medium.com/@moog16/rules-of-npm-packaging-16a40c5d7e30 |
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.
This is out of date with master and it looks like there are potentially some merge conflicts that are going to happen, based on what github is saying.
Also note that we've added more packages since this was opened (e.g. the new mdc-tab* packages, mdc-switch JS, and mdc-menu-surface).
Also, I don't know why this wasn't reported in CI, but I see a lot of test failures when I run unit tests locally. I also see incorrect coverage reports (and coverage well below the required 95% mark). Some of the coverage reports are now pointing to dist
. I assume this is due to needing tests to explicitly reference mdc-foo/index
after these changes, similar to material-components/material-components-web-react#198. (It concerns me that apparently the MDC React repo went over an entire month without correct coverage... we can't do that with MDC Web.)
I'm also still wanting to understand how our documented ES6 syntax still happens to work even when the entry point references the UMD files. I'd also like to know whether our getting started guide is impacted by this change at all.
@@ -9,7 +9,6 @@ | |||
"material design", | |||
"tab" | |||
], | |||
"main": "index.js", |
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.
This was never updated after my comment. Also, mdc-tab-bar, mdc-tab-scroller, and mdc-tab-indicator were added since this.
@@ -3,6 +3,7 @@ | |||
"version": "0.37.1", | |||
"description": "The Material Components for the web top app bar component", | |||
"license": "Apache-2.0", | |||
"main": "mdc.topAppBar.js", |
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.
Missing dist
?
All 353 screenshot tests passed for commit 21955dd vs. |
packages/mdc-form-field/package.json
Outdated
@@ -8,7 +8,7 @@ | |||
"material design", | |||
"form" | |||
], | |||
"main": "index.js", | |||
"main": "mdc.formField.js", |
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.
Missing dist
@@ -3,6 +3,7 @@ | |||
"description": "The Material Components for the web linear progress indicator component", | |||
"version": "0.38.0", | |||
"license": "MIT", | |||
"main": "dist/linearProgress.js", |
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.
Missing mdc.
All 353 screenshot tests passed for commit cc1ee56 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.
Since we're pointing all packages to compiled version, can we have module
property which points to ES6 for ES6 aware tool like webpack?
Reference: Rollup.js - Publishing ES6 modules
All 353 screenshot tests passed for commit 39f9f31 vs. |
Pushed changes and performed following: Linux: Windows:
|
All 353 screenshot tests passed for commit 2e58cd5 vs. |
All 581 screenshot tests passed for commit 853f2d5 vs. |
docs/importing-js.md
Outdated
``` | ||
|
||
Note that in this case, you must ensure your build toolchain is configured to process and transpile MDC Web's modules | ||
as well as your own. You will also need to include babel's `transform-object-assign` plugin for IE 11 support. |
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.
This piece of info should also be in the getting-started.md
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.
Yeah, I had intended to look into the right place to add that to getting-started, thanks for reminding me.
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've fixed that in #3665, since that PR was already touching the lines around that point in the file. That way hopefully it'll merge cleanly the next time we sync this PR.
@@ -0,0 +1,66 @@ | |||
/** |
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.
awesome script! Tested it and works nicely
All 581 screenshot tests passed for commit ecacefc vs. |
All 581 screenshot tests passed for commit b1c6e83 vs. |
Matt performed some tests with various build tools (e.g. browserify and webpack), and I tested this against our catalog and getting started guide. Between that and getting positive feedback from James on RMWC and Dominic on angular-mdc-web, I think we can merge this. |
All 581 screenshot tests passed for commit 44dde56 vs. |
All 581 screenshot tests passed for commit 7fcf8f1 vs. |
All 581 screenshot tests passed for commit 3cbdb21 vs. |
Currently npm is setup to export /index.js by default. The index.js file is ES6 and less universally accepted by other developers. This PR is to support those developers that are on other versions of EcmaScript, by exporting by default the dist js file.
Refs #929
See also material-components/material-components-web-react#107
BREAKING CHANGE: Anyone intending to build MDC Web's ES2015+ sources must directly import
@material/foo/index
.@material/foo
will now resolve to UMD modules.