Self is undefined in ts worker example (angular)
raulvc opened this issue · 2 comments
any idea why self is udefined on this line:
const context: Worker = self as any;
on this file
adding webpack entries to compile it with ts-loader this is what I get in js:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("globals");
var context = self;
context.onmessage = function (msg) {
setTimeout(function () {
console.log("Inside TS worker...");
global.postMessage("TS Worker");
}, 500);
};
I've been following step by step the angular+webpack+ts guidelines and the demo and still haven't got it to work...
Take a look to this answer:
https://stackoverflow.com/a/54546214/4982126
I have the same problem.
{
"nativescript": {
"id": "",
"tns-ios": {
"version": "5.1.0"
},
"tns-android": {
"version": "5.3.0"
}
},
"description": "",
"license": "SEE LICENSE IN ",
"repository": "",
"scripts": {
"lint": "tslint "src/**/*.ts""
},
"dependencies": {
"@angular/animations": "~7.2.0",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/http": "~7.2.0",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"nativescript-angular": "^7.2.3",
"nativescript-directions": "^1.3.0",
"nativescript-drawingpad": "^3.0.4",
"nativescript-feedback": "^1.3.3",
"nativescript-geolocation": "^5.1.0",
"nativescript-google-maps-sdk": "^2.6.1",
"nativescript-local-notifications": "^3.1.2",
"nativescript-localstorage": "^2.0.0",
"nativescript-phone": "^1.4.0",
"nativescript-plugin-firebase": "^7.6.0",
"nativescript-pulltorefresh": "^2.2.0",
"nativescript-theme-core": "~1.0.4",
"nativescript-toasty": "^1.2.0",
"nativescript-ui-dataform": "^3.10.0",
"nativescript-ui-listview": "^5.0.1",
"nativescript-ui-sidedrawer": "~5.0.0",
"reflect-metadata": "~0.1.10",
"rxjs": "^6.3.3",
"tns-core-modules": "^5.3.1",
"typescript": "~3.1.1",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/compiler-cli": "~7.2.0",
"@nativescript/schematics": "~0.4.0",
"@ngtools/webpack": "~7.2.0",
"codelyzer": "~4.5.0",
"nativescript-dev-sass": "~1.6.0",
"nativescript-dev-typescript": "^0.9.0",
"nativescript-dev-webpack": "^0.21.0",
"nativescript-worker-loader": "^0.9.5",
"tns-platform-declarations": "^5.2.2",
"ts-loader": "^5.3.0",
"tslint": "~5.11.0"
},
"readme": "NativeScript Application",
"author": ""
}