Skip to content

Commit 829fdd1

Browse files
committed
docs(api): minor formatting and cleanup
1 parent fb5cf5f commit 829fdd1

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

src/content/api/loaders.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ A single result can be returned in **sync mode**. For multiple results the `this
2121

2222
```javascript
2323
module.exports = function(content) {
24-
return someSyncOperation(content);
24+
return someSyncOperation(content);
2525
};
2626
```
2727

2828
**sync-loader-with-multiple-results.js**
2929

3030
```javascript
3131
module.exports = function(content) {
32-
this.callback(null, someSyncOperation(content), sourceMaps, ast);
33-
return; // always return undefined when calling callback()
32+
this.callback(null, someSyncOperation(content), sourceMaps, ast);
33+
return; // always return undefined when calling callback()
3434
};
3535
```
3636

src/content/api/plugins.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ T> For a high-level introduction to writing plugins, start with [writing a plugi
88

99
Many objects in webpack extend the `Tapable` class, which exposes a `plugin` method. And with the `plugin` method, plugins can inject custom build steps. You will see `compiler.plugin` and `compilation.plugin` used a lot. Essentially, each one of these plugin calls binds a callback to fire at specific steps throughout the build process.
1010

11+
There are two types of plugin interfaces...
12+
13+
__Timing Based__
14+
15+
- sync (default): The plugin runs synchronously and returns its output.
16+
- async: The plugin runs asynchronously and uses the give `callback` to return its output.
17+
- parallel: The handlers are invoked in parallel.
18+
19+
__Return Value__
20+
21+
- not bailing (default): No return value.
22+
- bailing: The handlers are invoked in order until one handler returns something.
23+
- parallel bailing: The handlers are invoked in parallel (async). The first returned value (by order) is significant.
24+
- waterfall: Each handler gets the result value of the last handler as an argument.
25+
1126
A plugin is installed once as webpack starts up. webpack installs a plugin by calling its `apply` method, and passes a reference to the webpack `compiler` object. You may then call `compiler.plugin` to access asset compilations and their individual build steps. An example would look like this:
1227

1328
__my-plugin.js__
@@ -50,30 +65,12 @@ plugins: [
5065
```
5166

5267

53-
## Plugin Interfaces
54-
55-
There are two types of plugin interfaces.
56-
57-
__Timing Based:__
58-
59-
- sync (default): As seen above. Use return.
60-
- async: Last parameter is a callback. Signature: function(err, result)
61-
- parallel: The handlers are invoked parallel (async).
62-
63-
__Return Value:__
64-
65-
- not bailing (default): No return value.
66-
- bailing: The handlers are invoked in order until one handler returns something.
67-
- parallel bailing: The handlers are invoked in parallel (async). The first returned value (by order) is significant.
68-
- waterfall: Each handler gets the result value of the last handler as an argument.
69-
70-
71-
## Tapable & Tapable instances
68+
## Tapable & Tapable Instances
7269

7370
The plugin architecture is mainly possible for webpack due to an internal library named `Tapable`.
7471
**Tapable Instances** are classes in the webpack source code which have been extended or mixed in from class `Tapable`.
7572

7673
For plugin authors, it is important to know which are the `Tapable` instances in the webpack source code. These instances provide a variety of event hooks into which custom plugins can be attached.
7774
Hence, throughout this section are a list of all of the webpack `Tapable` instances (and their event hooks), which plugin authors can utilize.
7875

79-
For more information on `Tapable` visit the [tapable repository](https://github.com/webpack/tapable) or visit the [complete overview](./tapable)
76+
For more information on `Tapable` visit the [complete overview](/api/tapable) or the [tapable repository](https://github.com/webpack/tapable).

0 commit comments

Comments
 (0)