colcade
colcade copied to clipboard
Getting jQuery not defined when importing colcade
Hi,
I keep getting:
Uncaught ReferenceError: jQuery is not defined
at Object.<anonymous> (external "jQuery":1)
at __webpack_require__ (bootstrap 946d2903250f93af9fc4:678)
at fn (bootstrap 946d2903250f93af9fc4:88)
at Object.<anonymous> (colcade.js:366)
at __webpack_require__ (bootstrap 946d2903250f93af9fc4:678)
at fn (bootstrap 946d2903250f93af9fc4:88)
at Object.<anonymous> (masonry.js:1)
at __webpack_require__ (bootstrap 946d2903250f93af9fc4:678)
at fn (bootstrap 946d2903250f93af9fc4:88)
at Object.<anonymous> (main.js:1)
When trying to import colcade: import Colcade from 'colcade'
It seems to me that the check for if jQuery is present is either not working correctly or is called at the wrong time, this part of the code here:
Colcade.makeJQueryPlugin = function( $ ) {
$ = $ || window.jQuery;
if ( !$ ) {
return;
}
...
When I delete that whole function everything works as it's supposed to. I'm of course not using jQuery in my project, just to be clear.
Anyway, liking the plugin so far :) .
Thanks for reporting this issue. Is your code being run on server side? The code in question should fail safely if window.jQuery
is not present. But if window
is not present, then there might be an issue.
The code runs in the browser, through webpack. I thought it may be the timing, but even if I build my project, I still get the same error. And actually code doesn't even get to the initiation faze. But fails at the import.
Okay. I'll have to reproduce this on my side.
Colcade is like a fun side-project so this is low priority for me.
No worries, I've taken out the colcade.js from node_modules, deleted the code in question, and put it in my vendor folder, and now I'm calling it from there, and everything works. So there is a workaround if someone is experiencing the same problem.