TiShadow icon indicating copy to clipboard operation
TiShadow copied to clipboard

Wrong version of underscore

Open brentonhouse opened this issue 8 years ago • 4 comments

When I create an app, the first thing I always do is put the contents from lodash.js into /lib/alloy/underscore.js so that I can use lodash instead of the really old version of underscore that is included with alloy.

When I do this with TiShadow, references to _ in my app seem to be pulling from a version of underscore.js that is included in /build/appify/build/Resources/lib/underscore.js. I am outputing _.VERSION right before I am getting undefined errors and it is 1.4.4 and the only reference to that seems to be in the TiShadow underscore file.

Do you know why it would be picking this up? And if so, is there a way of turning that off?

Thanks!

brentonhouse avatar Sep 13 '17 02:09 brentonhouse

I will look into it. The container app for TiShadow uses underscore including PlatformRequire.js which I think is the issue, as it evaluates your (modified) source code there. At a guess you don't require underscore manually and rely on a global instance so it using the instance of _ required in the container app. Does that makes sense?

dbankier avatar Sep 13 '17 09:09 dbankier

Probably a good idea for me to just start requiring lodash in all my files. Though, I am not sure if it would work with the auto-generated Alloy files like controllers, etc because of where it places the user code in the files. I will do a few more tests with different files to see what happens. Thanks!

brentonhouse avatar Sep 13 '17 11:09 brentonhouse

I have created the file /vendor/node_modules/lodash/index.js which contains the latest version of lodash. I then require it using var _ = require('lodash');. This works with TiShadow turned off but when I turn it on, I get: Couldn't find module: lodash for architecture: x86_64.

I am guessing this is a separate issue so I can create a new github issue for this.

Thanks!

brentonhouse avatar Sep 13 '17 14:09 brentonhouse

Yep. I'm not sure if ts support node_modules base requires (I haven't used them). Separate issue, but should be easy to fix.

dbankier avatar Sep 13 '17 18:09 dbankier