-
-
Notifications
You must be signed in to change notification settings - Fork 40
Bundler causes serious weird/crashing issues with ios ng apps with several plugins. #8
Comments
Regarding the first two issues, are you using the UglifyJS plugin or is this behavior so in the default config. |
I just do a As far as I know no uglifyJS is being activated; The webpack config file:
|
I am currently blocked by this issue in a bad way :( I have an app I would like to deploy to app store but cannot bundle it properly due to these issues. The unbundled app is 136 Mb so it would be unacceptable to post such a large app which I want to be a great production example of a nativescript-angular app. |
Does the first iOS extends issue happen with a blank application ( If you could send a sample or just the extend snippet that's happening I'll be more than interested to investigate it further. |
Notice the title, with plugins. :-) That is probably the missing factor. I have figured a way around all 4 issues (all though all 4 issues are still valid issues). They are no longer blocking for me (or Walker). The first two issues are causes by several of the plugins having their own __extends function. This version of the __extends is then inlined by webpack and then space/tab padded which makes it change the "fingerprint" of the __extends function causing it to fail the built in ios runtime __extends fingerprint regex check. My solution was to add a webpack plugin that strips all __extends from the source as it packs the bundle. This seems to be the simplest solution, and it appears that it worked for me, as I was able to get quite a ways into the app before it crashed again. (See #10 ) This issue will probably hit anyone using any number of popular plugins as a large chunk of the plugins that ship have the built in __extends function in final js file. And when webpack bundles them up; it will crash with all sorts of interesting fireworks. :-) |
Can you give an example of such plugin, I want to try it out. |
nativescript-cardview, nativescript-ezaudio, nativescript-gif, nativescript-intl, nativescript-spotify |
It shouldn't rewrite the global |
Well, let me restate it; I think that this is the FIRST one being defined; because it was where the crash was always occurring. The line number was always in the ns-spotify/src/ios/notification.js __extends, in side the __() { this.constructor = d; } It took me a little while to figure out what was causing the error with TypeError read only property being set. It ended up being the actual NSObject from the TNSSpotifyNotificationObserver in this file. Once I eliminated the "use strict"; at the top; it was fine because then it would "ignore" the read only type error on the attempt to re-assign; then I got the error with the _super.apply constructor because it was being fired on a NSObject (and NSObject's don't apparently have an "apply" function). |
I have an issue which is might be related to this. I'm using Angular and every time that I try to use I'm new to webpack still, but I can tell only when I compile with
The plugin I'm testing now is registerElement("PullToRefresh", () => require("nativescript-pulltorefresh").PullToRefresh); I've tried using globals and global.require as well, but doesn't give me bugs, as well as not working.
|
Thanks @NathanaelA, I fixed it removing the http://stackoverflow.com/questions/36556772/webpack-and-typescript-extends Perhaps @NathanWalker would like to add this *.ts setup to the nativescript-ng2-plugin-seed |
TypeScript creates an `__extends` function which [breaks most of apps in {N}](NativeScript/nativescript-dev-webpack#8). A simple fix is settings to `noEmitHelpers` to true.
Adding noEmitHelpers to TypeScript avoid the creating of the __extends() function which breaks WebPack. Read more: NativeScript/nativescript-dev-webpack#8 http://stackoverflow.com/questions/36556772/webpack-and-typescript-extends
Adding `noEmitHelpers` to TypeScript avoid the creating of the `__extends()` function which breaks WebPack. Read more: NativeScript/nativescript-dev-webpack#8 http://stackoverflow.com/questions/36556772/webpack-and-typescript-extends
@leocaseiro I actually wrote a webpack plugin automatically filters out all the __extends, right after I posted this issue. Very very few things actually "stop" me for any amount of time. ;-) I would leave the "use strict" this actually allows the v8 engine and JSC engine to do certain optimizations; eliminating "use strict" makes the engine be in compatibility mode... |
Hi @NathanaelA, would you mind sharing this webpack plugin? |
@leocaseiro When I have some time, I'll post it somewhere. Trying to get a couple clients projects done... You might need to ping me later this week as I might forget all about this... |
@leocaseiro I posted it in a blog post here: |
Many, many thanks @NathanaelA. You are a legend! So far! Perhaps, you'd like to add to npm? |
@leocaseiro Not a problem, glad to help you out. It actually would be trivial to turn it into a plugin that even self-installs; but to be honest; I don't have the "free" time now. I've had to make some hard choices recently, and so my NS free time has shrunk drastically. So drastically I don't bother answering questions on StackOverflow anymore, and I really enjoy helping people. It has even taken me a couple weeks to actually fix my own LiveEdit plugin to finally work with the latest runtimes (and I use this plugin myself in all my projects). To be honest I'm not even sure if I will find the time to even release even those fixes to the community any time soon. The bills have to be paid from chasing contracts which are almost always outside of the NS community, so now that is where I have to focus... So now everything NS related pretty much stays locally, as it takes way too much "free" time to package things up. What really sucks is beyond the already large collection of unreleased plugins that I'm using in my own projects, is I still have so many other great ideas on how to enhance the NS community. Sadly due to a lack of funding I have finally faced the reality that very few of them will ever come to pass -- ah well, life goes on... Maybe I'll find some company that will want something more than a couple weeks work here and there, and so I'll get more free time, but as it stands now... |
@NathanaelA I understand that. We all need to prioritise work that pay bills. If you authorise me, I'd be happy to release an npm module and, of course, I'd add you as a collaborator. Let me know your thoughts. For the moment, I have this method running locally anyway. Again! Many many thanks for your big help and time. |
Hi guys, Sorry for replying so late, but I wanted to check all the cases @NathanaelA listed above. To me, the biggest problem is # 1 since it relies on plugin writers getting that I wasn't able to reproduce issues 2 and 3. I got the same Issue 4 seems like some corner case in webpack. I managed to reproduce it, and got to the point of the |
@hdeshev - \2. On issue number 2 this is directly related to first issue, if some of the extra __extends are present then the regex fails and so then they are ran and then crashes occur. I don't have any ideas WHY the regex failed; the __extends looks correct and looks like it should match the regex. I actually stepped through this code in the debugger many times trying to understand what was going on; that was fun... :-D If you need a failing case I'm pretty sure @NathanWalker can give you access to the repo and then you just need to delete the webpack config to eliminate the use of my extend removing plugin and you will see it crash during startup. If you remove the "use strict" in that specific version of the __extends; you will easily see number 2 occur, because then the __extends actually runs fully (w/o failing from a strict violation) and sets up the NSObject improperly and then the .apply() is attempt when the class is actually new'ed. -- Thinking about this; I wonder if you never see number 2, because the versions of the __extends you have the "use strict" set which would always cause the failure to stop the code as issue number one. When I reported this issue; my webpack config file was totally empty; I did NOT apply any minification or anything else. In fact this project for Nathan was my first dive into Webpack; I was completely unaware of the webpack config file until I needed to figure out some way to fix the issue and then I wrote the plugin and added it to the empty wepback config. So rest assured, this was a completely stock ns-dev-webpack install. :-) \3. This might be fixed now, the ng2 bug I saw yesterday was also reported by someone else in the Telerik UI Forums, and there has been a release or two of the NS-UI since that point, so @ginev might have already fixed this issue... \4. Yeah, that is a corner case -- I don't know if it needs to be fixed or just documented. It was a surprise that occurred while dealing with the other issues that I ran into. |
I've just had the same issue with RadListView for Android as well. I had to rename from I'm using Angular, and it's only happens after include the Provider: import {LISTVIEW_PROVIDERS} from 'nativescript-telerik-ui-pro/listview/angular';
nativeScriptBootstrap(myApp, [LISTVIEW_PROVIDERS]); |
Closing this one, since we have separate issues for the problems. The latest release of RadListView should be bundlable. |
I have traced down a couple ios issues caused by webpack when running with multiple plugins:
https://github.com/NativeScript/ios-runtime/blob/b7b8d69c1857d6d6293b1e33c60ac6980a4161e3/src/NativeScript/ObjC/Inheritance/ObjCTypeScriptExtend.mm#L49 -- I don't know if this is an issue for sure; but in the webpack'd code -- when this runs, it attempts to run the __() which set the this.constructor (this.constructor = d;) which when the code is set to "use strict;" will cause it to crash. This is NOT an issue if the file isn't web packed. (In fact in my tests, the normal JS __extends --- __() constructor code does not appear to be ran against a NSObject at all); however in a webpacked version the code is ran which is what causes the failure.
The text was updated successfully, but these errors were encountered: