rstudio / shiny

Easy interactive web applications with R
https://shiny.posit.co/
Other
5.35k stars 1.87k forks source link

Adding shiny.js to bower & npm #1509

Open adilapapaya opened 7 years ago

adilapapaya commented 7 years ago

Hi.

Would it be possible to have shiny.js available via npm and bower so we can npm install --save shinyjs? This is specific only to the shiny.js file and not the R-code. Right now, I 'hack' the system by manually copying the shiny.js file into my node_modules director

shinyfolder

I then add this to the beginning and end respectively of the shiny.js file so that I can import it into react apps.

// add to top
var $ = require("jquery");
// add to end
var Shiny = exports;
module.exports = Shiny;

Would much prefer to be able to do it automatically via some kind of package manager. Happy to help update the relevant files in tools if you let me know how you envision it being done (separate shell script or part of the Gruntfile, etc).

For some background, my backend is in Shiny but my front end is custom index.html and js files instead of the usual ui.R file. I usually bower install or npm install to install the relevant libs.

Relevant docs: https://docs.npmjs.com/getting-started/publishing-npm-packages

alandipert commented 5 years ago

Hi, sorry it took so long for us to respond to this!

Your use case is very interesting. Out of curiosity, are you able to share any applications you've built with this technique?

We don't have plans to distribute Shiny on npm or anywhere else other than CRAN, but the topic of exposing Shiny to custom JavaScript apps has come up in our conversations in meetings and at conferences.

markhepburn commented 10 months ago

@alandipert We have a similar use-case I'm exploring. We have a map-based visualisation application written in React (re-frame, in fact!), and I'd like to allow people to write shiny apps to integrate with it: shiny-leaflet calls are intercepted to integrate with the main map, while we also manage the UI and redirect events back through the Shiny instance. The issues I'm facing at the moment are the reliance of shiny on the window object, and (this one) the inability to manage shiny via npm.