javascriptbackbone.jsrequirejsamdsoundmanager2

Loading soundmanager2 with requirejs amd shim, logs undefined


So here's my main.js file (stripped out all my other scripts for clarity):

require.config({
    paths: {
        'soundmanager2': '../libs/soundmanager2/soundmanager2',
    },
    shim: {
        'soundmanager2': {
            'exports': 'soundManager'
        }
    }
});

Then i'm loading the library like so:

define(['jquery', 'underscore', 'backbone', 'utilities/events', 'utilities/helpers', 'soundmanager2'],

    function($, _, Backbone, events, h, soundManager){

        var TrackModel = Backbone.Model.extend({

            initialize: function() {

                console.log(soundManager);
            }
        });

        return TrackModel;
    }
);

The script is being downloaded - but when I log soundManager, I get undefined, no other errors.

Any ideas? Fear i'm missing something obvious..


Solution

  • This was an issue with the version of soundmanager2 - it has AMD baked in but I can't get it to export for some reason. I reverted to an earlier version, used the shim, and that fixed it!