Material-ui: Use CJS version of brcast instead of es6

Created on 1 Aug 2017  路  8Comments  路  Source: mui-org/material-ui

Hi,

I recently updated my app to use the newest material-ui beta. Since this uses an es6 version of brcast, the build process (which uses uglifyjs) fails.
brcast actually provides a transpiled version in the dist, which I propose should be used instead of the es6 version. It's an easy fix, since you just need to adjust the require path.

brcast is required in:

  • MuiThemeProvider.js
  • MuiThemeProvider.js.flow
  • material-ui.development.js

Most helpful comment

@semse and @thilorichter-optimizely we ended up fixing the issue, in the webpack section resolve, from the mainFields, we removed the jsnext:main. In the brcast, this points to the index.js instead of the index.cjs.js

All 8 comments

What should we change? Are you sure about that. I haven't had any production build issue with v1-beta.

I tested using react-boilerplate (https://github.com/react-boilerplate/react-boilerplate/tree/master/docs). The build process fails here because brcast isn't transpiled (even though brcast does provide a transpiled version in their dist. It's just not the standard import) and uglifyjs does not support es6. So you can't just plug in material-ui and build for production. Right now I have to manually either adjust the material-ui package to use CJS version of brcast or adjust index.js of brcast, which is not recommended.

If I am missing something here, let me know. I might have some knowledge gaps with babel. Material-ui is the only package that causes this currently though, since it's the only one that requires a module that isn't transpiled.

The change would be to import the commonjs implementation of brc, which can be found in the brccast/dist folder instead of the index.js that is in the brcast folder. That fixes it.

I'm closing, their configuration seems ok:

node_modules/brcast/package.json

  "main": "dist/brcast.cjs.js",
  "module": "dist/brcast.es.js",
  "name": "brcast",

I don't think that we can do anything at the Material-UI level, aside from forking the project, but I would rather avoid it for now.
I believe the issue lies somewhere else. Let us know if you figure out! That would help :).

Seems like react-boilerplate is broken. Use create-react-app or next.js depending on your need, both projects are awesome. We have an example with each of them in the examples directory.

We're facing the same issue with _react-boilerplate_, _material-ui_ version 1.
To solve we're changing the brcast/index.js for the cmj.js version. 馃檨

@semse and @thilorichter-optimizely we ended up fixing the issue, in the webpack section resolve, from the mainFields, we removed the jsnext:main. In the brcast, this points to the index.js instead of the index.cjs.js

Nice! Thats good news.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

finaiized picture finaiized  路  3Comments

pola88 picture pola88  路  3Comments

sys13 picture sys13  路  3Comments

rbozan picture rbozan  路  3Comments

zabojad picture zabojad  路  3Comments