Building for WebR
As of the writing, extendr supports building for WebR!
Update build process
To build for WebR, you need to ensure that your R package has the appropriate build scripts and configuration. To do so ensure you have the latest development version of rextendr installed.
# update rextendr
pak::pak("extendr/rextendr")Compilation for WebR is handled through the tools/config.R and Makevars.in files in your R packages.
To udpate these files run
rextendr::use_extendr()Do not overwrite any important files like lib.rs or Cargo.toml. Allow it to overwrite:
Makevars{.win}.intools/config.Rconfigure{.win}entrypoint.c
Update Cargo.toml
In order to compile on WebR, the Cargo.toml file must ensure that lto = true for the release profile. Add the following to your Cargo.toml file:
[profile.release]
lto = true
Using extendr WebR packages
To use an extendr package with WebR, we recommend using r-universe. R-universe automatically builds binaries of your package for WebR, Mac, Windows, and Linux.