typescript-webworker icon indicating copy to clipboard operation
typescript-webworker copied to clipboard

Uncaught ReferenceError: exports is not defined

Open mogadanez opened this issue 7 years ago • 4 comments

Sample work with sample worker, but when I add any import in my worker code, it starts failed with

Uncaught ReferenceError: exports is not defined

I also see Object.defineProperty(exports, "__esModule", { value: true }); in generated code

mogadanez avatar Nov 03 '17 17:11 mogadanez

I am facing the same problem because I am using import inside my worker.ts. I am importing a ts module that have the export keyword. I believe the file loader need to define that keyword somehow!

mohyeid avatar Nov 08 '17 21:11 mohyeid

I'm also having this problem -- is there a solution?

garrettm avatar Nov 18 '17 02:11 garrettm

I ended up having to write the classes that I import inside the workers file on top of the file. Not elegant, but it solved it at least.

mohyeid avatar Nov 18 '17 04:11 mohyeid

@mohyeid thanks, I might end up doing that. @mogadanez were you able to find a different fix for this?

garrettm avatar Nov 20 '17 21:11 garrettm