JohnCoene / packer

webpack + npm + R = ❤️
https://packer.john-coene.com/
Other
147 stars 6 forks source link

RS Connect can not see www/index.js net::ERR_ABORTED 404 #24

Closed armenic closed 2 years ago

armenic commented 2 years ago

Dear developer,

Thank you so much for an awesome package and a nice example of golem-react https://packer.john-coene.com/#/examples/golem-react I followed your steps and it run fine locally on my machine. Then I run golem::add_rstudioconnect_file() to generate app.R for deploying to RS Connect. The full code I used is at https://github.com/armenic/reaction

This is the content of app.R

# Launch the ShinyApp (Do not remove this comment)
# To deploy, run: rsconnect::deployApp()
# Or use the blue button on top of this file

pkgload::load_all(export_all = FALSE,helpers = FALSE,attach_testthat = FALSE)
options( "golem.app.prod" = TRUE)
reaction::run_app() # add parameters here (if any)

Then I deployed it to RS Connect by uploading the whole package, every file. The app shows only the ui that comes from Shiny and fails to find the index.js

#' The application User-Interface
#'
#' @param request Internal parameter for `{shiny}`.
#'     DO NOT REMOVE.
#' @import shiny
#' @noRd
app_ui <- function(request) {
  fluidPage(
    h1("reaction"),
    tagList(
      reactCDN(),
      div(id = "app"),
      tags$script(src = "www/index.js")
    )
  )
}
GET https://connect.workbench.roche.com/content/fba9aaa6-ba0d-4090-b062-708d7fe0bbad/_w_945945ec/www/index.js net::ERR_ABORTED 404

image

armenic commented 2 years ago

The same issue happens on shnyapps.io, pleas see https://armenic.shinyapps.io/reaction/

JohnCoene commented 2 years ago

It's an issue with the guide on the website, apologies.

It's missing golem_add_external_resources in the UI, here should be

app_ui <- function(request) {
  fluidPage(
    golem_add_external_resources(),
    h1("reaction"),
    tagList(
      reactCDN(),
      div(id = "app"),
      tags$script(src = "www/index.js")
    )
  )
}
armenic commented 2 years ago

You are amazing @JohnCoene, thank you so much for the fix as well as update to React 18 💯