let viz = import("npm:geoviz@1.0.7")
works
let version ="1.0.7"
let viz = import(`npm:geoviz@${version}`)
doesn’t work !
RuntimeError: Failed to fetch dynamically imported module: npm:geoviz@1.0.7
let viz = import("npm:geoviz@1.0.7")
works
let version ="1.0.7"
let viz = import(`npm:geoviz@${version}`)
doesn’t work !
RuntimeError: Failed to fetch dynamically imported module: npm:geoviz@1.0.7
Hm yeah it looks like dynamic imports allow interpolation only for a full URL. Not sure why that is. Either we’re doing some static analysis or it’s a bug.
Reproduction: https://observablehq.com/@tophtucker/re-neocarto-on-import-interpolation
Full URL with interpolation
import(`https://cdn.jsdelivr.net/npm/geoviz@${version}/+esm`)
npm specifier
import("npm:geoviz@1.0.7")
npm specifier with interpolation
import(`npm:geoviz@${version}`)
Not a bug — import resolution requires static analysis. If you want to do a dynamic import you need to specify a full URL, as @tophtucker shows.