Material-ui: UMD package: export MaterialUI variable

Created on 2 Aug 2018  路  8Comments  路  Source: mui-org/material-ui

Currently to use Material-UI with codepen.io, JSFiddle... you have to write (see https://stackoverflow.com/q/50705423):

const { Button, Input } = window['material-ui'];

This is because the output name inside rollup.config.js is 'material-ui':
https://github.com/mui-org/material-ui/blob/8013fdd36d40980ebb8f116f20e2843b781c0c39/packages/material-ui/scripts/rollup.config.js#L10

Instead it should be a name without -, something like 'MaterialUI':

const { Button, Input } = MaterialUI;

rollup.config.js example:

https://github.com/tkrotoff/react-form-with-constraints/blob/b64119bee6ab80c77417a9284a704b380b81bf5e/packages/react-form-with-constraints/rollup.config.js#L19-L27

Related issue: #7621

breaking change enhancement

Most helpful comment

@tkrotoff This change sounds good to me. However, it's a breaking change. We gonna need to bump the version to v2. I'm adding it into the milestone 馃憤

All 8 comments

@tkrotoff This change sounds good to me. However, it's a breaking change. We gonna need to bump the version to v2. I'm adding it into the milestone 馃憤

This use case is OK: codepen.io => material-ui (with window['material-ui'])
This use case is KO: codepen.io => myLib => material-ui

I don't know how to configure myLib to use window['material-ui'] (no problem of course if material-ui exported a variable MaterialUI).
It's probably not possible, so having a MaterialUI export is not only a "nice to have".

Example code:

I don't know how to configure myLib to use window['material-ui']

@tkrotoff We will definitely move forward and address this problem in v2!

@oliviertassinari wow did not expect a release so soon! Can I make a PR to change this: https://github.com/mui-org/material-ui/blob/v3.0.0/packages/material-ui/scripts/rollup.config.js#L10 ?

@tkrotoff What do you mean? This change is still planed for v4, in 3-4 months.

Je suis un peu perdu : few days ago you were talking about a v2. I saw v3 was just released (could have been a good time to change this) and now talking about a v4.
Anyway, can I make a PR on master? (I guess not, master is for v3 and there is no branch for v4 yet).

Yeah sorry for the confusion. v2 focus has just shifted to v4 for Q1 2019.

You can definitely open a pull request now on master. We will just wait before merging it :).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryanflorence picture ryanflorence  路  3Comments

chris-hinds picture chris-hinds  路  3Comments

pola88 picture pola88  路  3Comments

ghost picture ghost  路  3Comments

iamzhouyi picture iamzhouyi  路  3Comments