[TIMOB-10491] iOS: Changes to how iOS does require in 2.2 have broken require
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-12-21T05:25:09.000+0000 |
Affected Version/s | Release 3.0.0 |
Fix Version/s | Sprint 2012-17 Core, Release 3.0.0 |
Components | iOS |
Labels | core, module_require, qe-review, qe-testadded, regression |
Reporter | Russell McMahon |
Assignee | Max Stepanov |
Created | 2012-08-17T19:00:27.000+0000 |
Updated | 2012-12-21T05:25:09.000+0000 |
Description
When running Alloy on iOS 2.2.0 master the alloy.js commonjs module can not be found. It is required in as require('alloy') other modules are loading okay. The path to alloy.js is Resources/alloy.js there is also a folder alloy.
Here's a minimal test case that is *NOT* alloy specific. The name alloy is used for the modules and it uses a similar structure, but this is pure Titanium code. These following three files do not require Alloy to show the following error: {quote} [ERROR] Script Error = Couldn't find module: alloy 2012-08-21 19:05:31.125 testRequireBug[28934:1a70b] *** Terminating app due to uncaught exception of class '__NSCFString' terminate called throwing an exception [INFO] Application has exited from Simulator {quote}
Test Case
app.js
alloy.js
alloy/controllers/index.js
It is also worth nothing that Alloy works fine with the lastest TiSDK 2.2.0 with Android and Mobileweb. Alloy actually worked with iOS on 2.2.0 up until about a week or two ago.
Looking at the code with Blain it appears that perhaps the commonjs spec may not have been followed as intended in the latest iOS code. Please see #4, #5 below as it talks about top level modules: CommonJS 1.1 Spec - Module Identifiers 1) A module identifier is a String of "terms" delimited by forward slashes. 2) A term must be a camelCase identifier, ".", or "..". 3) Module identifiers may not have file-name extensions like ".js". 4) Module identifiers may be "relative" or "top-level". A module identifier is "relative" if the first term is "." or "..". 5) Top-level identifiers are resolved off the conceptual module name space root. 6) Relative identifiers are resolved relative to the identifier of the module in which "require" is written and called.
PR pending https://github.com/appcelerator/titanium_mobile/pull/2806
Pull merged.
No error shown when tested by creating a titanium app and module named alloy Verified on: Titanium Studio: 2.1.2.201208201549 Titanium SDK: 2.2.0.v20120827143312 iPhone Simulator (v5.1)