-
-
Notifications
You must be signed in to change notification settings - Fork 40
Problem with webpack and workers on android build #176
Comments
@danielgek, thanks. I'll take a look as soon as possible :). |
Ok, I've got bad news and good news. The good news - you don't really need to import globals in your worker. The only thing you are using from tns-core-modules is the console. You can either provide some custom implementation for the console, or you could just use the // worker.ts
declare function postMessage(message: any, targetOrigin?: string, transfer?: any[]): void;
onmessage = msg => {
switch (msg.data.action) {
case 'init':
break;
case 'encode':
postMessage({ resultType: 'encode' });
break;
case 'decode':
postMessage({ resultType: 'decode' });
break;
default:
postMessage({ error: `Action not implemented common worker: ${}`});
break;
}
};
onerror = error => {
postMessage({ error: 'on common worker error ' + error});
}; // app.component.ts
...
export class AppComponent {
constructor(){
let worker;
if (global.TNS_WEBPACK) {
const workerTemp = require('worker-loader!./worker.js');
if (typeof workerTemp === 'function') {
worker = workerTemp();
}
else {
worker = workerTemp;
}
} else {
worker = new Worker('./worker');
}
worker.onmessage = msg => console.dir(msg);
worker.postMessage({ action: 'encode' });
}
}
... |
@sis0k0 thanks for your time, i will keep track on the other issue, and yes i don't need use console in the worker so i will just get rid of it ;) |
@sis0k0 actually i will not be able to use this fix, because i'm using 'file-system' in the worker, so need to wait more for the fix on the android-runtime |
Hi @danielgek, I have the same problem :( Have you found any workaround? |
@edoardocavazza not yet, i haven't touched this again. |
I had the same error as the OP, thanks to your comments I worked out my issue. modules: [ Removing the first resolve fixed my build issues 😄 |
Hi, i'm having a problem building an app that has 3 workers
i think the problem is that all workers import globals
take a look at the end of the compilation log
if test needed, i can test with this app, thanks
The text was updated successfully, but these errors were encountered: