nativescript-oauth
nativescript-oauth copied to clipboard
[Question] Is this plugin supported in {N} + Angular's AoT compilation
Hi,
I have a question because I am getting an strange error when compiling my project to AoT (here is how to do it) and was wondering if this plugin is actually supported in AoT bundled {N} + Angular projects?
The error I am getting is at runtime on IOS (haven't tested Android) and is:
file:///app/bundle.js:15318:25: JS ERROR TypeError: Attempted to assign to readonly property.
and here is the code of the bundle.js (only the related code for 15318 row), the error is at the row (function __() { this.constructor = d; }
):
/***/ }),
/* 525 */
/* unknown exports provided */
/* all exports used */
/*!***************************************************************!*\
!*** ../~/nativescript-oauth/tns-oauth-webview-helper.ios.js ***!
\***************************************************************/
/***/ (function(module, exports, __webpack_require__) {
"use strict";
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; } // THIS IS THE ROW 15318
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var TnsOAuthWebViewHelper = (function (_super) {
__extends(TnsOAuthWebViewHelper, _super);
function TnsOAuthWebViewHelper() {
return _super.call(this) || this;
}
...
Hi @VladimirAmiorkov This project could really benefit from a modification to support webpack + AoT. At this time, bundling and AoT remains untested (except what you've reported in this thread). Thanks for bringing it to my attention, but I won't be able to create support for this for a couple months. If you want to contribute, please do.
Thanks, Alex
Hi @alexziskind1 ,
I will give it a shot as I am currently working on a project that I want to use this plugin but AoT is very important so I am kind of between a rock and a hard place :) atm.
I have the same problem, I will try to solve this error. But in case it is not resolved someone knows what other plugin I can use to create a login with Facebook?
Hi @VladimirAmiorkov . Have you had any success with getting this to work with AOT? I'm looking at the line that's giving you an error and it looks like it's occurring in the __extends function, which is auto-generated from TypeScript. However, the code you've pasted looks like an older version of the generated __extends function. Have you tried updating the nativesript-oauth plugin to the latest version, which will have the latest __extends function?
Hi @alexziskind1 ,
I haven't had the chance to make a PR for this or test it. I simply stopped using it as it was not essential to me at that point but will be in the future so it would be good if this plugin can be migrated to 3.0 and AoT at some point of time.
Hopefully we will have compatibility with WebPack
EDIT:
I just compiled with AOT successfully, using the latest version "nativescript-oauth": "^ 2.0.1"
EDIT 2:
False alarm. The project compiles well, however when running my application on the device is frozen in the splash Screen.
Then, I get the same error:
JS ERROR TypeError: Attempted to assign to readonly property.
Does anyone know any alternatives, to log in with Facebook and have compatibility with AoT?
I'm doing some investigation on this one to hopefully get it working soon. I'm working on iOS first and have found that the exception is caused by TnsOAuthWebViewHelper
failing to inherit from NSObject
when bundled by webpack - hence why the exception is thrown in the __extends
function. I'm going to poke around the bundle a bit and see what the deal is, as many Nativescript-provided classes also inherit from NSObject
and work with bundling.
Welp, apparently I was on the wrong track - I found an issue with the __assign TypeScript helper in the custom auth provider I recently added. So, I tried rewriting it without using the ...
operator, and lo and behold Webpack bundling and AOT are working for me now! I'm going to PR my changes, but unfortunately I doubt it'll fix bundling and AOT for everyone