Hacker News new | ask | show | jobs
by thekaleb 2139 days ago
Have you tried the import expression as opposed to the import statement?

E.G. const foo = await import('foo.js');

1 comments

Same - I wonder if it's because it's some sandbox context and it's trying to bind to window (it's the UMD version)
I've had a look and wasn't able to get it to work yet, imports can be bit iffy: usually anything that exposes ES modules or puts variables on the window object work fine.

It looks like the reason it doesn't work here is because it relies on "this" being the window object. To make top-level await possible your code gets wrapped into a function, and in there "this" no longer points to the window. I am sure a workaround is possible, I'll make a ticket on github.

https://github.com/gzuidhof/starboard-notebook/issues/1