odoe / jsapi-webpack

Sample using the webpack plugin with babel
20 stars 10 forks source link

Compatibility with react packages (material-ui) #10

Open mayteio opened 5 years ago

mayteio commented 5 years ago

This works great out of the box, however, when I try to include common react packages (material-ui in this case) I get a string of errors.

First, when including any Material-UI component I get a duplicate module error (module warning included twice).

To fix this, I create an alias for warning:

resolve: {
    ...
    alias: {
      warning: path.resolve(__dirname, "node_modules/warning")
    }
  },

This creates a new error - global is not defined. So I create global via a newly defined webpack plugin:

plugins: [
    new webpack.DefinePlugin({
      global: {}
    }),
    ...
]

This compiles, but I get the error TypeError: node.addEventListener is not a function.

This is caused when the DOM node isn't instantiated before adding an event listener. This comes back to the addDOMNode function that bootstraps the app.

Any ideas on how to resolve this?

odoe commented 5 years ago

I'll come back to looking at this again once I finish some other things. The core issue is they, like some other libs are using node globals like global and it breaks some other stuff in the API with webpack builds. We have to ignore global and others in order to build properly. I'll circle back this soon, but I am totally open to suggestions.

This is the main reason I have been using rmwc for material components and it works great.

mayteio commented 5 years ago

Thanks for the direction. I've never come across rmwc before, will check it out.

mpdrury commented 5 years ago

Have you had a chance to come back to looking at this again?

I am seeing the same TypeError: node.addEventListener is not a function described above. I am not using material-ui, but am trying to integrate into an existing 'dashboard' configuration that utilizes many different react packages. This complex dashboard it making it difficult for me to track down the real cause for this 'TypeError.'

odoe commented 5 years ago

I haven't been able to work around libraries that are exposing node global. There has been a couple of other libraries that do this and they currently conflict with our web assembly modules. I have no fix.