posit-dev / r-shinylive

https://posit-dev.github.io/r-shinylive/
Other
151 stars 16 forks source link

bundling packages #27

Closed Karel-Kroeze closed 2 months ago

Karel-Kroeze commented 10 months ago

Apologies if this is the wrong forum, but I have been unable to find any documentation on the possiblity of pre-compiling and bundling packages as part of a compiled shiny app. The webr documentation mentions that this should be possible (https://docs.r-wasm.org/webr/latest/packages.html), but neglects to give any further hints on how this would be achieved.

1) is bundling packages even a good idea? From what I can tell based on reading the webr and shinylive documentation, console output, and load times, shinylive apps currently fetch wasm versions of packages from a repo, and do so for each user, and apparently on each visit. This seems incredibly wasteful and slow. Am I misunderstanding how this works?

2) Is a user-friendly way of bundling as part of the export() process planned? (it should be!)

3) Do you have any suggestions for documentation on how I could bundle packages 'manually' (for the time being, or if no official bundling is planned)?

4) In general, I think the documentation on this topic could be clearer.

We use a range of small shiny applications in education, and being able to serve them as standalone components from a simple static file server is a really exciting prospect. That said, we do need these applications to load fairly quickly, as they are typically rendered as part of other material. If it takes 30s+ to load (as even the simplest examples currently do), students are more likely than not to simply skip over the app, rather than wait for it to load.

I'm following this project with great attention, thank you for your hard work ❤️ !

schloerke commented 10 months ago
  1. is bundling packages even a good idea?

It's a great idea, but it is currently not implemented in shinylive.

  1. Is a user-friendly way of bundling as part of the export() process planned? (it should be!)

Absolutely! It'll be here sooner than later.

  1. Do you have any suggestions for documentation on how I could bundle packages 'manually' (for the time being, or if no official bundling is planned)?

The tooling is not fun to set up. It'll either be performed by a GitHub Action workflow that you run or a local Docker container. For the time being, no documentation will be made until the process is smoother.


This bundling will come with the benefit of being able to use packages from GitHub. Please see https://github.com/r-wasm/rwasm/ for the latest bleeding-edge work.

Again, this can all change fairly quickly.

schloerke commented 2 months ago

Fixed in https://github.com/posit-dev/r-shinylive/pull/72 (Requires shinylive assets >= 0.4.1)

Cran packages are now included. I was able to run my exported app locally with external internet turned off (and with cache disabled!).

I recommend having an r-universe to build all of your GitHub packages. If your GitHub package is actually installed from your r-universe, then {shinylive} can download r-wasm friendly bundles directly from r-universe for bundling. No extra GitHub infrastructure is necessary.