Library is broken in environment using CommonJS modules
See original GitHub issueLibrary is broken in CommonJS environment. Module is wrapped into anonymous function to provide something close to UMD module format:
(function(ns) {'use strict';
// code
}(typeof module !== "undefined" ? module.exports : window));
It works perfectly in non-CommonJS environment, since it sets ns
to Window
. In CommonJS environment ns
will be module exports object. But code of the library extensively uses ns
variable to access Window
’s properties: 1, 2, 3, etc. Obviously in CommonJS environment these properties are undefined, so it fails/behaves very weird (in my case animation went insane, because ns.performance
was undefined and it used Date.now()
to get animation start time (and they are completely different things).
The simple solution would be just removing ns.
prefix from all the global variables. If you think we should go with this solution, I can prepare PR.
Check out updated example to get simple reproduction of the issue in CommonJS environment.
As a side note. I find the Regex based build process a bit speculative. Any reason why you use that instead something like this babel plugin for example? Maybe we can improve build process as well?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Fixed in commit https://github.com/Mikhus/canvas-gauges/commit/ab1095188c6991a19e2d49cfab0c29b9824afcd1
Will be released in v2.1.0
sry… how about being able to specify your own time provider when creating the gauge? would that help?