web_logger icon indicating copy to clipboard operation
web_logger copied to clipboard

Add support for web_sys in addition to stdweb

Open Stigjb opened this issue 5 years ago • 0 comments

This crate depended on stdweb, which is not desirable if you prefer to use web-sys, like the main Yew project is moving to.

Many of the examples in the Yew project depend on web_logger, and therefore implicitly pull in stdweb even though they're supposed to be web-sys only. I assume they will benefit from smaller code size once web_logger can use web-sys as well.

  • Updated to Rust 2018 edition (no extern crate or macro_use)
  • Use a stdweb- or web-sys-based module based on the selected feature
  • std_web as default feature to keep backward compatibility

Some diffs are entirely cargo fmts doing.

Questions

I'm not confident that I applied pub(super) right in the respective modules, but I tried to mirror the original.

I think it would be nice to provide a warning if someone were to try to install both features (which could happen if they forgot default-features = false). Not sure how to do that. Because of the order of cfg_if, this would build the std_web module.

Stigjb avatar May 02 '20 18:05 Stigjb