top | item 24048873

(no title)

thekaleb | 5 years ago

Have you tried the import expression as opposed to the import statement?

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

discuss

order

tanepiper|5 years ago

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)

protoduction|5 years ago

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