Skip to content

Load package imports in generated shinylive app entrypoint#5

Open
JZauner wants to merge 1 commit intomainfrom
codex/update-package-for-shinylive-compatibility-31mp4l
Open

Load package imports in generated shinylive app entrypoint#5
JZauner wants to merge 1 commit intomainfrom
codex/update-package-for-shinylive-compatibility-31mp4l

Conversation

@JZauner
Copy link
Contributor

@JZauner JZauner commented Feb 5, 2026

Motivation

  • The previously generated app.R entrypoint sourced R/*.R and called LightLogWeb() without attaching package imports listed in DESCRIPTION, causing runtime errors in a clean Shinylive environment for unqualified calls like page_navbar() and addResourcePath().
  • Ensure exported Shinylive bundles reliably start by preloading the package dependencies the app needs at runtime.

Description

  • Added parse_description_field() to parse and clean package names from DESCRIPTION fields.
  • Added package_dependencies_for_entrypoint() to extract Depends and Imports from DESCRIPTION and filter out R and the package itself.
  • Added build_shinylive_entrypoint() and updated export_shinylive_bundle() so the generated app.R first attaches dependencies with library(..., character.only = TRUE), then sources R/*.R, and finally runs LightLogWeb().
  • Expanded unit tests in tests/testthat/test-export-shinylive-script.R to cover DESCRIPTION parsing, dependency extraction/filtering, and that the generated entrypoint includes dependency loading.

Testing

  • Added unit tests in tests/testthat/test-export-shinylive-script.R that exercise parse_description_field(), package_dependencies_for_entrypoint(), and build_shinylive_entrypoint() and verify expected output.
  • No automated R package tests were executed in this environment because Rscript / package test execution is unavailable, so the new tests were not run here.

Codex Task

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f51c589b84

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


c(
sprintf("deps <- c(%s)", dependency_literal),
"invisible(lapply(deps, library, character.only = TRUE))",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid eagerly attaching every import at startup

The generated entrypoint now loads all packages from Depends/Imports before the app starts, so the bundle fails immediately when any listed dependency is unavailable in the Shinylive/WebR runtime (for example, environment-specific or nonstandard packages), even if that package is only needed in a later code path. This turns a feature-scoped dependency problem into a full startup outage for the exported app.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant