Browser loading bug
rafaelmacario opened this issue · comments
When using highcharts in browser, the variable module param is becoming undefined and throwing an application error
Link to jsfiddle showing the issue.
https://jsfiddle.net/rafaelmacario/chhcpdu6/3/
Expected Behaviour
When loading the highchart module in browser it must detect the module existence in order to let script continue to load
Current Behaviour
highcharts-ng-js : Line 20
if (window && window.Highcharts) {
Highcharts = window.Highcharts;
// The module variable does not exists and the following error is thrown
} else if (module && module.exports === 'highcharts-ng') {
Highcharts = require('highcharts');
}
Error: ReferenceError: module is not defined
Your Environment
- Version of highcharts-ng used: 1.1.0
- Browser Name and version: Mozilla Firefox For Ubuntu canonical -1.0 52.0.2 (64-bit)
- Operating System and version (desktop or mobile): Ubuntu 14.04 LTS
- Link to your project:
Hi @rafaelmacario and @pablojim
I was about to make a PR when I found this issue - introducing what I think i a bug in it self?
All that was needed to fix the bug metioned in issue #592 was the additional check:
typeof module !== 'undefined'
The check that was introduced:
(typeof module !== 'undefined' && typeof exports !== 'undefined' && module.exports === exports && module.exports === 'highcharts-ng' )
will never be true when combined with the top most check/assignment:
if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.exports === exports){
module.exports = 'highcharts-ng';
}
If exports
and module.exports
are equal but not 'highcharts-ng' then when assigning 'highcharts-ng' to module.exports
results in the two no longer being equal!! :-)
Hence the later check for
module.exports === exports && module.exports === 'highcharts-ng'
will always fail??
The real check should be:
(typeof module !== 'undefined' && typeof exports !== 'undefined' && module.exports === 'highcharts-ng' )
That is, leaving out the module.exports === exports
check
How can this work for anyone? I am a little puzzled!
Please let me know if I am missing something here?
Kind Regards
Lasse
Hello, we would like to use your great library for a project in angularJS. I have the version 1.2.0 retrieved from npm repository. But I am block because of this defect.
Would it be possible to tag a new "minor" release for fixing this blocking defect and thus have it available thorugh npm.
Many thanks for this great work!
Regards,
Philippe Rols.
@prols you can target a specific commit via npm if that helps
Yes thanks I will do that for now.
you will indeed need to build it locally, looking at the PR, npm run build
should do the trick
@prols Released now.