[TIMOB-24796] iOS: Hybrid CommonJS and Native modules don't handle multiple js files
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-06-15T18:36:20.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.1.1 |
Components | iOS |
Labels | merge-6.1.1, mobilesdk, module, user_experience, validate |
Reporter | Andrea Vitale |
Assignee | Christopher Williams |
Created | 2017-06-08T17:48:05.000+0000 |
Updated | 2017-06-15T22:48:58.000+0000 |
Description
Hi, I tested this using 6.1.0.GA and it works only for a single commonjs file.
Suppose that you have a module called it.commonjs.test.module and in your assets folder you have two files called:
it.commonjs.test.module.js
another.module.js
In the second one you have:
module.exports = {
sayWelcome: function() {
Ti.API.info("Welcome from the second commonjs module");
}
};
In the first one you have:
module.exports = {
sayHello: function() {
alert("Hello!");
},
secondModule: require("it.commonjs.test.module/another.module")
}
You can successfully build the module but when you try to run an app that requires the it.commonjs.test.module module you get an error like:
[ERROR] Script Error Couldn't find module: it.commonjs.test.module/another.module for architecture: i386
If you try to build the module with 3.5.1.GA sdk everything is working fine.
On Android is working also with 6.1.0.GA.
Attachments
File | Date | Size |
---|---|---|
hybrid.ios.mod.zip | 2017-06-08T20:22:14.000+0000 | 22491 |
master/6.2.0: https://github.com/appcelerator/titanium_mobile/pull/9131 6.1.1: https://github.com/appcelerator/titanium_mobile/pull/9132 I'm not really sure how this "worked" in 3.5.1, as it appears we've always mangled the file paths to turn '.' to '_' when attempting to load JS assets in a native iOS module - but I can find no version of titanium_prep that actually generated file paths with the same underscore mangling.
For testing/review: I've attached a hybrid iOS native module with two commonjs files in the assets folder. Unzip it, and attempt to build the module and run the example app.js by doing:
Prior to the PR this would complain at runtime about being unable to load the required js files. With the fix in the PR, it should not complain and the log output should show that we were able to load an object with each require call.
Tested with my sample project that works only on 3.5.1.GA. Verified the fix, everything is working now! Really thank you.
Passed FR with this environment: Node Version: 6.10.3 NPM Version: 3.10.10 Mac OS: 10.12.4 Appc CLI: 6.2.2 Appc CLI NPM: 4.2.9 Titanium SDK version: 6.1.1 locally built with the appropriate pr Appcelerator Studio, build: 4.9.0.201705302345-39 Xcode 8.3.2 Hyperloop 2.1.0 (master) and 2.0.1 I built the module and used the module in the demo app. No errors were seen at any stage, and the app worked as expected.
Verified that the fixes are here: SDK 6.1.1.v20170615113917 SDK 6.2.0.v20170615115004 Closing ticket.