Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20141] Global scope variables can be shared with CommonJS modules

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2020-01-06T15:29:00.000+0000
Affected Version/sRelease 5.1.1
Fix Version/sRelease 9.0.0
Componentsn/a
LabelsengSchedule, ios, iphone
ReporterEric
AssigneeEwan Harris
Created2015-02-03T17:31:49.000+0000
Updated2020-01-06T15:29:00.000+0000

Description

module.js
console.log(controllerVariable);
moduleVariable = "moduleVariable";
module.exports = {};
controller.js
controllerVariable = "controllerVariable";
var module = require("module");
console.log(moduleVariable);
Output when running the application is: moduleVariable controllerVariable Expected that the global scope of the controller would not be shared with the global scope of the module.

Comments

  1. Mauro Parra-Miranda 2015-02-04

    Hello, please read the guide to report issues: http://docs.appcelerator.com/titanium/3.0/#!/guide/How_to_Submit_a_Bug_Report and provide at least: - Description of the problem - Steps to reproduce - Expected Results - Actual Results If you want/need to add a new feature, explain what you need, why you need it, and what you expect to be a solution.
  2. Eric 2015-02-04

    Description of the problem: Global scope variables can be shared with CommonJS modules Steps to reproduce: 1) Here is the source for the module: module.js
       console.log(controllerVariable);
       moduleVariable = "moduleVariable";
       module.exports = {};
       
    2) Here is the source for the controller: controller.js
       controllerVariable = "controllerVariable";
       var module = require("module");
       console.log(moduleVariable);
       
    Actual results (console output): moduleVariable controllerVariable Expected results (neither variable should be defined in the scope it is logged): undefined undefined If it was strict mode, I would expect an exception for not finding the variables. What other information is necessary so that I can provide it to you? This was all in the original report.
  3. Ewan Harris 2019-12-10

    node-titanium-sdk PR: https://github.com/appcelerator/node-titanium-sdk/pull/129
  4. Christopher Williams 2019-12-10

    merged the node-titanium-sdk PR, once 4.0.0 goes out we'll need to fold that into the SDK
  5. Christopher Williams 2019-12-10

    merged to master for 9.0.0: https://github.com/appcelerator/titanium_mobile/pull/11387
  6. Samir Mohammed 2020-01-06

JSON Source