requirejs / almond

A minimal AMD API implementation for use after optimized builds
Other
2.42k stars 169 forks source link

Build problem #111

Open DSDev7 opened 8 years ago

DSDev7 commented 8 years ago

I'm trying to build requirejs project with grunt-contrib-requirejs and almond, but somehow r.js includes require.js in bundle and it tries to load all my dependencies from external files.

Gruntfile part:

51     requirejs:                                                                  
52       build:                                                                    
53         options:                                                                
54           almond: true                                                          
55           mainConfigFile: 'src/tmp/js/main.js'                                  
56           baseUrl: 'src/tmp/js'                                                 
57           out: 'build/js/app.min.js'                                            
58           name: '../../vendor/js/almond'                                        
59           include: '../../vendor/js/almond'                                     
60           optimize: "none"                                                      
61           deps: ['app']                                                         
62           wrap: true                                                            
63           paths: {...} # require.js not included here

main.coffee looks like this:

 1 requirejs.config                                                                
 2                                                                                 
 3   deps: ['app']                                                                 
 4   baseUrl: 'js/',                                                               
 5                                                                                 
 6   paths: {...} # require.js not included again                                                                       
33 define ['jquery'], (jQuery) ->                                                  
34   jQuery.noConflict true

Require.js is not included by myself anywhere. Am I missing something? Thanks for any help.

ffflabs commented 8 years ago

I believe 'app' would belong in the include array property. I've never used an explicit deps property in grunt-contrib-requirejs nor in the root section of requirejs.config. It should go inside a certain shim, in case you need one.

Also, your folder structure is not evident. Why is almond two folders above the gruntfile?

DSDev7 commented 8 years ago

Thank you, now it looks like it's not trying to load any modules from external files. But now I got an error about missing module, but I'm able to find that module by name. Modules are defined like this:

define([/*dependencies*/], function (/*args*/) {...

and r.js correctly transform this definitions to

define(moduleName, [/*dependencies*/], function (/*args*/) {...

I've deleted deps property from main.coffee and gruntfile and modified include property as you advised to

include: ['../../vendor/js/almond', 'app']

About paths, almond is 2 folders above defined root (src/tmp/js), not gruntfile. And it's because in src/tmp/js there are compiled coffee and cjsx files and in src/vendor/js are javascript libs.