Google Groups

Re: [requirejs] How to use shim without loading the non-AMD module

James Burke Jul 2, 2012 4:55 PM
Posted in group: requirejs
If you know the file has already loaded, then in main.js I would
create an inline define for each already-loaded script. Since the
script is already loaded, I would assume its dependences are also
already loaded, so it is more about just setting the exports. Example
if angular.js exports an 'angular' global.

//in main.js
define('angular', function () {
    return angular;

//Then do normal requirejs stuff here:
require([…], function () { … });


On Sat, Jun 30, 2012 at 9:12 PM, Cary <> wrote:
> I'm using the shim config with success as long as RequireJS is responsible
> for loading the non-AMD module I am shimming.
> I have a need to load the non-AMD file outside of RequireJS but still need
> RequireJS to shim it, providing exports and deps.
> Example:
> <!-- angular.js is not a module -->
> <script src="angular.js"></script>
> <!-- main.js references modules dependent on angular.js -->
> <script src="require.js" main="main"></script>
> Any help is much appreciated.
> Thanks,
> Cary