Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting jQuery not defined when importing colcade #16

Open
ivandoric opened this issue Feb 19, 2019 · 4 comments
Open

Getting jQuery not defined when importing colcade #16

ivandoric opened this issue Feb 19, 2019 · 4 comments
Labels

Comments

@ivandoric
Copy link

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 :) .

@desandro
Copy link
Owner

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.

@ivandoric
Copy link
Author

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.

@desandro desandro added the bug label Feb 21, 2019
@desandro
Copy link
Owner

Okay. I'll have to reproduce this on my side.

Colcade is like a fun side-project so this is low priority for me.

@ivandoric
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants