-
Notifications
You must be signed in to change notification settings - Fork 227
ReferenceError: Element is not defined on SSR #561
Comments
There was an issue a while back where someone couldn't render the list correctly because of minification (#492). What does the |
In the minified code it doesn't have the
Yeah, this should work. Also, it would be nice to have a test case covering this issue, so it doesn't happen again accidentally. |
function _(module,exports) {
var candidateSelectors = ['input','select','textarea','a[href]','button','[tabindex]','audio[controls]','video[controls]','[contenteditable]:not([contenteditable="false"])'];
var candidateSelector = candidateSelectors.join(',');
var matches = Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
function tabbable(el,options) {
// ...
}
// ...
} This is how the |
So this effectively disappears? |
Yeah, exactly. |
Also I think we switched from |
I have an idea: add this package to the externals during the |
adding it as an external mean it'll be a peer dependency? |
Adding it as a dep to this object: https://github.com/material-components/material-components-web-react/blob/master/packages/webpack.config.js#L89 |
* Add material design icons * Add categories nav * Fix Drawer SSR Issues: - material-components/material-components-web-react#561
Hi, I just saw this and realized it's related to the poorly worded issues I filed. Maybe it would help to reference them here: #462 material-components/material-components-web#4104 |
Thanks @4cm4k1! Seems like it is a MDC Web issue not react issue. I still haven't had the chance to look into this one. I will deprioritize this on my end since its Web related. |
@moog16 @4cm4k1 issue material-components/material-components-web#4104 has been resolved, the fix (upgrading focus-trap dependency for the drawer and dialog components have been merged. We need to await a new release and bump the mdc-web dependency accordingly to resolve this for materila-components-web-react. |
@alexanderjeurissen MDC Web will release their next cut this Monday. We will be skipping v0.42.0 and going straight to v0.43.0. |
This hasn't been slated for 0.9.0 but seems like a blocker for some people. Can someone update to 0.43.0 when it is landed next week? The main contributors of this project are moving to MDC Web's typescript conversion project (which will last for about 1 - 3 months). All issues/prs will be reviewed, however we will not be able to contribute. I will add more detail in our Roadmap, but just wanted to see if there are any volunteers who could fix this. |
@moog16 Is it just updating the package.json to use 0.43.0 of MDC Web? Or I guess I'll see what you add to the roadmap. Since most of these SSR things are kinda blockers for me, I'd be happy to volunteer to help with this. |
awesome! Yes its updating to 0.43.0 (come 1/7/19). I don't think drawer has any actual changes. |
0.43.0 released today! |
So, I've figured that with the code from #706, you can add the following to your {
"resolutions": {
"@material/ripple": "1.0.0-0",
"@material/tab-scroller": "1.0.0-0",
"@material/drawer": "1.0.0-0"
}
} If you do not want to wait for the code to be released, you can edit: This, of course, will only work for local development, if you use a cloud-based platform for your development or have tests running in a CI, they will break. |
Wow, awesome! Thanks, @lucasecdb! Also, thanks @moog16; I'm sorry I didn't have time to continue working on my PR related to this. I started a new software engineering job, so that has been taking a lot of my time lately, though I think as I settle in there, I will be able to spend more of my time on GitHub again. 💜 |
@lucasecdb thanks for finding a fix for this. I finally have some more bandwidth now that we will be releasing 1.0.0 next week. Going to try upgrading all the packages. :) |
Hello, I'm getting a
ReferenceError: Element is not defined
when I try to SSR the Drawer component, running on version 0.7.1.The issue is probably some optimization on the webpack build process where it removes "dead-code", because the error occurs on the
tabbable
npm package, imported fromfocus-trap
, specifically on this line. But, as you can see, it has a check specifically to avoid this issue when running on node environments. I have checked the minified code and have confirmed that the check for thetypeof Element
is optimized away.Unfortunately I don't have a reproducible codesandbox snippet as it doesn't execute the code with SSR 😔
The text was updated successfully, but these errors were encountered: