Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegate shinylive deployment to code in shinylive #310

Merged
merged 6 commits into from
Aug 12, 2022
Merged

Conversation

wch
Copy link
Collaborator

@wch wch commented Aug 10, 2022

This PR makes it so that when shiny static is called, it runs code provided by the shinylive bundle. This makes it so that shinylive can make changes to how it does deployment, without having to synchronize it with the shiny package.

Along with posit-dev/py-shinylive#14, it also makes the following possible:


Multiple applications can be deployed in one command, with:

shiny static app1 site --subdir a1
shiny static app2 site --subdir a2
shiny static app3 site --subdir a3

This will create the following directory structure:

site
├── a1
│   ├── app.json
│   ├── edit
│   │   └── index.html
│   └── index.html
├── a2
│   ├── app.json
│   ├── edit
│   │   └── index.html
│   └── index.html
├── a3
│   ├── app.json
│   ├── edit
│   │   └── index.html
│   └── index.html
├── serviceworker.js
└── shinylive     # Other JS stuff in here, including pyodide

All of the deployed apps share the same shinylive resources.

Note that if you want one to be deployed to the top level, it can be done by just not using --subdir:

shiny static app1 site
shiny static app2 site --subdir a2
site
├── app.json   # Top level application, from source dir app1/
├── edit
│   └── index.html
├── index.html
├── a2
│   ├── app.json
│   ├── edit
│   │   └── index.html
│   └── index.html
├── serviceworker.js
└── shinylive

shiny static now by default only includes packages needed to run the deployed application(s). Previously, a deployment would be about 200MB because it included all of the packages from Pyodide, as well as a few other shiny-related packages. With the change in posit-dev/py-shinylive#14, a minimal shinylive app deployment is now about 27MB.

If deployed this way, then when a user goes to the /edit/ page and makes changes or runs code in the terminal, they will not be able to load any extra packages that normally are part of the distribution (they will be able to load packages from PyPI, but as always, these packages must not contained any compiled code).

In order to include the full Shinylive distribution, the option --full-shinylive can be used.

@wch wch marked this pull request as draft August 10, 2022 20:21
shiny/_static.py Outdated Show resolved Hide resolved
@wch wch marked this pull request as ready for review August 12, 2022 21:25
@wch wch merged commit 99b94d6 into main Aug 12, 2022
@wch wch deleted the shinylive-prune branch August 12, 2022 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants