-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
jQuery not being loaded correctly #2724
Comments
I ran into the same issue. There is code in the jquery file that does not init the global variables if it is loaded in scenarios like parcel. This is the code from jquery:
With parcel, it runs through the then block where it should run through the else in your scenario. There is a workaround. You can change the line |
@mschaaf that worked! Thanks! I was just pasting in the JS into a |
Is there a more trivial fix to this? Been toying with Parcel for the past few hours, and this seems to be a stopper. Currently trying to make https://github.com/fancyapps/fancybox work. |
@MindTooth I'm still looking for a solution on importing other types of dependencies globally (besides jQuery). No luck here. :p |
any solutions here? im running the same issue ;( |
$ yarn add bootstrap@3 jquery babel-polyfill // index.js
import 'babel-polyfill'
import("jquery").then(async (jquery) => {
$ = window.$ = window.jQuery = jquery
await import('bootstrap')
$(document).ready(function() {
console.log('hello')
})
})
//or
const jquery = require('jquery')
//
$ = window.$ = window.jQuery = jquery;
require('bootstrap')
$(document).ready(() => {
console.log("hello");
});
|
@reducm That worked for me. Thanks! Is there a way to make === Update: I got it working by using https://www.npmjs.com/package/parcel-plugin-externals (from #144 (comment)) |
I can confirm that this still exists in |
Based on the solution presented by @reducm but I didn't want jQuery as a global and I had no need for it to be accesible at import('jquery').then(async ($) => {
// your code that uses jQuery
}); |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. |
This issue is still happening on 2.6.2 |
馃悰 bug report
I've spent almost a week trying to figure out why I'm having such problems with jquery being required. My only guess is that it has something to do with how Parcel is handling asset files. As you'll see below, I've tried including jQuery in my index.html file multiple ways, CDN and locally, and my
jQuery(document).ready(function($) {console.log("jQuery loaded");...
seems to load correctly, but the other files that require jQuery are not able to access it.馃帥 Configuration (.babelrc, package.json, cli command)
馃 Expected Behavior
jQuery should be loaded.
馃槸 Current Behavior
馃拋 Possible Solution
馃敠 Context
Other local files, seem to have loaded and been imported just fine, at this point I've stripped the entire app down the minimum; so the only files required are the ones needed to produce the error.
馃捇 Code Sample
index.html:
馃實 Your Environment
ExpressJS sever:
The text was updated successfully, but these errors were encountered: