goldfire / howler.js

Javascript audio library for the modern web.
https://howlerjs.com
MIT License
23.74k stars 2.22k forks source link

Uncaught Error: Mismatched anonymous define() #564

Closed lucap86 closed 4 years ago

lucap86 commented 8 years ago

I currently use requirejs but not for load howler because my libraries are dynamically minimized server side.

if (typeof define === 'function' && define.amd) {
    define(function() {
      return {
        Howler: Howler,
        Howl: Howl
      };
    });
  }

will cause

Uncaught Error: Mismatched anonymous define() module: function () {
      return {
        Howler: Howler,
        Howl: Howl
      };
    }

according to requirejs docs http://requirejs.org/docs/errors.html#mismatch i suggest to edit code to:

if (typeof define === 'function' && define.amd) {
    define("howlerjs", function() {
      return {
        Howler: Howler,
        Howl: Howl
      };
    });
  }

Note: no errors if i load library with requirejs

goldfire commented 8 years ago

Can you give sample code that you are using to load it? I'm not seeing this error, and we used to have it in the format you suggest, but changed it because it was more standard to not have it named (https://github.com/goldfire/howler.js/pull/69, https://github.com/goldfire/howler.js/issues/65, https://github.com/goldfire/howler.js/pull/392).

lucap86 commented 8 years ago

Here it is an exemple.

The solution may be to import howler before requirejs but i think that if someone want to use it with require he should define it into "paths" node of require config object param

require.config({
   paths:[
      howler: "/bowler_components/howler.js/howler"
   ]
});

and than use it as AMD module

howlertest.zip

finkinfridom commented 5 years ago

We are encountering the same issue when integrating with a 3rd party website. should we update our code to reflect the above comment or there will be (near) future fix for this issue? thanks

FlorianChataignier commented 5 years ago

Hi, you could try with this : https://muut.com/i/gootech/tutorials:any-examples-of-using-howle This worked for me. Hope this helps.

goldfire commented 4 years ago

Closing due to inactivity. If this is still an issue, reply with more info and I'll reopen.