In @kitware /vtk.js version 23.3.0 I’m receiving an error that DataAccessHelper is not defined.
This would be the module imported from:
import DataAccessHelper from '@kitware/vtk.js/IO/Core/DataAccessHelper'
In VSCode I’m getting the following hint:
My code is following the SceneExplorer example here:
Has something changed intentionally that needs us to shift how we use the DataAccessHelper?
If this is a regression I can spend a little time to track down why this may be happening tomorrow…
Not sure about the ESM part of it, but you need to explicitly load the concrete implementation of them so they can became available.
That was added to allow better tree shaking and reduce bundle size when pieces of vtk.js were not use.
Try adding the following import in your code.
import '@kitware/vtk.js/IO/Core/DataAccessHelper/ZipDataAccessHelper';
1 Like
Hey @Sebastien_Jourdain I figured it out -
I imported the appropriate function using:
import { get } from '@kitware/vtk.js/IO/Core/DataAccessHelper.js'
It looks like this would also work:
import { DataAccessHelper } from '@kitware/vtk.js/IO/Core/DataAccessHelper.js'
The export from .../IO/Core/DataAccessHelper.js
looks like this:
export { DataAccessHelper as default, get, has, registerType };
I am not familiar with that notation, it looks like writing it as the following solves the issue:
export default DataAccessHelper;
export { get, has, registerType };
I can open an issue with the above information.
I’m not sure to understand what you are talking about? Does your code works now? Is it just a TypeScript definition error, or the missing Zip handler?
Yes my code works now.
The error I’m talking about is just in the way the DataAccessHelper module is exported.
Importing DataAccess helper this way:
import DataAccessHelper from '@kitware/vtk.js/IO/Core/DataAccessHelper'
Was causing an error for me.
Importing it either of the following ways seem to work given the way it’s exported:
import { DataAccessHelper } from '@kitware/vtk.js/IO/Core/DataAccessHelper'
import { get } from '@kitware/vtk.js/IO/Core/DataAccessHelper'
1 Like
Forrest
(Forrest)
March 29, 2022, 2:29pm
6
1 Like