Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine ASP.NET MVC4 bundling and require.js javascript module dependency

Is there a way to use the bundle functionality of ASP.NET MVC4 and the JavaScript module dependency feature of require.js

I want to load all my modules with ASP.NET MVC4 bundle features and use require.js to organize the relationships between them.

The problem is that require.js doesn't find the needed dependencies while all the modules are loaded via bundles.

I don't want require.js to go and try to load files asynchronous I just want it to use already loaded modules via bundles.

What should the main file look like in this case.

I Have the following structure in _Layout.chtml

@Scripts.Render("~/bundles/jquery",
                "~/bundles/jqueryval",
                "~/bundles/jslibs",
                "~/Scripts/require.js",
                "~/bundles/tjProductivity",
                "~/Scripts/tjpApp/main.js"
                )

@RenderSection("scripts", required: false)

And then in each scripts section I want to load all modules that will be used for that page via Bundle.config but let require.js manage dependencies between them.

like image 913
Alev Ryustemov Avatar asked Mar 18 '13 19:03

Alev Ryustemov


1 Answers

It's possible, use almond.js, from the creator of RequireJS.

The only shortcoming is that you have to always add the module names on your modules...

like image 191
Minelli Avatar answered Nov 05 '22 15:11

Minelli