Skip to content
This repository has been archived by the owner on Oct 11, 2021. It is now read-only.

Conflict with meteor's bundled jquery package #64

Open
gbisheimer opened this issue Feb 19, 2015 · 14 comments
Open

Conflict with meteor's bundled jquery package #64

gbisheimer opened this issue Feb 19, 2015 · 14 comments

Comments

@gbisheimer
Copy link
Contributor

@lorensr, I was having some trouble with jquery extensions after last PR that auto-includes files from referenced packages.

I was using select2, that depends on jquery, and both packages are loaded automatically. As jquery is already included in meteor, there was a conflict between the two.

In order to fix it, I disabled the jquery bower package using overrides:

{
  "name": "meteor-app",
  "version": "0.0.0",
  "authors": [
    "John Doe <[email protected]>"
  ],
  "license": "MIT",
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "test",
    "tests"
  ],
  "dependencies": {
    "select2": "~3.5.2"
  },
  "overrides": {
    "jquery": {
      "main": []
    }
  }
}

So, has to be careful checking packages and their dependencies to avoid this kind of conflicts.

@lorensr
Copy link
Collaborator

lorensr commented Feb 19, 2015

This seems like a big issue that's going to affect to a lot of people that
we should fix soon. We should probably modify handler.js to never install
jquery – what do you think? Does the conflict happen with underscore as
well? There aren't any more packages with bower equivalents that are
included in Meteor, right?

On Wed, Feb 18, 2015 at 6:48 PM, Guillermo Bisheimer <
[email protected]> wrote:

@lorensr https://github.com/lorensr, I was having some trouble with
jquery extensions after last PR that auto-includes files from referenced
packages.

I was using select2, that depends on jquery, and both packages are loaded
automatically. As jquery is already included in meteor, there was a
conflict between the two.

In order to fix it, I disabled the jquery bower package using overrides:

{
"name": "meteor-app",
"version": "0.0.0",
"authors": [
"John Doe [email protected]"
],
"license": "MIT",
"ignore": [
"*/.",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"select2": "~3.5.2"
},
"overrides": {
"jquery": {
"main": []
}
}
}

So, has to be careful checking packages and their dependencies to avoid
this kind of conflicts.


Reply to this email directly or view it on GitHub
#64.

@gbisheimer
Copy link
Contributor Author

@lorensr, forgot to mention that jquery was still functional, but select2 was not available for JQuery objects selected using $ function inside a template.

I'm still testing what's wrong.

@adrianmcli
Copy link

@gbisheimer, does your method of overriding prevent bower from downloading them as well? I'm using a Bower package that has two dependencies: jquery and moment. I see that both folders are being re-created inside local/bower/.

@gbisheimer
Copy link
Contributor Author

@adrianmc, this override just prevents meteor-bower from loading your file into the application, but the package is downloaded anyway. As with polymer components, you may need to download them but you are responsible for including those files wherever you need them in your app.

@gbisheimer
Copy link
Contributor Author

Given an application that uses multiple packages 3rd party packages, how can you possibly know (without inspecting the source of each package) if multiple bower libraries are being included, each in different versions?
I saw @Urigo comment here but that doesn't solve the problem of multiple 3rd party packages using the same dependency in different versions. It only allows you to select the right meteor package version, given that you know beforehand which files are being included in each package.

I see no difference using @Urigo approach and using overrides and resolutions entries in bower.json.

@Urigo
Copy link
Contributor

Urigo commented Mar 2, 2015

@gbisheimer I completely agree.
This is why we say that there is a possible solution to that with overrides and resolutions but we don't recommend the meteor-bower package anymore.
We recommend creating a Meteor package using @dandv approach.

@filipstachura
Copy link

Same has happened to me. Thanks for the fix.

@wbashir
Copy link

wbashir commented Mar 31, 2015

+1 Ran into this exact issue. @gbisheimer Thanks for the suggested fix

@gbisheimer
Copy link
Contributor Author

👍 You are welcome

@paulo2nd
Copy link

Trying to use font-awesome and bootstrap in my app, I'm trying to install then in my lib folder... so in my folder i have:

bower.json

{
  "name": "myApp",
  "version": "0.0.0",
  "authors": [
    "John Doe <[email protected]>"
  ],
 "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "test",
    "tests"
  ],
  "dependencies": {
    "bootstrap-sass-official": "~3.3.4",
    "font-awesome": "~4.3.0"
  },
  "overrides": {
    "jquery": {
      "main": []
    }
  },
  "private": true
}

.bowerrc

{
  "directory": "bower"
}

But meteor-bower keep installing jquery and trying to compile him in my application. Should i but the libs in my public folder? Why he keeps to install full jquery in my folder (including /src)?

@sferoze
Copy link

sferoze commented Oct 18, 2015

@Urigo Are you not recommending using bower at all with meteor? Or just with angular-meteor?

Also I have libraries with jQuery dependency too. This is what I have done to prevent jquery from loading into the app. I can still see that it is downloaded but it does not seem to be interfering with the app in any way I can notice yet.

"ignoredDependencies": [
    "bootstrap-sass-official",
    "font-awesome-sass",
    "jquery",
    "bootstrap"
  ],
  "overrides": {
    "jquery": {
      "main": []
    },
    "bootstrap": {
      "main": []
    }
  },

That is what I have done to prevent interfering dependencies

@trajano
Copy link

trajano commented Mar 3, 2016

bower/bower#1394 seems to provide the facility, but it isn't working from what i can tell. Could it be we have an older version of bower in the package?

@lorensr
Copy link
Collaborator

lorensr commented Mar 5, 2016

Yes. I don't think we're updating this package, but here's the line to change on a fork if you need it:

https://github.com/mquandalle/meteor-bower/blob/master/package.js#L22

@trajano
Copy link

trajano commented Mar 7, 2016

Actually it is working, though it is downloading it regardless on the logs.

The following block just needs to be in the bower.json file. To verify that it is not loaded you should be able to view source on the main page and confirm that bower/jquery.js is not loaded.

"ignoredDependencies": [
"jquery"
]

With the above this should resolve the issue.

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

No branches or pull requests

10 participants