Skip to content

Commit 7633eda

Browse files
committed
readme
1 parent 4470ec6 commit 7633eda

1 file changed

Lines changed: 38 additions & 4 deletions

File tree

README.md

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,56 @@
11
# Optimize Plugin for Webpack
22

3-
Optimize your code for modern browsers while still supporting the other 10%, increasing your build performance, reducing bundle size and improving output quality.
3+
Optimize your code for modern browsers while still supporting the other 10%,
4+
increasing your build performance, reducing bundle size and improving output quality.
45

56
Put simply: it compiles code faster, better and smaller.
67

7-
### Features
8+
## Features
89

910
- Much faster than your current Webpack setup
1011
- Transparently optimizes all of your code
1112
- Automatically optimizes all of your dependencies
1213
- Compiles bundles for modern browsers (90%) and legacy browsers (10%)
1314
- Removes unnecessary polyfills, even when inlined into dependencies
14-
- Compiles a highly-optimized dedicated polyfills bundle
15+
- Builds a highly-optimized automated polyfills bundle
16+
17+
## Usage
18+
19+
First, disable any existing configuration you have to Babel, minification, and module/nomodule.
20+
21+
Then, add `OptimizePlugin` to your Webpack plugins Array:
1522

1623
```js
1724
plugins: [
1825
new OptimizePlugin({
19-
// options
26+
// any options here
2027
})
2128
]
2229
```
30+
31+
### Options
32+
33+
| Option | Type | Description
34+
|---|---|---
35+
| `concurrency` | `number|false` | Maximum number of threads to use. Default: the number of available CPUs. <br>_Pass `false` for single-threaded, sometimes faster for small projects._
36+
37+
38+
## How does this work?
39+
40+
Instead of running Babel on each individual source code file in your project, `optimize-plugin`
41+
transforms your entire application's bundled code. This means it can apply optimizations and
42+
transformations not only to your source, but to your dependencies - making polyfill extraction
43+
and reverse transpilation steps far more effective.
44+
45+
This setup also allows `optimize-plugin` to achieve better performance. All work is done in
46+
a background thread pool, and the same AST is re-used for modern and legacy transformations.
47+
Previous solutions for module/nomodule have generally relied running two complete compilation
48+
passes, which incurs enormous overhead since the entire graph is built and traversed multiple
49+
times. With `optimize-plugin`, bundling and transpilation are now a separate concerns: Webpack
50+
handles graph creation and reduction, then passes its bundles to Babel for transpilation.
51+
52+
<img src="https://user-images.githubusercontent.com/105127/74685954-0cd21a80-519e-11ea-99f9-8fa5f3aef1b8.png">
53+
54+
### License
55+
56+
Apache-2.0

0 commit comments

Comments
 (0)