Hi Duncan,

That's perfect, exactly what I was looking for!

Many thanks for the help!
Andrew

-----Original Message-----
From: Duncan Murdoch <[email protected]> 
Sent: Friday, 23 January 2026 5:39 AM
To: Andrew Johnson <[email protected]>; R Package Development 
<[email protected]>
Subject: Re: [R-pkg-devel] Specifying non-C/C++ build-time dependency

On 2026-01-14 12:55 a.m., Andrew Johnson wrote:
> Hi all!
> 
> I have an R package which uses several JS scripts/libraries, and I'm trying 
> to configure the build process to minify the JS files at build-time (via my 
> jsutils package: https://cran.r-project.org/web/packages/jsutils/).
> 
> My current approach is using a configure script to run the minification, with 
> the jsutils package added as an Import 
> (https://github.com/AUS-DOH-Safety-and-Quality/controlcharts/pull/25). But 
> this adds an additional runtime dependency when it's only needed at build 
> time.
> 
> Are there any recommended ways for specifying build-time dependencies when 
> the package doesn't require compilation? My attempts to use the LinkingTo 
> field so far are giving check notes for not having source or include files.
> 
> Any suggestions are much appreciated!

The rgl package keeps Javascript code deep down within the inst directory, and 
uses R code calling js::uglify_files to minify them.

Remember that building a package entails running every .R file in the R 
directory.  In most cases that just executes function definitions, but it can 
also execute other code involved in building.  So rgl defines a function 
rgl::makeDependency(), then calls things like

   CanvasMatrixDependency <- makeDependency("CanvasMatrix4",
     src = "htmlwidgets/lib/CanvasMatrix",
     script = "CanvasMatrix.src.js",
     package = "rgl",
     debugging = isTRUE(as.logical(Sys.getenv("RGL_DEBUGGING", "FALSE"))))

to minify it and record the information used by htmlwidgets to handle 
dependencies.  The makeDependency() function is exported from rgl, and might be 
useful as a model for the kinds of things you should do.  If you're using 
htmlwidgets, then you might be able to use it as-is.

Duncan Murdoch
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to