[WIP] example with Material Web Components#42
Draft
thescientist13 wants to merge 6 commits intomasterfrom
Draft
Conversation
29eb4f1 to
9c09f12
Compare
5 tasks
This was referenced Sep 6, 2021
This was referenced Oct 4, 2021
5 tasks
9c09f12 to
d8f6e0c
Compare
0ea2910 to
a2b15cd
Compare
Merged
6 tasks
a2b15cd to
ef40282
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Per ProjectEvergreen/greenwood#523 wanted to get an example of Material Web Components working with Greenwood. The intent isn't to merge this PR, but rather provide an example and demonstration for how to add it to a Greenwood project.
Steps
For the most part, I only had to follow the Quick start from the README and following their example
importthe component and it dependencies in a templateKnown Issues
TSLib ESM compatibility (development only)
Looks like there is an issue pulling in tsllib because of a no default export error

Seemingly because it doesn't point to an ESM compatible file (tslib.js)
(Resolved issues)
Details
Tracking some issues across Greenwood and MWC projectsThen after fixing the JS extensions issue...
Details
### 🚫 Importing (missing?) CSS Currently MWC [directly `import`s CSS](https://github.com/material-components/material-web/issues/2561), which assumes a bundler, which Greenwood [can handle](https://github.com/ProjectEvergreen/greenwood/tree/master/packages/plugin-import-css), but I don't see a [_styles.css_ file in the package though](https://unpkg.com/browse/@material/mwc-button@0.22.1/)? 🔎 👀Example from the screenshot
edit: Ah, this I think relates to the below issue as well 👇 , in that MWC assumes you will resolve @material/mwc-button/styles.css -> @material/mwc-button/styles.css.js (adding the .js extension automatically) 😕
Details
### 🚫 Missing JS Extensions Additionally, MWC references JS files without specifying an extension (which I believe to be required as part of the spec), thus an odd hack is needed like in the **plugin-node-modules** `resolve` method via the `importMap`. ```js if (path.extname(url) === '' && fs.existsSync(path.join(projectDirectory, `${url}.js`))) { url = `${url}.js`; }; ```Same as issue as above and being tracked upstream in ProjectEvergreen/greenwood#700 and material-components/material-web#2632
Details
### ❓ Incorrectly (double) scoped package paths This one looks to be on Greenwood, in that references to scoped packages are getting duplicated(and thus 404)? Example from the screenshot:Getting closer, made this fix in plugin-node-modules
Open issue for the duplicate package entry - ProjectEvergreen/greenwood#748
and now seeing this, so progress? 🤷♂️

Made some progress, found out there was a better way to handle exporting a walked module to grab any exports from its own entry point, like what was needed to resolve
@material/base/foundationTracking in ProjectEvergreen/greenwood#773
Details
### Duplicate Import Map Entries Also seeing duplication in the import map? ```html <script type="importmap-shim"> { "imports": { "tslib": "/node_modules/tslib/modules/index.js", "lit-element": "/node_modules/lit-element/lit-element.js", "@material/mwc-icon/mwc-icon": "/node_modules/@material/mwc-icon/mwc-icon.js", "@material/mwc-ripple/mwc-ripple": "/node_modules/@material/mwc-ripple/mwc-ripple.js", "@material/mwc-ripple/ripple-handlers": "/node_modules/@material/mwc-ripple/ripple-handlers.js", "lit-html/directives/class-map": "/node_modules/lit-html/directives/class-map.js", "@material/mwc-button": "/node_modules/@material/mwc-button/mwc-button.js", "@material/mwc-icon": "/node_modules/@material/mwc-icon/mwc-icon.js", "lit-html/lib/shady-render.js": "/node_modules/lit-html/lib/shady-render.js", "lit-html/lit-html.js": "/node_modules/lit-html/lit-html.js", "lit-html": "/node_modules/lit-html/lit-html.js", "tslib/modules/index.js": "/node_modules/tslib/modules/index.js", "@material/dom/ponyfill": "/node_modules/@material/dom/ponyfill.js", "@material/mwc-base/base-element": "/node_modules/@material/mwc-base/base-element.js", "@material/ripple/foundation": "/node_modules/@material/ripple/foundation.js", "lit-html/directives/style-map": "/node_modules/lit-html/directives/style-map.js", "@material/mwc-ripple": "/node_modules/@material/mwc-ripple/mwc-ripple.js", "@material/dom": "/node_modules/@material/dom/index.js", "@material/mwc-base": "/node_modules/@material/mwc-base/base-element.js", "@material/base": "/node_modules/@material/base/index.js", "@material/ripple": "/node_modules/@material/ripple/index.js", "@material/animation": "/node_modules/@material/animation/index.js" } } </script> ```