webr icon indicating copy to clipboard operation
webr copied to clipboard

Test and document how to bundle webR with Skypack for Observable notebooks

Open imathews opened this issue 1 year ago • 3 comments

The ability to leverage R statistics within an interactive Observable notebook could be incredibly powerful. Observable utilizes Skypack to bundle external libraries. When I attempt to do this for webr (https://cdn.skypack.dev/[email protected]), I get the following error:

/*
 * [Package Error] "[email protected]" could not be built. 
 *
 *   [1/5] Verifying package is valid…
 *   [2/5] Installing dependencies from npm…
 *   [3/5] Building package using esinstall…
 *   Running esinstall...
 *   ENOENT: no such file or directory, open 'webr/dist/repl.mjs'
 *   ENOENT: no such file or directory, open '/tmp/cdn/_aFiBbALhfvDaTW6dWLk8/node_modules/webr/dist/repl.mjs'
 *
 * How to fix:
 *   - If you believe this to be an error in Skypack, file an issue here: https://github.com/skypackjs/skypack-cdn/issues
 *   - If you believe this to be an issue in the package, share this URL with the package authors to help them debug & fix.
 *   - Use https://skypack.dev/ to find a web-friendly alternative to find another package.
 */

console.warn("[Package Error] \"[email protected]\" could not be built. \n[1/5] Verifying package is valid…\n[2/5] Installing dependencies from npm…\n[3/5] Building package using esinstall…\nRunning esinstall...\nENOENT: no such file or directory, open 'webr/dist/repl.mjs'\nENOENT: no such file or directory, open '/tmp/cdn/_aFiBbALhfvDaTW6dWLk8/node_modules/webr/dist/repl.mjs'");
throw new Error("[Package Error] \"[email protected]\" could not be built. ");
export default null;

imathews avatar Aug 17 '23 16:08 imathews

Thanks for reporting this, it looks like our package.json needs a little work. I'll take a look at tidying things up for a 0.2.1 patch release.

A corrected package.json should hopefully solve this issue.

georgestagg avatar Aug 21 '23 07:08 georgestagg

This should hopefully work better as of [email protected]. The url https://cdn.skypack.dev/[email protected] seems to work now, but I have not yet tested importing the module into a wider Observable/Skypack project.

georgestagg avatar Sep 12 '23 14:09 georgestagg

Now it seems to load both with import("https://cdn.skypack.dev/[email protected]") and import("https://esm.sh/[email protected]"). (However I don't know how to instantiate it with the wasm file, nor how to use it.)

Fil avatar Sep 28 '23 10:09 Fil