Skip to content

Commit

Permalink
Avoid LinkingTo dependencies in package resolution (#115)
Browse files Browse the repository at this point in the history
* 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()`.

* Update NEWS.md
  • Loading branch information
georgestagg authored Aug 2, 2024
1 parent 2d4be82 commit b14bea1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 3 additions & 2 deletions R/packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ 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())
glue::glue("local::{refs}")
} 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)
}
Expand Down

0 comments on commit b14bea1

Please sign in to comment.