Suggestion: Use JSImport annotations instead of requiring user to configure an 'mui' or similar variables
See original GitHub issueCurrently, the raw components for material-ui are contained in the Mui
Scala object, which pulls its definition from an mui
Javascript object which the library user must configure, e.g., as
var mui = require("material-ui");
mui.Styles = require("material-ui/styles");
mui.SvgIcons = require('material-ui/svg-icons/index');
window.mui = mui;
However, depending on the tool chain used to manage Javascript dependencies, getting such an object into the global namespace may be inconvenient and/or finicky, and it is also not obvious that it needs to be done to begin with.
Scala.js has an @JSImport
annotation which is designed for this use case, that of importing definitions from modules. @JSName("mui")
can be replaced with @JSImport("material-ui",Namespace)
It has the same semantics as the original Mui
object, so the facade classes don’t need to be changed. It also works out of the box with sbt plugins like scalajs-bundler that manage NPM dependencies. Making such a tool chain work with scalajs-react-components’ current method of getting component definitions is something I haven’t managed to do yet.
(the above also applies to the other libraries this library provides facades for).
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:7
Top GitHub Comments
Fixed!!!
It works using this config:
webpack.config.js
build.sbt
Hey there! Yes, yes, this is the plan! In fact me and @rleibman have been working on it for a while in what will be version 1.0, see #89 . Feel free to give it a spin!