Hi thiago. I actually have read about requirejs shimming
http://requirejs.org/docs/api.html#config-shim to use non-AMD module in
requirejs. For requirejs, it's quite forward. We just need to add the shim
to requirejs.config (usually in main.js).

Looking at this thread
https://mail-archives.apache.org/mod_mbox/tapestry-users/201406.mbox/%3c273e9647-5cfe-4bf5-b0b3-9a9d5aad3...@gmail.com%3E
showed that to add the shim to requirejs.config we need to contribute to Module
Manager AND put the non-AMD js to the assets folder instead of the module
folder. And it should work.

That's what i gather from the mailing list & other resources. There's no
official Tapestry Doc about shimming, But i think this would be a very
common thing. Since people usually go to github looking for some simple
javascript lib to use in their app. And most of those js file is non-AMD
and would require shimming.

Cheers


On Wed, Feb 18, 2015 at 1:05 AM, Thiago H de Paula Figueiredo <
thiag...@gmail.com> wrote:

> Please read the Require.js documentation about this. You just cannot use
> Require.js with non AMD .js files and expect it to work without no further
> work.
>
>
> On Sat, 14 Feb 2015 14:04:36 -0200, abangkis <abang...@gmail.com> wrote:
>
>  Hello. I'm trying to load a simple regular javascript that's going to be
>> used as dependency from a RequireJS module.
>>
>> So i created mytest.js under classpath:META-INF/assets/js/mytest.js. It
>> contain a single function :
>>
>> function showMe() {
>> alert("test 2  my_test");
>> };
>>
>> I add the contribution in AppModule
>>
>>     public static void contributeModuleManager(
>> MappedConfiguration<String,
>> Object> configuration,
>>             @Path("/META-INF/assets/js/mytest.js") Resource js) {
>>         configuration.add("mytest", new JavaScriptModuleConfiguration(
>> js));
>>     }
>>
>> Create a test page
>>
>> @Import(module = "Lima")
>> public class Lima {
>> }
>>
>> that call the module :
>>
>> require(['mytest'],
>> function(mytest){
>> console.log("mytest " + mytest);
>> mytest.showMe();
>> });
>>
>> the module is loaded, the mytest.js file is found. But the console log
>> mytest as undefined. Here's what's printed on the console
>>
>> Loading 2 libraries
>> console.js:104 Loading library
>> /KomuttaCentral/assets/ctx/z1d218c13/js/jquery-2.0.3.min.js
>> console.js:104 Loading library
>> /KomuttaCentral/assets/ctx/z50c3674f/js/scripts.js
>> console.js:104 Executing 1 inits
>> console.js:104 Loaded module Lima
>> console.js:104 All inits executed
>> Lima.js:3 mytest undefined
>> console.js:104 RequireJS error: require: Cannot read property 'showMe' of
>> undefined
>>
>> So, what did i do wrong? Thanks.
>>
>
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
http://www.mreunionlabs.net/ <http://www.mreunion-labs.net/>
twitter : @mreunionlabs @abangkis
page : https://plus.google.com/104168782385184990771

Reply via email to