From 546d3fc5c513da214365a8be0c126145c65cfa28 Mon Sep 17 00:00:00 2001 From: George Stagg Date: Fri, 2 Aug 2024 09:12:30 +0100 Subject: [PATCH 1/2] Avoid LinkingTo dependencies in package resolution Packages listed under LinkingTo are required for building dependent packages, but not at runtime as they are header-only or statically linked libraries. So, we can ignore these packages when we're looking for dependencies to bundle for webR. In webR 0.4.1, these packages will also be ignored when invoking `webr::install()`. --- R/packages.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/packages.R b/R/packages.R index 4989aa9..52a27eb 100644 --- a/R/packages.R +++ b/R/packages.R @@ -6,7 +6,7 @@ sys_env_max_filesize <- function() { if (max_fs_env == "") NULL else max_fs_env } -# Resolve package list hard dependencies +# Resolve package list, dependencies listed in Depends and Imports resolve_dependencies <- function(pkgs, local = TRUE) { pkg_refs <- if (local) { refs <- find.package(pkgs, lib.loc = NULL, quiet = FALSE, !is_quiet()) @@ -14,7 +14,8 @@ resolve_dependencies <- function(pkgs, local = TRUE) { } else { pkgs } - inst <- pkgdepends::new_pkg_deps(pkg_refs) + wasm_config <- list(dependencies = c("Depends", "Imports")) + inst <- pkgdepends::new_pkg_deps(pkg_refs, config = wasm_config) inst$resolve() unique(inst$get_resolution()$package) } From cb37e79939f54c1816a88fc364d29f8b536a36c8 Mon Sep 17 00:00:00 2001 From: George Stagg Date: Fri, 2 Aug 2024 14:07:50 +0100 Subject: [PATCH 2/2] Update NEWS.md --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 61b57a0..f79bd08 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # shinylive (development version) +* shinylive now avoids bundling WebAssembly R package dependencies listed only in the `LinkingTo` section of required packages. With this change dependencies that are only required at build time are no longer included as part of the exported WebAssembly asset bundle. This reduces the total static asset size and improves the loading time of affected shinylive apps. (#115) + # shinylive 0.2.0 * shinylive now uses [shinylive web assets v0.5.0](https://github.com/posit-dev/shinylive/releases/tag/v0.5.0) by default, which bundles webR 0.4.0 with R 4.4.1. This update brings improved keyboard shortcuts for R users in the Shinylive editor, the ability to export a custom library of R packages with the exported app, and a few improvements to the Quarto integration. (#108)