Skip to content

Load package imports in generated shinylive app entrypoint#6

Open
JZauner wants to merge 2 commits intomainfrom
codex/update-package-for-shinylive-compatibility-jbdzcz
Open

Load package imports in generated shinylive app entrypoint#6
JZauner wants to merge 2 commits intomainfrom
codex/update-package-for-shinylive-compatibility-jbdzcz

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: 4912711123

ℹ️ 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".

Comment on lines +78 to +79
parse_description_field(desc[1, "Depends"]),
parse_description_field(desc[1, "Imports"])

Choose a reason for hiding this comment

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

P2 Badge Guard missing DESCRIPTION dependency fields

Handle absent Depends/Imports columns before indexing desc, because read.dcf() omits columns that are not present and desc[1, "Depends"] (or "Imports") then throws subscript out of bounds. In that case export_shinylive_bundle() fails before generating app.R, so repos that drop one of these fields (which is valid in DESCRIPTION) cannot be exported even though parse_description_field() already supports empty inputs.

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