Closed ryan-williams closed 2 years ago
I'm happy you were able to figure it out! Starboard needs a documentation site badly, one of the things that should definitely be in there is a guide to importing code. There are quite some configurations:
P5.js
)And for each of these there are either the dynamic import style and ES import style:
// Dynamic import
import "bla.js"
import MyLib from "bla.js";
import * as MyLib from "bla.js";
import {someFunction} from "bla.js";
import {someFunction as anotherName} from "bla.js";
import {default as MyLib} from "bla.js"; // This one is weird: a named export of `default` is dodgy.
// JS style import
await import("bla.js");
const MyLib = await import("bla.js");
const {someFunction} = await import("bla.js");
const {default: MyLib} = await import("bla.js"); // a bit weird..
And then some packages will import Node-only stuff (like https
in the last of your examples), which need to be polyfilled (or excluded).
Here is an idea: there could be an online tool that statically analyzes the code and tells you how to import it and whether it is browser-friendly or not (and whether skypack can make it browser friendly).
semi-related to https://github.com/gzuidhof/starboard-notebook/issues/94, I've tried to use plotly.js in Starboard in a few ways, but nothing I've tried has worked. Here (and below) are a few things I've tried: https://starboard.gg/runsascoded/plotly-js-test-nDXqtpJ
Is there a way to use plotly.js in Starboard?
Update: I think I found a way! It's in the notebook above now, JS cell:
Screencast
Will leave the trail of failed attempts below, and issue open, in case there's any documentation etc. that should come from this. Feel free to close though!
JS cell
seemingly gives an empty module object
ESM cell
gives error:
Skypack imports
I noticed that the demo imports on the homepage starboard.gg all come from cdn.skypack.dev, so I tried a few of those (in ESM cells):
plotly.js
:errors with:
plotly.js-dist
Similar error:
plotly
Seems to have a different problem: