Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5434] Android: require() in a non-root context breaks any include() statements below it.

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2012-01-09T13:48:17.000+0000
Affected Version/sRelease 1.8.0
Fix Version/sSprint 2011-42, Release 1.7.4, Release 1.8.0
ComponentsAndroid
Labelsmodule_module, qe-testadded
ReporterBill Dawson
AssigneeBill Dawson
Created2011-10-04T18:26:18.000+0000
Updated2012-10-24T21:04:40.000+0000

Description

If an app has a second (or third, or fourth...) Javascript execution context (via a window being opened with a url property), a require() statement anywhere in that context will break any include() statements below it. Reproduction of the failcase (and test of the fix): In a new app use this app.js:
Ti.UI.createWindow({
	url: "win.js", // causes new JS context
	backgroundColor: "#000",
	exitOnClose: true
}).open();
And this win.js:
require("module"); // Don't need return value, just important that this runs.
Ti.include("included.js");
alert("The included word is " + includedWord);
And this module.js:
exports.x = function() {}; //not important
And this included.js:
var includedWord = "test";
When you run that, you'll get an error in the failcase, saying that includedWord is not defined. When testing the fix, you should see an alert dialog telling you "The included word is test".

Comments

  1. Bill Dawson 2011-10-04

    Pull request ready: https://github.com/appcelerator/titanium_mobile/pull/526
  2. Alan Vaghti 2011-10-06

    Closing. Passed as expected on Nexus One running 2.2.2 with SDK 1.8.0.v20111006001414.
  3. Bill Dawson 2011-10-21

    Re-opening b/c will need to be re-tested with changes coming for TIMOB-5748
  4. Bill Dawson 2011-10-21

    New pull request ready: https://github.com/appcelerator/titanium_mobile/pull/578
  5. Mark Burggraf 2011-11-11

    This problem is still occurring for me on 1.7.x (both 1.7.5 and the current 1.7.6 build as of Nov 10, 2011). I am including event handlers into a CommonJS module via Ti.include, but they're not showing up at runtime.
  6. Mark Burggraf 2011-11-11

    I take that back. The events get included. However, the included events refer to functions in the main (CommonJS) file, but it can't see them. I get an error "Cannot find function xxxx in object [object Object]".
  7. Natalie Huynh 2011-12-06

    Tested with 1.8.0.1.v20111205164258 v8/rhino on Galaxy 10.1 (3.1) Droid 1 (2.2.2) Nexus S (2.3.6) Emulator (4.0)
  8. Dustin Hyde 2012-01-09

    Added label: qe-testadded.

JSON Source