-
-
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
Update docs example on how to optimize JavaScript bundle #31111
Conversation
Yeah, I think this should be cleaned up. See #31111 |
Alright, I just created this repo containing minimal working examples with Parcel, Rollup and webpack. In all three examples, the bundle contains only the collapse and dropdown plugins (plus Popper.js, required for dropdowns). There's also a template with a navbar that uses both plugins. Regardless of the bundler, imports are written like this: import 'bootstrap/js/dist/collapse';
import 'bootstrap/js/dist/dropdown'; And actually there is no need to explicitly import Popper.js in the entry file because all bundlers will automatically include it if needed. It simply needs to be installed with npm in the same way as Bootstrap. If this sounds ok for you, I can rebase and update this PR with cleaned imports and the correct comment about Popper. |
@pascalpepe Holler if you need any more feedback here before opening up for reviews :). |
LGTM @pascalpepe 👍 |
Thanks for reviews ! Here's the updated PR:
Ready for review :) |
Btw I think we should mention we use export default for those files, which mean if you want to create a new modal you have to do: import Modal from 'bootstrap/js/dist/modal'
const modal = new Modal(document.getElementById('myModal')) |
Any interest in the last comment @pascalpepe? |
@Johann-S can you add the changes you mentioned above? |
@XhmikosR I'm unable to add a JS example in a |
For some reason, the Netlify preview is broken; it throws a
I'll put this on hold, until I figure out why this happens. |
For some weird reason, using "Exports" as the callout header leads to TypeError coming from clipboard.js
So, it seems the error comes from ClipboardJS due to the "Exports" heading. Should probably be reported upstream, but in the meantime I renamed the heading to "Default Exports". If someone could report it, that would help. |
The lean JavaScript example in v5 docs has not been updated from v4.
This PR suggests the two following changes in the Lean JavaScript code snippet:
js/dist/util.js
, which does not exist anymore.https://deploy-preview-31111--twbs-bootstrap.netlify.app/docs/5.0/customize/optimize/