leaflet icon indicating copy to clipboard operation
leaflet copied to clipboard

get_providers_html_dependency returning temporary file path

Open qdread opened this issue 3 years ago • 1 comments

We have a build script that knits a .Rmd calling leaflet to a .md, then uses knit_meta() to find the file paths to all dependencies. Those files are then copied to /docs/assets/htmlwidgets. Then, when we push the repo to GitHub, a GitHub Page is built. The .js files are then present in the repo so that the htmlwidgets will display properly on our GitHub Pages. However there is currently an issue with the leaflet-providers_1.9.0.js script. When we call knit_meta() the output for leaflet-providers looks like this:

List of 10
 $ name      : chr "leaflet-providers"
 $ version   : chr "1.9.0"
 $ src       :List of 1
  ..$ file: chr "/tmp/RtmpMfsFHw"
 $ meta      : NULL
 $ script    : chr "leaflet-providers_1.9.0.js"
 $ stylesheet: NULL
 $ head      : NULL
 $ attachment: NULL
 $ package   : NULL
 $ all_files : logi FALSE
 - attr(*, "class")= chr "html_dependency"

The file path src$file is not the location of the leaflet-providers_1.9.0.js script on our filesystem so it does not copy over properly.

I see that the tempdir() based file path is originating from leaflet:::get_provider_html_dependency(). I am confused why this function intentionally creates a dependency to a file path in tempdir(). Is there any workaround for this?

qdread avatar Apr 08 '21 17:04 qdread

I was able to temporarily "fix" this issue on our end by rolling back to leaflet v2.0.2. In that version the function leafletProviderDependencies() has version 1.1.17 of leaflet-providers.js bundled with the package. Is it possible for leaflet-providers_1.9.0.js to still be bundled with leaflet?

This is a bit of an edge case but the way our build script is written, it pulls all the html dependencies from the package files. So the most recent version of get_provider_html_dependency() isn't compatible with that. I understand if you don't want to change this but I still wanted to raise the issue. Thanks in advance.

qdread avatar Apr 08 '21 18:04 qdread