[TIMOB-23997] iOS and Android revert incorrect CommonJS module changes
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-12-05T18:04:46.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.1.0 |
Components | Tooling |
Labels | cb-tooling |
Reporter | Chris Barber |
Assignee | Christopher Williams |
Created | 2016-10-07T06:18:43.000+0000 |
Updated | 2017-07-19T15:21:27.000+0000 |
Description
Both the Android and iOS build have a bug when resolving the main JS file in a CommonJS Titanium module. Normally the JS files are named
<module id>.js
, but if this doesn't exist, it should:
* See if there's a package.json
* If there is, read it in and find a main
property
* Check that the file defined by main
actually exists
* If exists, use it
* If not exists, look for an index.js
file
As apart of TIMOB-23382 (PR https://github.com/appcelerator/titanium_mobile/pull/8004), the logic is bad. It will set the module.libFile
to package.json
or index.json
which is technically incorrect. The good news is module.libFile
for CommonJS modules is not used anywhere, however we should still fix it.
Attachments
File | Date | Size |
---|---|---|
modules.zip | 2016-10-11T20:22:12.000+0000 | 14995 |
timob23997BuildLog.rtf | 2016-12-05T19:50:53.000+0000 | 29438 |
TiSDK master PR: https://github.com/appcelerator/titanium_mobile/pull/8500 To test, add the following to your
tiapp.xml
:Then unzip the attached
modules.zip
file into your project directory and build the app for both iOS and Android. You should see something like the following:I reverted all changes to the build with respect to CommonJS modules in the Android and IOS build. TiSDK master PR: https://github.com/appcelerator/titanium_mobile/pull/8500 TiSDK 6_0_X PR: https://github.com/appcelerator/titanium_mobile/pull/8623
The PRs here have broken functionality for us to support commonJS modules that don't have a file named the exact same as the module id inside.
https://github.com/appcelerator/titanium_mobile/pull/8649 https://github.com/appcelerator/titanium_mobile/pull/8648
I tested with this environment: NPM Version: 2.15.9 Node Version: 4.5.0 Mac OS: 10.12.1 Appc CLI: 6.0.0 Appc CLI NPM: 4.2.8 Titanium SDK version: 6.0.1.v20161202124626 Appcelerator Studio, build: 4.8.0.201611121409 Xcode 8.1 GM I did get the messages that the modules were found. However, I also got this message for each module when I tried to build it on either Android or iOS device:
The log is attached. [^timob23997BuildLog.rtf]
NPM Version: 2.15.9 Node Version: 4.5.0 Mac OS: 10.12.1 Appc CLI: 6.0.0 Appc CLI NPM: 4.2.8 Titanium SDK version: 6.1.0.v20161205110006 Appcelerator Studio, build: 4.8.0.201611121409 Xcode 8.1 GM Fix is validated. Note that fix was validated using the attached zip, which has a min SDK 6.1.0
since the update to 6.1.0, the app freezes on startup on a real device (everything works fine on the simulator). The app is pre-alloy, so everything is in CommonJS. The error I get: [ERROR] Application received error: undefined is not a constructor (evaluating 'new(void 0)') at downloader.js (line 1) [ERROR] Application received error: Module "module/controllers/loginController.js" failed to leave a valid exports object The only thing I can think of, is that inside downloader.js there's this kind of code: --- var downloader = function() { var myModule = require('com.myNativeModule'); var downloadUtility = require("/module/helpers/download_utility"); [.....] } module.exports = downloader; ---
not sure if the error is related to this ticket, I went through all of the fixes/new features and this looked something that could interfere with CommonJS and modules. In case I will open a new ticket.