onokumus / metismenu

A collapsible jQuery menu plugin

Home Page:https://onokumus.github.io/metismenu/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UMD wrapper is broken? Doesn't work for CommonJS/Node.js.

BurkovBA opened this issue · comments

Hi, @onokumus (thanks for publishing newer version of package by the way)!

I continued to work with metismenu in node.js environment and it still breaks with:

/home/burkov/Documents/Projects/BurkovBA.github.io/node_modules/metismenu/dist/metisMenu.js:112
  }(jQuery);
    ^

ReferenceError: jQuery is not defined

I looked into the UMD wrapper and I think, it might be wrong.

What it does? It retrieves jquery (from either AMD/require module or CommonJS module or global.jquery) and passes it to your code as _jquery2 variable.

But, _jquery2 variable isn't used anywhere!

Instead, metismenu is just initializing both Util and MetisMenu with global jQuery variable.

Naturally, this code breaks in node.js environment, cause there is no such global.

When I replace jQuery with _jquery2 in both constructors, it works fine.

Does this make sense to you? Can you suggest how to fix this? I will gladly assist you and submit a Pull Request with fix.

Thank you!