Skip to content

Commit

Permalink
docs: improve command by code-group (#5587)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Taegert-Atkinson <[email protected]>
  • Loading branch information
thinkasany and lukastaegert authored Jul 26, 2024
1 parent 27260de commit c16c924
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions docs/introduction/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,25 @@ Rollup can be used either through a [command line interface](../command-line-int
These commands assume the entry point to your application is named `main.js`, and that you'd like all imports compiled into a single file named `bundle.js`.

For browsers:
::: code-group

```shell
```shell [For browsers:]
# compile to a <script> containing a self-executing function ('iife')
rollup main.js --file bundle.js --format iife
$ rollup main.js --file bundle.js --format iife
```

For Node.js:

```shell
```shell [For Node.js:]
# compile to a CommonJS module ('cjs')
rollup main.js --file bundle.js --format cjs
$ rollup main.js --file bundle.js --format cjs
```

For both browsers and Node.js:

```shell
```shell [For both browsers and Node.js:]
# UMD format requires a bundle name
rollup main.js --file bundle.js --format umd --name "myBundle"
$ rollup main.js --file bundle.js --format umd --name "myBundle"
```

:::

## The Why

Developing software is usually easier if you break your project into smaller separate pieces, since that often removes unexpected interactions and dramatically reduces the complexity of the problems you'll need to solve, and simply writing smaller projects in the first place [isn't necessarily the answer](https://medium.com/@Rich_Harris/small-modules-it-s-not-quite-that-simple-3ca532d65de4). Unfortunately, JavaScript has not historically included this capability as a core feature in the language.
Expand Down

0 comments on commit c16c924

Please sign in to comment.