Skip to content

createWebDependency can't handle relative htmlDependencies #2383

Open
@cpsievert

Description

@cpsievert

Minimal example, this works as expected

library(htmltools)
dep <- htmlDependency(
  name = "jquery",
  version = "1.0.0",
  src = c(file = "www/shared"),
  script = "jquery.min.js",
  package = "shiny"
)
renderDependencies(list(dep))
<script src="www/shared/jquery.min.js"></script>

This does not:

shiny::createWebDependency(dep)
Error in value[[3L]](cond) : 
  Couldn't normalize path in `addResourcePath`, with arguments: `prefix` = 'jquery-1.0.0'; `directoryPath` = 'www/shared'

I noticed this in a shiny app that uses crosstalk and leaflet. The dev version of crosstalk::crosstalkLibs() now returns html dependencies with relative paths which ends up being a problem for this line of leaflet

https://github.com/rstudio/leaflet/blob/44df7d18a2618e0aeecb4145d765e597ec65878b/R/utils.R#L201

Since others might want to use shiny::createWebDependency() in a similar way, I figured the fix should derive from here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions