posit-dev / r-shinylive

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

Is manual bundling of packages possible? #66

Closed maek-ies closed 4 months ago

maek-ies commented 4 months ago

dear George, dear Barret,

you are doing god's work with this package, thank you!

I know that making easy bundling possible is already in the pipeline (related issues #63, #27). My question is whether it is by any chance already possible to achieve that manually e.g. by manually copying the .data and .metadata to a certain subfolder (e.g. \shinylive\webr\vfs\usr) and then maybe just adjusting some additional lines of the existing code. Being able to freeze the deployed shinylive app in a static website without a need to download additional packages from the repo already would be fantastic. Sorry for being impatient, if this is not straightforward/possible currently, feel free to outright just close the issue, I will wait for the feature to be available.

georgestagg commented 4 months ago

Hi,

Indeed, we're planning on adding this soon to make it easy to bundle fixed package binaries with an app.

It is currently possible but requires a little extra work. You should be able to upload the .data and .metadata package files to static hosting in a directory relative to your app, then mount them into a new package library directory on the webR virtual filesystem using the webr::mount() function (docs).

Once the packages have been mounted, you'll need to add the virtual directory to your library path using .libPaths().

The resulting code would look something like this:

webr::mount("/custom_library/cli", "https://repo.r-wasm.org/bin/emscripten/contrib/4.3/cli_3.6.2.data")
.libPaths(c("/custom_library", .libPaths()))
library(cli)

Since this is not quite ready to be officially supported yet, and is largely the same as #27, we'll close this issue as a duplicate.

maek-ies commented 4 months ago

Thanks a lot for clarification, George!