Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build problem #111

Open
DSDev7 opened this issue Jan 4, 2016 · 2 comments
Open

Build problem #111

DSDev7 opened this issue Jan 4, 2016 · 2 comments

Comments

@DSDev7
Copy link

DSDev7 commented Jan 4, 2016

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
Copy link

ffflabs commented Jan 5, 2016

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
Copy link
Author

DSDev7 commented Jan 5, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants