I have created a number of React components which wrap Material-UI components and are packaged as an NPM module.
The module works fine when installed via the remote package: npm install *name-of-package*
, or via local install: npm install ../*name-of-package*
.
For module development, however, I would like to use npm link
so that I can use webpack --watch
/ webpack-dev-server
etc in the module and site directories.
To do so, I am running npm link
to create a symlink in the module directory, and then npm link *name-of-package*
in the site directory. Webpack starts as expected, however I keep encountering errors in the browser related to MUI's withStyles
function:
Uncaught TypeError: Cannot read property '@global' of undefined
referring to the var rules = style[propKey];
line of the function handleNestedGlobalContainerRule(rule)
.
And other such as: The above error occurred in the <WithStyles(Typography)> component
From what I can tell from similar posts this is complaining about the absence of theme
object (the site has a MuiThemeProvider
with a theme object declared).
Can anyone suggest why this might be working with npm install
and not npm link
? I cannot seem to figure this one out.