Load package imports in generated shinylive app entrypoint#5
Load package imports in generated shinylive app entrypoint#5
Conversation
There was a problem hiding this comment.
💡 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))", |
There was a problem hiding this comment.
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 👍 / 👎.
Motivation
app.Rentrypoint sourcedR/*.Rand calledLightLogWeb()without attaching package imports listed inDESCRIPTION, causing runtime errors in a clean Shinylive environment for unqualified calls likepage_navbar()andaddResourcePath().Description
parse_description_field()to parse and clean package names fromDESCRIPTIONfields.package_dependencies_for_entrypoint()to extractDependsandImportsfromDESCRIPTIONand filter outRand the package itself.build_shinylive_entrypoint()and updatedexport_shinylive_bundle()so the generatedapp.Rfirst attaches dependencies withlibrary(..., character.only = TRUE), then sourcesR/*.R, and finally runsLightLogWeb().tests/testthat/test-export-shinylive-script.Rto cover DESCRIPTION parsing, dependency extraction/filtering, and that the generated entrypoint includes dependency loading.Testing
tests/testthat/test-export-shinylive-script.Rthat exerciseparse_description_field(),package_dependencies_for_entrypoint(), andbuild_shinylive_entrypoint()and verify expected output.Rscript/ package test execution is unavailable, so the new tests were not run here.Codex Task