{"id":284,"date":"2016-03-31T21:41:43","date_gmt":"2016-03-31T21:41:43","guid":{"rendered":"http:\/\/fluentreports.com\/blog\/?p=284"},"modified":"2016-04-01T00:23:16","modified_gmt":"2016-04-01T00:23:16","slug":"nativescript-enabling-beta-android-v8-features","status":"publish","type":"post","link":"https:\/\/fluentreports.com\/blog\/?p=284","title":{"rendered":"NativeScript: Enabling beta android v8 features"},"content":{"rendered":"<p><a href=\"http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2016\/03\/nv8.png\" rel=\"attachment wp-att-289\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-289 alignright\" src=\"http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2016\/03\/nv8.png\" alt=\"nv8\" width=\"320\" height=\"285\" srcset=\"https:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2016\/03\/nv8.png 674w, https:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2016\/03\/nv8-300x267.png 300w, https:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2016\/03\/nv8-624x555.png 624w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a>One of the interesting things about the v8 engine is there is a lot of development going on behind the scenes that you can actually enable right now.\u00a0 This is supported in NodeJS, Chrome, and yes even NativeScript.<\/p>\n<p>Currently v8 for NativeScript 1.7 Android is running on v4.7.80 -- \u00a0 So because this is fairly old; a lot of the ES6 code has not been exposed to the engine. \u00a0 As NativeScript adopts the newer v8 engines, most of the ES6 functionality should start becoming available by default. \u00a0\u00a0 However if you are inpatient, you can enable this in your own NativeScript application.\u00a0 Please note; some of the functionality might work perfectly; but some of it might be very buggy; that is why it is behind feature flags.<\/p>\n<p>To enable functionality; you need to open the \"package.json\" folder in your \"app\" folder; it typically will look like this:<br \/>\n<pre>{\n&nbsp;&nbsp;&quot;name&quot;: &quot;tns-template-hello-world&quot;,\n&nbsp;&nbsp;&quot;main&quot;: &quot;app.js&quot;,\n&nbsp;&nbsp;&quot;version&quot;: &quot;1.7.0&quot;,\n&nbsp;&nbsp;&quot;author&quot;: {\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;name&quot;: &quot;Telerik&quot;,\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;email&quot;: &quot;support@telerik.com&quot;\n&nbsp;&nbsp;},\n&nbsp;&nbsp;&quot;description&quot;: &quot;Nativescript hello-world project template&quot;,\n&nbsp;&nbsp;&quot;license&quot;: &quot;Apache-2.0&quot;,\n&nbsp;&nbsp;&quot;keywords&quot;: [\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;telerik&quot;,\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;mobile&quot;,\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;nativescript&quot;,\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;{N}&quot;,\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;tns&quot;,\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;appbuilder&quot;,\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;template&quot;\n&nbsp;&nbsp;],\n&nbsp;&nbsp;&quot;repository&quot;: {\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;type&quot;: &quot;git&quot;,\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;url&quot;: &quot;git:\/\/github.com\/NativeScript\/template-hello-world.git&quot;\n&nbsp;&nbsp;},\n&nbsp;&nbsp;&quot;bugs&quot;: {\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;url&quot;: &quot;https:\/\/github.com\/NativeScript\/template-hello-world\/issues&quot;\n&nbsp;&nbsp;},\n&nbsp;&nbsp;&quot;homepage&quot;: &quot;https:\/\/github.com\/NativeScript\/template-hello-world&quot;,\n&nbsp;&nbsp;&quot;android&quot;: {\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;v8Flags&quot;: &quot;--expose_gc&quot;\n&nbsp;&nbsp;},\n&nbsp;&nbsp;&quot;readme&quot;: &quot;ERROR: No README data found!&quot;,\n&nbsp;&nbsp;&quot;_id&quot;: &quot;tns-template-hello-world@1.7.0&quot;,\n&nbsp;&nbsp;&quot;_from&quot;: &quot;tns-template-hello-world@1.7.0&quot;\n}<\/pre><br \/>\nYes, this is the STOCK 1.7.0 hello world template definition.\u00a0\u00a0\u00a0\u00a0 Do you see about 5 lines up the package.json from the bottom?<\/p>\n<p><strong>\"android\": {<\/strong><br \/>\n<strong>\u00a0 \"v8Flags\": \"--expose_gc\"<br \/>\n<\/strong><strong>}<\/strong><\/p>\n<p>Well, that is where you would add your flags; <strong>!!!WARNING!!! DO NOT REMOVE the --expose_gc <\/strong>if you remove it, your app will crash when NS attempts to manually do garbage collection.\u00a0 So, trust me when I say, do not remove it!<\/p>\n<p>So some of the flags you can add and use are:<\/p>\n<ul>\n<li>--use_strict = Will force everything to be in strict mode<\/li>\n<li><span class=\"pl-s\">--harmony_proxies = Enable ES6 Proxy support<\/span><\/li>\n<li><span class=\"pl-s\">--harmony_collections = Enable ES6 Maps\/Sets<br \/>\n<\/span><\/li>\n<li>--harmony_typeof = Enable ES6 Typeof<\/li>\n<li>--harmony_scoping = Enable ES6 Scoping rules<\/li>\n<li>--harmony_generators = Enabled ES6 Generators<\/li>\n<li>--harmony_itteration = Enable ES6 for-of<\/li>\n<li>--harmony_numeric_literals = Enables the new ES6 number constants<\/li>\n<li>--harmony_strings = Enable new ES6 String features<\/li>\n<li>--harmony_arrays = Enable new ES6 Array features<\/li>\n<li>--harmony_maths = Enable new ES6 Math features<\/li>\n<\/ul>\n<p>These are all Harmony \/ ES6 related; some of the ES6 code might already be exposed; some of the ES6 code doesn't work real well and might be incomplete.\u00a0 Please note that some of these ES6 features may already be fully live in the engine. \u00a0 As NS gets closer to 5.1 of the v8 the more feature will be completed and exposed by default without having to use these flags.\u00a0\u00a0 There are MANY other <a href=\"https:\/\/github.com\/thlorenz\/v8-flags\/blob\/master\/flags-0.11.md\" target=\"_blank\">flags <\/a>you can use to tune the v8 engine and disable functionality; however if you don't know how what they do and the ramifications of using them, I would <strong>not<\/strong> set them in any customer facing application.<\/p>\n<p>So if you wanted to enable the new Array &amp; new Typeof abilities your <strong>android<\/strong> section would be<\/p>\n<p><strong>\"android\": {<\/strong><br \/>\n<strong>\u00a0 \"v8Flags\": \"--expose_gc --harmony_array --harmony_typeof\"<br \/>\n<\/strong><strong>}<\/strong><\/p>\n<p>One other word of caution; these are ONLY for Android; this does not effect the iOS or Windows runtimes.\u00a0 So if you enable a feature in Android; that same code may or may not run on iOS or Windows.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the interesting things about the v8 engine is there is a lot of development going on behind the scenes that you can actually enable right now.\u00a0 This is supported in NodeJS, Chrome, and yes even NativeScript. Currently v8 for NativeScript 1.7 Android is running on v4.7.80 -- \u00a0 So because this is fairly&hellip; <a class=\"more-link\" href=\"https:\/\/fluentreports.com\/blog\/?p=284\">Continue reading <span class=\"screen-reader-text\">NativeScript: Enabling beta android v8 features<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[15,39],"tags":[],"class_list":["post-284","post","type-post","status-publish","format-standard","hentry","category-nativescript","category-tips","entry"],"_links":{"self":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=284"}],"version-history":[{"count":4,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/284\/revisions"}],"predecessor-version":[{"id":291,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/284\/revisions\/291"}],"wp:attachment":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}