{ "id": "167879", "key": "TIMOB-24726", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2017-05-23T21:44:30.000+0000", "created": "2017-05-23T20:35:36.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "ES6", "Titanium" ], "versions": [], "issuelinks": [], "assignee": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "updated": "2017-05-23T21:44:30.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [], "description": "When calling {{require('animal')}} I am getting the following error:\r\n\r\n{noformat}\r\n[ERROR] message = \"Unexpected use of reserved word 'class'\";\r\n{noformat}\r\n\r\n\r\nanimal.js\r\n\r\n\r\n{code:java}\r\n'use strict';\r\n\r\nclass Animal { \r\n\tconstructor(name) {\r\n\t\tthis.name = name;\r\n\t}\r\n\tspeak() {\r\n\t\tconsole.log(this.name + ' makes a noise.');\r\n\t}\r\n}\r\n\r\nmodule.exports = Animal;\r\n{code}\r\n", "attachment": [], "flagged": false, "summary": "iOS: Error when requiring ES6 class ", "creator": { "name": "brentonhouse", "key": "brentonhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "subtasks": [], "reporter": { "name": "brentonhouse", "key": "brentonhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "environment": "iOS\r\nTI SDK: 6.1.0.v20170519131839 (RC Build)\r\nAlloy: 1.10.0\r\nHyperloop: Not enabled", "comment": { "comments": [ { "id": "420280", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, Can you provide a full reproducible code and steps to generate the issue? Thanks.", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-05-23T20:48:07.000+0000", "updated": "2017-05-23T20:48:07.000+0000" }, { "id": "420281", "author": { "name": "brentonhouse", "key": "brentonhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "body": "Steps to recreate:\r\n\r\n1. Create new Titanium app using CLI\r\n2. Create new file: {{lib/animal.js}}\r\n\r\n\r\n\r\n{code:java}\r\n'use strict';\r\n\r\nclass Animal { \r\n\tconstructor(name) {\r\n\t\tthis.name = name;\r\n\t}\r\n\tspeak() {\r\n\t\tconsole.log(this.name + ' makes a noise.');\r\n\t}\r\n}\r\n\r\nmodule.exports = Animal;\r\n{code}\r\n\r\n3. Add the following line to {{controllers/index.js}}:\r\n\r\n\r\n{code:java}\r\nrequire('animal');\r\n{code}\r\n\r\n3. Run the app: {{appc ti build --platform ios --target simulator --log-level trace}}", "updateAuthor": { "name": "brentonhouse", "key": "brentonhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "created": "2017-05-23T21:00:35.000+0000", "updated": "2017-05-23T21:00:35.000+0000" }, { "id": "420282", "author": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "body": "Is this at runtime? If so, it's because you need to switch to the bundled JSCore engine from iOS to get ES6 support. Our TiCore fork is very old. You do that by setting a special value in your tiapp.xml:\r\n\r\n{code:xml}\r\n\r\n \r\n true\r\n \r\n\r\n{code}\r\n\r\nthere's more details on the PR itself about this: https://github.com/appcelerator/titanium_mobile/pull/8972\r\n\r\nBut basically, we do not transpire your ES6 code down to ES5 on older engines (yet). We pass the code through and it's up the JS engine if it supports it. TiCore is very old and does not. Using bundled JSCore means it's up to the iOS version you're running (see https://kangax.github.io/compat-table/es6/)", "updateAuthor": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "created": "2017-05-23T21:02:11.000+0000", "updated": "2017-05-23T21:02:11.000+0000" }, { "id": "420289", "author": { "name": "brentonhouse", "key": "brentonhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "body": "Sorry about that [~cwilliams]! Forgot to switch that on for the new project. You can close this ticket.", "updateAuthor": { "name": "brentonhouse", "key": "brentonhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "created": "2017-05-23T21:25:55.000+0000", "updated": "2017-05-23T21:25:55.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }