docz: v2: Pages crash with Material-UI installed
Bug Report
Describe the bug
When creating a new project with Material-UI installed, pages crash on load when running the dev server. Omitting Material-UI causes docz to work as expected. This occurs even with the MDX file below where Material-UI is not imported.
Downgrading to docz 1.2.0 (and installing docz-theme-default) causes the page to load as expected.
To Reproduce
(reproduction repo available here)
- Create the following files:
package.json:
{
"name": "docz-v2-mui-bug",
"version": "1.0.0",
"scripts": {
"dev": "docz dev",
"build": "docz build"
},
"dependencies": {
"@material-ui/core": "^4.2.1",
"docz": "^2.0.0-rc.1",
"react": "^16.8.6",
"react-dom": "^16.8.6"
}
}
home.mdx:
---
name: Hello world
route: /
---
# Hello world
Hello, I'm a mdx file!
- Install dependencies (I’m running
yarn) - Run the dev server (I’m running
yarn run dev) - Wait for docz to download dependencies and start the dev server
In the docz console, no errors are reported, but the following error is displayed in the browser console and rendered on the page:
Uncaught TypeError: e is not a function
at ./node_modules/compass-vertical-rhythm/dist/index.js.module.exports (index.js:1)
at toTheme (index.esm.js:239)
at Module.<anonymous> (index.js:1)
at Module../node_modules/gatsby-theme-docz/src/theme/index.js (index.js:1)
at __webpack_require__ (bootstrap:723)
at fn (bootstrap:100)
at Module.<anonymous> (index.js:1)
at Module../node_modules/gatsby-theme-docz/src/index.js (index.js:1)
at __webpack_require__ (bootstrap:723)
at fn (bootstrap:100)
at Module.<anonymous> (Layout.js:1)
at Module../node_modules/gatsby-theme-docz/src/base/Layout.js (Layout.js:1)
at __webpack_require__ (bootstrap:723)
at fn (bootstrap:100)
at Module.<anonymous> (bootstrap:790)
at Module.../home.mdx (home.mdx:18)
at __webpack_require__ (bootstrap:723)
at fn (bootstrap:100)
at Object.<anonymous> (sync-requires.js:4)
at Object../.cache/sync-requires.js (sync-requires.js:4)
at __webpack_require__ (bootstrap:723)
at fn (bootstrap:100)
at Module.<anonymous> (app.js:1)
at Module../.cache/app.js (app.js:38)
at __webpack_require__ (bootstrap:723)
at fn (bootstrap:100)
at Object.0 (404.js:1)
at __webpack_require__ (bootstrap:723)
at bootstrap:790
at bootstrap:790
index.js:2177 hot update failed for module "./.cache/sync-requires.js". Last file processed: "./node_modules/gatsby-theme-docz/src/theme/index.js".

Expected behavior
The server starts and displays the home page without any errors.
Environment
- OS: Windows 10
- Node/npm version: 12.4.0
- Yarn version: 1.16.0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 17 (6 by maintainers)
Thanks @oliviertassinari for asking !
I narrowed it down to being a problem with
dom-helpersimports not resolving to the right version when two different versions were installed.docz->gatsby->gatsby-react-router-scroll->scroll-behaviordepends on the older3.4.0and
@material-ui/core->react-transition-groupdepends on5.1.2which has some understandable breaking changes.Both versions are in node_modules :
node_modules/dom-helpers/-> 5.1.2and
node_modules/scroll-behavior/node_modules/dom-helpers/-> 3.4.0But are not being resolved correctly by
gatsby(I think)The easiest way I could think of to get this fixed was to submit a PR to
scroll-behaviorthat updatesdom-helpersbut it turned out thescrollTopmethod indom-helpersv5 doesn’t behave like v3.So I opened these 2 PRs to attempt to fix this :
dom-helpersscroll-behaviorAny update on this?
@rakannimer works as expected! Thanks so much.
Hey all !
Sorry for the late reply.
The reason for the problem is that
doczandmaterial-uihave conflicting dependencies for theconvert-css-lengthmodule.The quick fix is to patch
convert-css-length.If you’re starting from scratch with Material UI + Docz
npx create-docz-app my-material-ui-docz --example material-uiIf you’re adding docz to an existing project with material-ui
patch-packageandpostinstall-postinstallto your dev dependencies:patch-packageevery-time an install occurs, in your package.json :convert-css-lengthpatch to your project