-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Bootstrap dropdown require Popper.js (https://popper.js.org) #23381
Comments
other people are also having problems with this as well, there are 19 posts on Stack Overflow |
Have a look at this https://getbootstrap.com/docs/4.0/getting-started/webpack/ |
Popper.js is proving to be a massive headache for me and I don't even know why. When ever I pull the minified file into my build, it throws a console error - something about not having the .js.map? Seems to work fine though. But then when I concatenate and uglify my assets - Bootstrap's Javascript just stops working. I know it's something to do with Popper, no idea how to solve it, such a fiddly thing. Arg. |
/CC @Johann-S |
I'm not an expert on how to use Maybe this page of our documentation can help you : https://getbootstrap.com/docs/4.0/getting-started/webpack/ |
For anyone trying (and failing/ struggling) to use Popper js with Ember Js. I got it to work by grab popper from npm, and import the umd version of the dist from node_modules (either using ember-browserify or the latest beta of ember-cli 2.15) |
any ideas @jrburke? |
@fran-worley Thanks, that seems to work if you're not using webpack for your project. |
For laravel projects using laravel mix, |
i notice that if you npm popper.js the dist/popper.min.js code in that is different from the popper.min.js used in the the bootstrap examples? http://getbootstrap.com/docs/4.0/examples/jumbotron/ do we have to do something to popper.js to export it or something for bootstrap? do we have to use webpack2 or something on popper.js? Sorry. i've just tested fran-worley solutions and using the one in the dist/umd/popper.min.js folder has worked |
then somewhere in your application (when using SSR, put it in the main.browser.ts): require('jquery/dist/jquery');
require('popper.js/dist/umd/popper');
require('bootstrap/dist/js/bootstrap'); and at last in your webpack config: ...
plugins: [
...
new webpack.ProvidePlugin({
'$': "jquery",
'jQuery': "jquery",
'Popper': 'popper.js'
}),
... |
Many Thanks.
I really need to have a go of webpack .
I only ever used concat and uglify for js in my gruntfile.js before for combining js files.
From: Stefan Rein [mailto:notifications@github.com]
Sent: 14 August 2017 13:41
To: twbs/bootstrap <bootstrap@noreply.github.com>
Cc: Stephen Deere <SD@ccsw.co.uk>; Comment <comment@noreply.github.com>
Subject: Re: [twbs/bootstrap] Bootstrap dropdown require Popper.js (https://popper.js.org) (#23381)
npm install popper.js --save
then somewhere in your application (when using SSR, put it in the main.browser.ts):
require('jquery/dist/jquery');
require('popper.js/dist/umd/popper');
require('bootstrap/dist/js/bootstrap');
and at least in your webpack config:
...
plugins: [
...
new webpack.ProvidePlugin({
'$': "jquery",
'jQuery': "jquery",
'Tether': 'tether',
'Popper': 'popper.js'
}),
...
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#23381 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ACrzmftHsDx6YxQtnB5h31zqk6Yl61kEks5sYEB1gaJpZM4O1kVT>.
|
Same error with Visual Studio 2017 15.3.0 Preview 7.1 and WebCompiler/Bundler&Minifier (both from Mads Kristensen) |
I thought I'd elaborate on my earlier issue. Hopefully someone can point me in the right direction. My current setup is a custom Grunt script with Bower. I pull JQuery, Popper and Bootstrap in and everything works fine when serving. My problem comes when I concatenate and uglify the scripts - all Bootstrap Javascript just stops working without throwing any errors. Could grunt-uglify be doing something I'm not aware of? Is the Popper code ES6 perhaps, and Uglify can't process that properly? EDIT: Nevermind, I found the solution to my problem. It seemed pulling in the minified Bootstrap file and then minifying it again was causing the issue (not quite sure why). I just removed "min" and it worked for me.
|
I tried the solution suggested by @DDDN and @fran-worley, by using the version inside the "umd", but the issue still persists. Any other suggestions? Still getting the "Error: Bootstrap dropdown require Popper.js" - and everything is loading in the correct order. I event tried loading directing from CDNs, but the same result. Just for the sake of getting my project ready for testing, I'll just load the "dropdown" through CSS hover instead. |
@edwardm you have to import popper before bootstrap on angular would be like this
|
@Nexeuz We're not using Angular. Co-worker found out we had to roll back to 1.11.0 "umd" for Popper.js and it now works. Before it was 1.12.1, automatically installed through Bower |
It would be helpfull if the popper.js is delivered with the Project. I just downloaded it from the CDN, but would help many other ppl if you provide it through your Download |
They are a link on each plugins which use Popper.js to download it |
Is there a solution for those of us using the CDN links? Thanks in advance. |
Can you try with the last release of Popper.js ? https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.2/umd/popper.min.js |
Thanks @Johann-S, that was it... I appreciate the help! 😸 |
That's nothing 😉 do not hesitate to follow the development of Popper.js if you have issues with it |
@Johann-S (and @zspitzer): I think lot of people will have similar problems until Bootstrap changes its code to define Popper as an explicit dependency instead of relying on its availability in the global scope. I fixed the OP script, but as you can see, you have to first import the Bootstrap dependencies, then define them as global, and then import Bootstrap: |
It will be done here : #22888 |
@FezVrasta @Johann-S Why can't this popper.js include in the bootstrap.js file? Why this need to be separate? Since its used by dropdowns, most projects will need that. Also in other cases, we can recompile with the needed plugins same as carousel or modal are separate js file in source. Why don't we make like this? ~Surjith |
It will be done in the PR linked below |
Now Bootstrap recommand to use Popper.js 1.12.3 see : #23626 |
I fixed it by replacing the popper.min.js I was referencing for the one that they use at the Bootstrap website: |
Read the documentation. https://getbootstrap.com/docs/4.0/getting-started/introduction/#quick-start `<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>` |
Its a simple solution to add popper.js before the bootstrap.min.js file and after that it will working fine. Use this like: <script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script> <script src="https://getbootstrap.com/assets/js/vendor/popper.min.js" type="text/javascript"></script> <script src="js/bootstrap.min.js" type="text/javascript"></script> |
Here's how I solved the issue: http://blog.chasepeeler.com/2017/09/12/bootstrap-4-and-requirejs/ |
for laravel, you can use @36864 solution:
with a little bit of optimization based on PopperJs documentation, you can do:
|
Going back to the OPs issue of loading Bootstrap and popper.js via requireJs, until #22888 is released, this is how I've fixed the Similar to what's mentioned in other blog posts the idea is to create your own module that wraps Bootstrap. This module then loads and sets requirejs.config({
"paths" : {
"jquery" : "https://code.jquery.com/jquery-3.2.1.slim.min",
"popper" : "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min",
"bootstrap" : "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min"
"initBootstrap" : "...wotever..."
},
"shim" : {
"bootstrap" : ["jquery"]
}
});
...
define("initBootstrap", ["popper"], function(popper) {
// set popper as required by Bootstrap
window.Popper = popper;
require(["bootstrap"], function(bootstrap) {
// do nothing - just let Bootstrap initialise itself
});
}); Now let your code / website have a dependency on |
For everyone in our next release we added two new dist files :
Which contains Popper.js inside, so you won't have to include Popper.js by yourself |
@Johann-S what's the progress with the proper CommonJS support of the classic build? Has Rollup landed already? |
Currently I chose to split my PR to handle modularisation if it's what you mean because that's difficult to check if it works in all the environments, but yes now Bootstrap.js use Rollup |
Thanks for the shoutout @SlimerDude, but, you don't even have to make it that complex. No need to define your own module just for initializing popper. Just use a require, like I show in my blog post require(["popper"],function(p){
window.Popper = p;
require([bootstrap]);
}); The example in my post was based on an implementation where I am defining a module elsewhere, which I load via require, and then attach to global scope for easy console access. However, I still don't create a new module for loading popper and attaching it to the global scope require(["popper"],function(p){
window.Popper = p;
require(["app/main"],function(app){
window.mainApp = app;
});
}); |
404 popper.min.js.map |
If you want support for source maps. Yes. Otherwise. No |
comment this line add this line in your Popper.js [last line] |
This worked for me.
|
None of above worked for me, I got error This fixed the issue:
|
I use popper.js in umd folder. It's solve. (dist/umd/popper.min.js) |
Here is quick start example project with Webpack 3 + Bootstrap 4: https://github.com/xdvarpunen/webpackboot |
I change bootstrap@4.0.0.beta-2 back to bootstrap@4.0.0.alpha-6. |
Since Bootstrap 4 beta 2 you can use |
The Bootstrap website itself mentions the following- "If you’re using our compiled JavaScript, don’t forget to include CDN versions of jQuery and Popper.js before it.". And it is followed by the relevant links to the jQuery and Popper.js. Here is the link https://getbootstrap.com/docs/4.0/getting-started/download/#bootstrap-cdn |
Yep do not hesitate @vannitotaro to make a PR 😉 |
I'm having trouble getting started with bootstrap v4 via requirejs due to Popper
Bootstrap dropdown require Popper.js (https://popper.js.org)
https://jsbin.com/xululo/edit?js,console,output
this maybe related? floating-ui/floating-ui#287
The text was updated successfully, but these errors were encountered: