Open belvederef opened 4 years ago
FWIW, I also got this error in the situation where I (foolishly) import
ed an enum from within the worker that was defined in the file that imported the worker. In other words,
import MyWorker from "nativescript-worker-loader!./worker";
export enum Action {
first
}
const worker = new MyWorker();
worker.postMessage(…);
import {Action} from "./file";
self.onmessage = function() {
…
};
I suspect these are two entirely different problems, but since the error message is the same and equally inscrutable, I thought I'd post this here in case it helps someone else.
I am using nativescript-worker-loader@0.11.0
in my project with:
import * as ExampleWorker from 'nativescript-worker-loader!./workers/example.worker';
The typings/worker-loader.d.ts
that I've got declares this, which matches the import
statement:
declare module "nativescript-worker-loader!*" {
const content: any;
export = content;
}
I think if it declared export default content
, then I would have needed to use import ExampleWorker from '...'
.
On I found that importing the typescript worker with
as per the docs does not let the worker to be created and raises the error
[TypeError: TsWorker is not a constructor]
.The solution is simply to import it using
I tried both version
0.9.0
and0.10.0
of this package, and the error is still there when importing with the first method, so I believe the documentation needs to be updated.