Titanium JIRA Archive
Appcelerator Community (AC)

[AC-804] iOS: Debugger: actual breakpoint location is off by one in require()'d js modules

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2015-08-30T07:17:08.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAppcelerator CLI, Titanium SDK & CLI
Labelsdebugger-ios, ios
ReporterOlivier Morandi
AssigneeChris Barber
Created2014-09-05T09:23:15.000+0000
Updated2016-03-08T07:37:04.000+0000

Description

Since Ti SDK 3.3.0 (but not with earlier versions), when setting a breakpoint in a common js module the JSCore debugger will suspend on the previous line. This is not immediately evident in Ti Studio, since the debugger UI highlights the expected line. The following code can be used to reveal the wrong behaviour:
 exports.doSomething = function() {
	Ti.API.info("line 2");
	Ti.API.info("line 3");
	Ti.API.info("line 4");
};
var bt = require("mymodule").doSomething();
With a breakpoint set at line 4 of the mymodule.js file, the execution is suspended at line 3, with the console output showing only {noformat} [INFO] line 2 {noformat} This is caused by the commonJS wrapping code introduced by the -\[KrollBridge loadCommonJSModule:withSourceURL:\] method, which actually adds a line on top of a file being require()'d, thus creating a discordance between the code parsed by JSCore and that viewed by the editor.

Comments

  1. Olivier Morandi 2014-09-05

JSON Source