Skip to content
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

Warning: Missing export default in ComputeHistogram.worker.js #1737

Closed
phcerdan opened this issue Feb 22, 2021 · 9 comments
Closed

Warning: Missing export default in ComputeHistogram.worker.js #1737

phcerdan opened this issue Feb 22, 2021 · 9 comments

Comments

@phcerdan
Copy link

WARNING in ./node_modules/vtk.js/Sources/Interaction/Widgets/PiecewiseGaussianWidget/index.js 451:23-45
"export 'default' (imported as 'ComputeHistogramWorker') was not found in './ComputeHistogram.worker'
 @ ./node_modules/paraviewweb/src/React/Widgets/PieceWiseGaussianFunctionEditorWidget/index.js
 @ ./node_modules/paraviewweb/src/React/Widgets/ColorByWidget/AdvancedView.js
 @ ./node_modules/paraviewweb/src/React/Widgets/ColorByWidget/index.js
 @ ./src/panels/ControlPanel/PipelineBrowser/index.js
 @ ./src/panels/ControlPanel/index.js
 @ ./src/MainView.js
 @ ./node_modules/babel-loader/lib??ref--8-0!./node_modules/eslint-loader??ref--5!./src/app.js
 @ ./src/app.js-exposed

Imported here:
https://github.com/Kitware/vtk-js/blob/master/Sources/Interaction/Widgets/PiecewiseGaussianWidget/index.js#L6

import ComputeHistogramWorker from './ComputeHistogram.worker';

But there is no export default in ComputeHistogram.worker.js

The other worker: https://github.com/Kitware/vtk-js/blob/master/Sources/Filters/General/PaintFilter/PaintFilter.worker.js might suffer the same warning, but haven't tested.

@jourdain
Copy link
Collaborator

Workers are expected to be handled by a dedicated loader.

@phcerdan
Copy link
Author

phcerdan commented Feb 22, 2021

Isn't the warning still valid? There is no ComputeHistogramWorker in that file?

It is used here:

import ComputeHistogramWorker from './ComputeHistogram.worker';

const worker = new ComputeHistogramWorker();
const workerPromise = new WebworkerPromise(worker);

@jourdain
Copy link
Collaborator

No, I would not think so.

@phcerdan
Copy link
Author

I see, although the warning is generated from current code from visualizer. I thought it belonged here.

@jourdain
Copy link
Collaborator

That is an issue on how visualizer is setup (loader config).

Probably when Visualizer started to use the vtk.js class, that class was not using any worker and therefore everything was fine. But when we updated vtk.js inside Visualizer a while back we broke it by not adding the proper loaders to handle the workers properly.

This should be fixed but I guess no one get to it ;-)

@phcerdan
Copy link
Author

Thanks @jourdain. Give me a couple of months and I might get up to speed with javascript and a small niche of its rapid-changing ecosystem to start fixing my own findings! Meanwhile, I just report issues as I find them :)

Closing, as it belongs to kitware/visualizer.

@Tinanuaa
Copy link

Tinanuaa commented Jun 5, 2023

Workers are expected to be handled by a dedicated loader.

Hi Jourdain, may I know what do you mean by a dedicated loader? cause I got the following error when trying to use itkwidgets(which used itk-vtk-viewer, which used vtk.js).

Attempted import error: './ComputeHistogram.worker' does not contain a default export (imported as 'ComputeHistogramWorker').
ERROR in ./node_modules/itk-vtk-viewer/node_modules/vtk.js/Sources/Interaction/Widgets/PiecewiseGaussianWidget/index.js 490:25-47
export 'default' (imported as 'ComputeHistogramWorker') was not found in './ComputeHistogram.worker' (module has no exports)

ERROR in ./node_modules/itk-vtk-viewer/node_modules/vtk.js/Sources/Rendering/Core/Camera/index.js 502:6-17
export 'quat'.'toMat4' (imported as 'quat') was not found in 'gl-matrix' (possible exports: add, calculateW, clone, conjugate, copy, create, dot, equals, exactEquals, exp, fromEuler, fromMat3, fromValues, getAngle, getAxisAngle, identity, invert, len, length, lerp, ln, mul, multiply, normalize, pow, random, rotateX, rotateY, rotateZ, rotationTo, scale, set, setAxes, setAxisAngle, slerp, sqlerp, sqrLen, squaredLength, str)

And I checked the vtk.js/Utilities/config/dependency.js has the loader for worker.js, is there any step required to set it up correctly?

{
          test: /\.worker\.js$/,
          include: /vtk\.js[\/\\]Sources/,
          use: [
            {
              loader: 'worker-loader',
              options: { inline: true, fallback: false },
            },
          ],
        },

@floryst
Copy link
Collaborator

floryst commented Jun 5, 2023

Linking your itkwidgets issue for cross-referencing purposes: InsightSoftwareConsortium/itkwidgets#668

This is a project build process issue, where the project using vtk.js doesn't properly ingest vtk.js source files. I don't think this is a vtk.js issue, but rather a downstream project issue.

@Tinanuaa
Copy link

Tinanuaa commented Jun 6, 2023

Linking your itkwidgets issue for cross-referencing purposes: InsightSoftwareConsortium/itkwidgets#668

This is a project build process issue, where the project using vtk.js doesn't properly ingest vtk.js source files. I don't think this is a vtk.js issue, but rather a downstream project issue.

Thanks floryst, is there any guide on how I can make the downstream project configure right? I checked the intro_vtk_as_es6_dependency and old_intro_vtk_es6, and I checked the webpack.config.js, which has the vtkRules configured and has the loader for worker.js, https://github.com/Kitware/itk-vtk-viewer/blob/master/webpack.config.js#L56-L69. So is there anything else I should check to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants