{
"id": "173836",
"key": "TIMOB-27206",
"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": null,
"resolutiondate": null,
"created": "2019-07-02T19:52:43.000+0000",
"priority": {
"name": "None",
"id": "6"
},
"labels": [
"alloy",
"engSchedule",
"liveview"
],
"versions": [],
"issuelinks": [
{
"id": "58368",
"type": {
"id": "10620",
"name": "Gantt End to End",
"inward": "has to be finished together with",
"outward": "has to be finished together with"
},
"outwardIssue": {
"id": "175014",
"key": "TIMOB-27899",
"fields": {
"summary": "Common: path.parse with a file extension but no directory results in an invalid dir value",
"status": {
"description": "The issue is open and ready for the assignee to start work on it.",
"name": "Open",
"id": "1",
"statusCategory": {
"id": 2,
"key": "new",
"colorName": "blue-gray",
"name": "To Do"
}
},
"priority": {
"name": "None",
"id": "6"
},
"issuetype": {
"id": "1",
"description": "A problem which impairs or prevents the functions of the product.",
"name": "Bug",
"subtask": false
}
}
}
}
],
"assignee": {
"name": "eharris",
"key": "eharris",
"displayName": "Ewan Harris",
"active": true,
"timeZone": "Europe/Dublin"
},
"updated": "2021-02-22T20:01:37.000+0000",
"status": {
"description": "The issue is open and ready for the assignee to start work on it.",
"name": "Open",
"id": "1",
"statusCategory": {
"id": 2,
"key": "new",
"colorName": "blue-gray",
"name": "To Do"
}
},
"components": [
{
"id": "13600",
"name": "LiveView",
"description": "Live preview of Titanium apps"
}
],
"description": "SDK: 8.0.2.GA\r\nTitanium: 5.2.1\r\nAlloy: 1.14.0-1\r\n--------------------------------\r\n\r\nUPDATE: Upon further investigation, I've found that it is more than just Alloy.Globals that is being affected by this. Every time alloy is required using `require()` it is getting a fresh version so any changes that were made to the same module in a different class are lost. \r\n\r\nrequire('/alloy') on index.js gets a clean version and thus all changes made in alloy.js are gone. Even if I move all the logic of assigning things to Alloy.Globals to index.js, everything added is gone when the next controller is loaded.\r\n\r\nI have a stand-alone project that I can share to duplicate this issue.\r\n\r\n--------------------------------\r\nWhen defining an event handler function in alloy.js:\r\n\r\n\r\n{code:java}\r\nAlloy.Globals.eventHandler = e => {\r\n\tconsole.error('you are here → Alloy.Globals.eventHandler1');\r\n\talert('button clicked 1');\r\n}\r\n\r\n{code}\r\n\r\nand then using it in index.xml:\r\n\r\n\r\n{code:xml}\r\n\r\n{code}\r\n\r\n\r\nWhen this auto-generated controller code is executed:\r\n\r\n\r\n{code:java}\r\n$.addListener($.__views.label1, 'click', Alloy.Globals.eventHandler);\r\n{code}\r\n\r\n\r\nIt gets to this code in the BaseController:\r\n\r\n\r\n{code:java}\r\nproxy.addEventListener(type, callback);\r\n{code}\r\n\r\n\r\nand then throws an error because callback is undefined. \r\n\r\n\r\n{code}\r\n[INFO] [LiveView] Error Evaluating app.js @ Line: 430\r\n[ERROR] Error: Invalid type passed to function\r\n[ERROR] File: app.js\r\n[ERROR] Line: 430\r\n[ERROR] SourceId: \r\n[ERROR] Backtrace:\r\n[ERROR] undefined\r\n\r\n{code}\r\n\r\nThe file is actually BaseController.js Line: 430 but it just reports app.js when using LiveView.\r\n\r\nNOTE: This does not happen in every app. I am not sure how LiveView is handling alloy.js code so I might need to get more familiar with that before I can say what or why Alloy.Globals.eventHandler would be undefined even though it is defined in alloy.js.",
"attachment": [],
"flagged": false,
"summary": "LiveView: unable to require files under node_modules",
"creator": {
"name": "bhouse",
"key": "bhouse",
"displayName": "Brenton House",
"active": true,
"timeZone": "America/Chicago"
},
"subtasks": [],
"reporter": {
"name": "bhouse",
"key": "bhouse",
"displayName": "Brenton House",
"active": true,
"timeZone": "America/Chicago"
},
"environment": null,
"comment": {
"comments": [
{
"id": "449592",
"author": {
"name": "eharris",
"key": "eharris",
"displayName": "Ewan Harris",
"active": true,
"timeZone": "Europe/Dublin"
},
"body": "So this looks down to be reproducible sample vendoring the node_modules. Here's my observations\r\n\r\n* The {{require('alloyxl')}} call at the top of the file seems to be the root cause of the problems here\r\n* This is because liveview has no real support for loading from node_modules, it has some code that was used to support loading the polyfilling libs that looks into the Resources dir as well as the build dir, so when requiring {{alloyxl}} the liveview server cant find the module and responds with a 404, causing the liveview app code to fallback to the \"native require\", which does know about node_modules, so requires it successfully, I believe this fallback is intended for native modules and not js files. \r\n* I suspect that because of the differences in how the require mechanisms work, this is then causing problems which is breaking Alloy.Globals. Commenting out that require, or putting an alloyxl.js file under lib fixes the issue.\r\n\r\nI guess technically this is a bug in liveview, but it's due to a use case that liveview has never stated to support (but it should).",
"updateAuthor": {
"name": "eharris",
"key": "eharris",
"displayName": "Ewan Harris",
"active": true,
"timeZone": "Europe/Dublin"
},
"created": "2019-07-03T13:50:44.000+0000",
"updated": "2019-07-03T13:50:44.000+0000"
},
{
"id": "449595",
"author": {
"name": "bhouse",
"key": "bhouse",
"displayName": "Brenton House",
"active": true,
"timeZone": "America/Chicago"
},
"body": "I added another test to the app where I am doing a new require from node_modules: require('test1')\r\n\r\nWhen I do this in alloy.js and assign a property a value, that value is still there when I require it again in index.js.\r\n\r\nThis would seem to contradict the theory from above...",
"updateAuthor": {
"name": "bhouse",
"key": "bhouse",
"displayName": "Brenton House",
"active": true,
"timeZone": "America/Chicago"
},
"created": "2019-07-03T14:33:30.000+0000",
"updated": "2019-07-03T14:33:30.000+0000"
},
{
"id": "453241",
"author": {
"name": "bhouse",
"key": "bhouse",
"displayName": "Brenton House",
"active": true,
"timeZone": "America/Chicago"
},
"body": "The flip-side also seems to be an issue. If I am requiring a file (like alloy.js) from a JavaScript file under node_modules, it seems to give me a new context and any properties that were set on it at runtime are absent.",
"updateAuthor": {
"name": "bhouse",
"key": "bhouse",
"displayName": "Brenton House",
"active": true,
"timeZone": "America/Chicago"
},
"created": "2019-12-18T20:28:40.000+0000",
"updated": "2019-12-18T20:28:40.000+0000"
}
],
"maxResults": 6,
"total": 6,
"startAt": 0
}
}
}