# import WorkerFactory Error in React

**URL:** https://discourse.vtk.org/t/import-workerfactory-error-in-react/8936
**Category:** Web
**Created:** [July 12, 2022, 9:41am UTC](https://discourse.vtk.org/t/import-workerfactory-error-in-react/8936 "2022-07-12T09:41:39Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![lizemin2016](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lizemin2016/32/5266_2.png) [@lizemin2016](https://discourse.vtk.org/u/lizemin2016)
#### Post date: [July 12, 2022, 9:41am UTC](https://discourse.vtk.org/t/import-workerfactory-error-in-react/8936/1 "2022-07-12T09:41:39Z")

</div>

the import statement in `PiecewiseGaussianWidget.js` file bellow occurs error when compiled in react project.

```auto
import { W as WorkerFactory } from '../../_virtual/rollup-plugin-worker-loader__module_Sources/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js';

```

who can tell me how to deal with the error.  
Compiled with problems:X

ERROR in ./node\_modules/@kitware/vtk.js/Interaction/Widgets/PiecewiseGaussianWidget.js 546:23-36

export ‘W’ (imported as ‘WorkerFactory’) was not found in ‘…/…/\_virtual/rollup-plugin-worker-loader\_\_module\_Sources/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js’ (possible exports: default)

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [July 12, 2022, 1:39pm UTC](https://discourse.vtk.org/t/import-workerfactory-error-in-react/8936/2 "2022-07-12T13:39:19Z")

</div>

What version of vtk.js are you using? And is this with create-react-app?

---

<div class="post-metadata">

### Author: ![lizemin2016](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lizemin2016/32/5266_2.png) [@lizemin2016](https://discourse.vtk.org/u/lizemin2016)
#### Post date: [July 12, 2022, 2:14pm UTC](https://discourse.vtk.org/t/import-workerfactory-error-in-react/8936/3 "2022-07-12T14:14:02Z")

</div>

vtkjs version:24.14.2, with create-react-app.

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [July 12, 2022, 2:26pm UTC](https://discourse.vtk.org/t/import-workerfactory-error-in-react/8936/4 "2022-07-12T14:26:12Z")

</div>

I would recommend upgrading if that is possible for you, since we are on v25 now. If upgrading is not possible, I can investigate to see if that version has a faulty export.

---

<div class="post-metadata">

### Author: ![lizemin2016](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lizemin2016/32/5266_2.png) [@lizemin2016](https://discourse.vtk.org/u/lizemin2016)
#### Post date: [July 12, 2022, 3:35pm UTC](https://discourse.vtk.org/t/import-workerfactory-error-in-react/8936/5 "2022-07-12T15:35:56Z")

</div>

I have upgraded @kitware/vtk.js to the latest(v25.1.3), the error still exists…

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [July 12, 2022, 3:43pm UTC](https://discourse.vtk.org/t/import-workerfactory-error-in-react/8936/6 "2022-07-12T15:43:45Z")

</div>

Hm, it could be that create-react-app is auto-transforming `*.worker.js`, but I don’t imagine why they would be doing that for node\_modules. Do you have a minimal proof of concept repo that reproduces this problem?

---

<div class="post-metadata">

### Author: ![lizemin2016](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lizemin2016/32/5266_2.png) [@lizemin2016](https://discourse.vtk.org/u/lizemin2016)
#### Post date: [July 12, 2022, 4:10pm UTC](https://discourse.vtk.org/t/import-workerfactory-error-in-react/8936/7 "2022-07-12T16:10:42Z")

</div>

[vtkjs-app.rar](https://discourse.vtk.org/uploads/short-url/zuNQElQrGCm8hNwADleASxOKif7.rar) (950.6 KB)  
here is my simplified project, many thanks…

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [July 13, 2022, 6:30pm UTC](https://discourse.vtk.org/t/import-workerfactory-error-in-react/8936/8 "2022-07-13T18:30:06Z")

</div>

Ah, the rules you have in `config-overrides.js` is unnecessary. You don’t need the worker-loader, since that worker file is already transpiled in the `@kitware/vtk.js` package.

---

<div class="post-metadata">

### Author: ![lizemin2016](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lizemin2016/32/5266_2.png) [@lizemin2016](https://discourse.vtk.org/u/lizemin2016)
#### Post date: [July 14, 2022, 2:49am UTC](https://discourse.vtk.org/t/import-workerfactory-error-in-react/8936/9 "2022-07-14T02:49:11Z")

</div>

Thank you, Forrest, my friend, I think too much…
