How to laod vtk.js

Hi I have a stubborn module that I need helping using.

Here is a sample notebook:

When the page loads vtk is undefined, but if you redefined vtk as something else, then unassign it Observable will recognize vtk as the vtk.js module. Is there a proper hack to get this to work properly on page load?

Thanks in advance!

I think this works

vtk = {
  await import('https://cdn.skypack.dev/vtk.js@19.1.0?min')
  return window.vtk
}

BTW the way dynamic imports should work is

vtk = (await import('https://cdn.skypack.dev/vtk.js@19.1.0?min')).default

but this has been packed a bit strangely so the default doesn’t seem to have any exports. (Not the 1st time.)

1 Like

Thanks so much!