-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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 JavaScript modules API design questions/issues #19017
Comments
Re: "Pretranspiled or raw sources", see #20072. |
A gigantic +1 to this; in v3, getting bootstrap to work without Also wanted to add: |
Thank you Pete, I imagine this will be done for the beta, these days modularization is kind of a hard requirement. |
What are we tackling here for v4, if anything? |
Sorry for getting back so late @mdo, this one kinda fell through the cracks In https://github.com/petetnt/bootstrap/commits/v4-js-modules I had a structure going on that mostly had the thing going on that I had in mind when writing this issue a looooooong time ago. There were couple of things that needed to be fixed, such as Carousels raising errors due to some shared state (IIRC) issues, and while the tests all pass, it would have required some refactoring that would have introduced some breaking changes. At the same time The beef of Either way, I do still ❤️ Bootstrap and would love to revisit the JavaScript side someday. |
All good @petetnt. Should we close this for now then? |
Are we really not going to see a modular Bootstrap before v5 or later? 😞 |
I created a PR to allow a better modularization of our plugins see : #22888 |
Any news on this for Beta 3? |
Now in Beta 3, our files (bootstrap.js , bootstrap.min.js, bootstrap.bundle.js and bootstrap.bundle.min.js) are UMD ready |
Is |
See #23586 |
@twbs/js-review can we close this? |
Yep a lot have been done on that part 👍 |
As a part of #17325, I have been doing the initial legwork of having better modularization for the Bootstrap modules. Currently it is rather painful to get the dependencies working properly when trying to minimize global variables and it's pretty much impossible to hand pick the features you want (without hacking on the source).
Solving #17325 is relatively easy to handle: adding
import jQuery from "jquery"
,import Tether from "tether"
and adding both of those topackage.json
. The tricky part comes when the user needs (or wants) a bit more control over the Bootstrap modules. Bootstrap has always* been automagical: you add thebootstrap.js
file and suddenly you have all the features the framework uses at hand through the HTML markup binding. Or you could just use the provided JS API's.As modular JavaScript has gotten more and more popular in the past few years, the developers have gotten accustomed to fine-grained control over the source files, into a situation where not everything has to be dumped to the page and then it just works. Like in #17325 (comment), the obvious choice would be allowing to import the files one by one and use them as you want to:
In my bs-modules branch this sort of works right now:
Modal
will be modal and Popover will be popover. The real issues begin here:IIFE's and re-exporting
All the components are wrapped in to IIFE's
When we re-export the files in index.js the exported files are executed from top to bottom and all of the IIFE's get triggered. Consider something like this:
Not entirely sure what would be the best way to avoid this. Most likely creating some kind of
init
-methods that are IIFE'd in the compiled version (bootstrap.js
) that could be called manually when importing, ormaking the end users initialize their own components (through something like
Tooltip($(".foo"), {config: options, here: yup})
.Pretranspiled or raw sources
Currently the distributed modules are transpiled with Babel and wrapped into UMD-wrappers.
npm.js
file is created by Grunt which requires all the modules. Now the userland can use the modules without transpilation, but if you are creating something this ES2015 this seems a bit redundant as you most likely have your own transpilation process going on. #18934 asks for where the source files are and I agree: the raw sources should be included. Which leads to the question, should the UMD-modules be included too? Some of the options:dist
modules ===src
modulesbootstrap/umd
and the ES2015 filesbootstrap
Opinions?
Any opinions about either of these or the modularization in ? We are getting quite to the release (or end of the alpha, I assume) and these are quite big choices. Like in #17325 (comment) there was some discussion about people not complaining about the dependencies not being there and @vejersele replying how most people were not using Bootstrap via
npm
because it was hard and that's most likely true. It would be a shame if that happened tov4
too: I really want to use Bootstrap in most of my projects, but at its current state it's near impossible to get it to integrate with my apps in a way that I would consider somewhat standard.The text was updated successfully, but these errors were encountered: