Reactjs 如何在web workers的React应用程序中使用带有webpack的ES6模块?
我想在我的应用程序中使用web workers 这是我的工人:Reactjs 如何在web workers的React应用程序中使用带有webpack的ES6模块?,reactjs,webpack,web-worker,es6-modules,Reactjs,Webpack,Web Worker,Es6 Modules,我想在我的应用程序中使用web workers 这是我的工人: import { processOrderFieldValue } from './utils'; export function colsAndRowsWorker() { this.onmessage = () => { processOrderFieldValue(); // in this place the compiler is trying to convert this module to
import { processOrderFieldValue } from './utils';
export function colsAndRowsWorker() {
this.onmessage = () => {
processOrderFieldValue();
// in this place the compiler is trying to convert this module to this:
//Object(_WEBPACK_IMPORTED_MODULE_0__["processOrderFieldValue"])
//and I've got this:
//Uncaught ReferenceError: _WEBPACK_IMPORTED_MODULE_0__ is not defined
postMessage('oops');
};
}
我还尝试使用importScripts('./utils'),但也遇到了一个错误。
如何在React应用程序中使用worker中的模块?也许,我可以在importScripts()中将函数定义为相对路径