Skip to content

Commit 2c10e4a

Browse files
committed
Make it shake(able)
1 parent e9f8b8a commit 2c10e4a

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
}
3636
],
3737
"type": "module",
38+
"sideEffects": false,
3839
"exports": {
39-
".": "./dist/js/bootstrap.js",
40+
".": "./js/index.js",
4041
"./js/src/*": "./js/src/*",
4142
"./js/dist/*": "./js/dist/*",
4243
"./dist/js/*": "./dist/js/*",

site/src/content/docs/getting-started/download.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ Install Bootstrap in your Node.js powered apps with [the npm package](https://ww
7878
npm install bootstrap@[[config:current_version]]
7979
```
8080

81-
`const bootstrap = require('bootstrap')` or `import bootstrap from 'bootstrap'` will load all of Bootstrap’s plugins onto a `bootstrap` object.
82-
The `bootstrap` module itself exports all of our plugins. You can manually load Bootstrap’s plugins individually by loading the `/js/dist/*.js` files under the package’s top-level directory.
81+
`import * as bootstrap from 'bootstrap'` will load all of Bootstrap’s plugins onto a `bootstrap` object. You can also import plugins individually for automatic tree shaking, e.g., `import { Tooltip } from 'bootstrap'`. You can also load Bootstrap’s plugins individually by loading the `/js/dist/*.js` files under the package’s top-level directory.
8382

8483
Bootstrap’s `package.json` contains some additional metadata under the following keys:
8584

site/src/content/docs/getting-started/install.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ The [Bootstrap npm package](https://www.npmjs.com/package/bootstrap) is publishe
2929

3030
### Using npm
3131

32-
Using `const bootstrap = require('bootstrap')` or `import bootstrap from 'bootstrap'` will load all of Bootstrap’s plugins onto a `bootstrap` object. The `bootstrap` module itself exports all of our plugins. You can manually load Bootstrap’s plugins individually by loading the `/js/dist/*.js` files under the package’s top-level directory.
32+
Using `import * as bootstrap from 'bootstrap'` will load all of Bootstrap’s plugins onto a `bootstrap` object. You can also import plugins individually for automatic tree shaking:
33+
34+
```js
35+
import { Tooltip, Toast, Popover } from 'bootstrap'
36+
```
37+
38+
You can also import plugins directly by loading the `/js/dist/*.js` files under the package’s top-level directory.
3339

3440
Bootstrap’s `package.json` contains some additional metadata under the following keys:
3541

site/src/content/docs/getting-started/javascript.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ Curious which components explicitly require our JavaScript and Floating UI?
2626

2727
Plugins can be included individually (using Bootstrap's individual `js/dist/*.js`), or all at once using `bootstrap.js` or the minified `bootstrap.min.js` (don't include both).
2828

29-
If you use a bundler (Webpack, Parcel, Vite…), you can use `/js/dist/*.js` files which are ES modules.
29+
If you use a bundler (Webpack, Parcel, Vite…), you can import only the plugins you need and your bundler will automatically tree-shake the rest:
30+
31+
```js
32+
import { Toast, Tooltip } from 'bootstrap'
33+
```
3034

3135
## Usage with JavaScript frameworks
3236

0 commit comments

Comments
 (0)