Closed ignaciolarranaga closed 8 years ago
I think the iOS runtime has issues with code using the "use strict" declaration. I think nativescript-geolocation has to be compiled without that.
This issue was moved to NativeScript/nativescript-geolocation#32
I don't think it is a problem of geolocation, the "use strict" appears 463 times in my bundle :)
Check for example this piece, it is the app component:
/*!************************!*\
!*** ./app.context.js ***!
\************************/
/***/ function(module, exports, __webpack_require__) {
"use strict";
var core_1 = __webpack_require__(/*! @angular/core */ 146);
/**
* This class represents a particular context (a company selected, a product, selected, etc.)
*/
var AppContext = (function () {
function AppContext() {
}
AppContext = __decorate([
core_1.Injectable(),
__metadata('design:paramtypes', [])
], AppContext);
return AppContext;
}());
exports.AppContext = AppContext;
//# sourceMappingURL=app.context.js.map
/***/ },
This will also create an issue if the problem where the "use strict"
Tried:
In both cases the reason was not the mentioned here, but is there some sample project that I can try ?
I don't think it is a problem of geolocation, the "use strict" appears 463 times in my bundle :)
I just tried it, and removing "use strict" from the nativescript-geolocation plugin (upgrading to 0.0.13) fixed it. You can try it in this demo project -- it webpacks and works fine on my end.
Just to comment @hdeshev, @PeterStaev found another solution removing the helpers: https://github.com/PeterStaev/nativescript-purchase/commit/15dcc2855117a7af75177acd40993c26783076e1
I saw the related discussion in PeterStaev/nativescript-purchase#4, and I remember having to remove both the decorator helpers and the "use strict" option. Thanks for verifying this!
Oh, and one thing I forgot. I'll update the docs article with a section for library maintainers.
Hey @hdeshev Im getting the same error but from code within my project.
The error is:
file:///app/bundle.js:22761:25: JS ERROR TypeError: Attempted to assign to readonly property.
When looking at the bundle.js I can see:
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_file_system__ = __webpack_require__(/*! file-system */ 45);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_file_system___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_file_system__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_platform__ = __webpack_require__(/*! platform */ 10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_platform___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_platform__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__shared_utils_using_simulator_util__ = __webpack_require__(/*! ../shared/utils/using-simulator.util */ 716);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__shared_utils_os_version_util__ = __webpack_require__(/*! ../shared/utils/os-version.util */ 715);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_timer__ = __webpack_require__(/*! timer */ 176);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_timer___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_timer__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return SpotAssetManager; });
/* unused harmony export SpotAssetContainer */
/* unused harmony export SpotAssetDownloadTask */
/* unused harmony export AVAssetDownloadDelegateImpl */
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
Any ideas on how to resolve this?
I've also added "noImplicitUseStrict": true,
on my tsconfig.json but no change
I'm having the same error. Any solution for this? @bnussey How do you locate the file:///app/bundle.js file?
file:///app/bundle.js:45685:25: JS ERROR TypeError: Attempted to assign to readonly property. Oct 12 09:02:15 Samos-MacBook-Pro com.apple.CoreSimulator.SimDevice.1CC4E8E8-9771-4947-B5C1-0ED7CA28D7F9.launchd_sim[20909] (UIKitApplication:mobi.tamtam.TamTam[0x1c62][20931][21843]): Service exited due to Segmentation fault: 11
Hey @rsaf that is in platforms -> ios -> appname -> bundle.js
Not sure about this issue, I think it was cause I didn't configure my tsconfig.aot.ts
to have the "noImplicitUseStrict": true
@bnussey Thank you very much for the quick response. After inspecting my bundle.js, I realized that the error was related to the nativescript-imagecropper module (version: 0.0.7). When I comment out all imagecroppring code in my app, and delete the platform folder, the error goes away.
Unfortunately setting noImplicitUseStrict": true , in the tsconfig.aot.ts didn't help.
Hey @rsaf here is my tsconfig.aot.json
for you:
{
"extends": "./tsconfig",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"application": ["node_modules/tns-core-modules/application"],
"application-settings": ["node_modules/tns-core-modules/application-settings"],
"camera": ["node_modules/tns-core-modules/camera"],
"color": ["node_modules/tns-core-modules/color"],
"connectivity": ["node_modules/tns-core-modules/connectivity"],
"console": ["node_modules/tns-core-modules/console"],
"data/*": ["node_modules/tns-core-modules/data/*"],
"fetch": ["node_modules/tns-core-modules/fetch"],
"file-system": ["node_modules/tns-core-modules/file-system"],
"fps-meter": ["node_modules/tns-core-modules/fps-meter"],
"globals": ["node_modules/tns-core-modules/globals"],
"http": ["node_modules/tns-core-modules/http"],
"image-asset": ["node_modules/tns-core-modules/image-asset"],
"image-source": ["node_modules/tns-core-modules/image-source"],
"location": ["node_modules/tns-core-modules/location"],
"platform": ["node_modules/tns-core-modules/platform"],
"text": ["node_modules/tns-core-modules/text"],
"timer": ["node_modules/tns-core-modules/timer"],
"trace": ["node_modules/tns-core-modules/trace"],
"ui/*": ["node_modules/tns-core-modules/ui/*"],
"utils/*": ["node_modules/tns-core-modules/utils/*"],
"xhr": ["node_modules/tns-core-modules/xhr"],
"xml": ["node_modules/tns-core-modules/xml"]
},
"skipLibCheck": true
},
"exclude": [
"node_modules",
"platforms"
],
"angularCompilerOptions": {
"skipMetadataEmit": true,
"genDir": "./"
}
}
@bnussey Thanks, I actually have the same tsconfig.aot.json already.
I temporarily solved my issue by manually commenting out "use strict" in the "nativescript-imagecropper" node module as stated here: https://github.com/bthurlow/nativescript-imagecropper/issues/15
nice you could submit PR for that plugin @rsaf
For example it does not work for the geolocation module, because of this code (extracted from the bundled code):
At runtime it throws:
This is just an example, but also happen to me on other modules. The only pattern I was able to found is that happends at:
function __() { this.constructor = d; }