material-components / material-components-web

Modular and customizable Material Design UI components for the web
https://material.io/develop/web
MIT License
17.15k stars 2.14k forks source link

Usability with Bazel #4839

Open sgammon opened 5 years ago

sgammon commented 5 years ago

Feature Request

Hi there! I was wondering if there is an easy way to use MDC Web via Bazel? Specifically, rules_closure?

Proposed solution

Building against closureized sources would probably be ideal, but maybe there is a way to do it via TypeScript. Any help either generating closurized MDC web, or using MDC web from Bazel via TypeScript would be most welcome.

Alternatives considered

We wrote a Bazel overlay file for MDL, but that is only maintainable because MDL is essentially frozen in favor of this project.

Additional context

There is strong support for TypeScript in Bazel so maybe that is a better route, but I'm unfamiliar with Lerna-structured repos. FWIW whatever solution comes into play here might work for Firebase's JS SDK, too.

abhiomkar commented 5 years ago

I'm not expert in Bazel configuration. But you might find this sample project https://github.com/angular/angular-bazel-example/blob/master/src/BUILD.bazel useful.

You may've to use ts_library() rule with module_name set to appropriate npm package name.

For example,

ts_library(
    name = "component_ts",
    srcs = ["component.ts"],
    module_name = "@material/foo",
)

Here the link to Bazel docs for ts_library.

sgammon commented 5 years ago

@abhiomkar thank you! actually, we've got some progress going on this internally. we have an MDC overlay file that is properly building things, and then emitting that code via tsickle to Closure Compiler. if anyone is interested in this, let me know! :)

abhiomkar commented 5 years ago

Thanks for sharing the update Sam! Please share a sample repository that you've been working on for future references :)

sgammon commented 5 years ago

Hey, @abhiomkar! i just wanted to see why this was closed? :)

we were still hoping for some formal closure support, or the ability to use this from Bazel, someday. while our overlay file is something im happy to share, its a little hacky and requires us to maintain more than one fork.

sgammon commented 5 years ago

@abhiomkar how would you like me to share my Bazel stuff? via a gist, or a fork, perhaps? i have been working on packaging it up, but the forks we have is something that needs to be documented, otherwise the overlay file won't work.

abhiomkar commented 5 years ago

Thanks for the follow up Sam!

It would be very helpful to link a sample repo in this thread for future references. I feel it is hard for us to maintain documentation for every setup. WDYT?

sgammon commented 5 years ago

@abhiomkar, surely you must understand how this is not the ordinary setup - Bazel is a Google tool, MDC is a Google UI library. If MDC is in use at Google, how does it not yet have support for Blaze, and potentially, therefore, relatively easy support for Bazel?

if google would be willing to help maintain a sample repo, i would be happy to do the work needed to gather the docs and PRs and propose them.

in many cases these are google tools, that need to work with google libraries. if this isn't a supported use case, what is?

sgammon commented 5 years ago

@abhiomkar could we at least re-open the issue to discuss it? so far our forks include rules_closure and a few stragglers, like closure-stylesheets which needed a patch or two for the SCSS output from MDC.

it will take a little while to put together but im happy to contribute if there really is no bandwidth or apetite for this one inside google.

sgammon commented 5 years ago

@abhiomkar thank you