New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Imports that rely on "this" being window don't work #1
Comments
You can try out Skypack CDN instead, every npm package is served as valid ESM for import.
|
Perfect, I think Pika and Skypack are the perfect companions to Starboard. I'm thinking about exposing a global helper function, something along the lines of: async function skypackImport(packageName: string, opts: {min: boolean} = {min: true}) {
return await import(`https://cdn.skypack.dev/${packageName}${opts.min ? "?min" : ""}`;
} As for the value of Original cell code console.log("Hello!");
await fetch("https://example.com"); Wrapped cell code (async () => {console.log("Hello!");
return {returnValue: (await fetch("https://example.com"))};
})() We could use Function.call() instead to pass in I suppose it is trivial to support, so maybe it's just worth doing so people not using skypack don't run into this issue.. |
Scratch that trivial (async () => {return {returnValue: (await import("https://cdn.jsdelivr.net/npm/rxjs@6.6.2/bundles/rxjs.umd.js"))};
}).call(window) To my surprise, using I suppose within the dynamic imported script |
That's awesome, and exactly the kind of workflow Skypack is built for! Users are so used to being able to just import packages by name, you could go the extra step and have Skypack power |
Even though I think it would make usability a lot better, I'm hesitant to introduce that change. The logic whether to rewrite or not is difficult to get right in every situation. If somebody embeds a notebook on their own website and wants to import a script I think it makes sense for requiring an explicit opt-in to the magic for now by exposing a function (maybe in the future it could be behind a toggle). |
An example is rxjs, when importing:
The code around that line is:
The text was updated successfully, but these errors were encountered: