Skip to content
15 changes: 8 additions & 7 deletions src/content/configuration/output.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1586,11 +1586,13 @@ T> Read the [authoring libraries guide](/guides/author-libraries/) guide for mor

### output.library.export

Specify which export should be exposed as a library.
Specify which part of your module should be exposed as the library when it is consumed by other applications.

By default, the entire module (namespace object) is exposed. However, in many cases, you may want to expose only a specific export, such as the default export or a particular function.

- Type: `string | string[]`

It is `undefined` by default, which will export the whole (namespace) object. The examples below demonstrate the effect of this configuration when using [`output.library.type: 'var'`](#type-var).
#### Example: exporting the default export

```js
export default {
Expand All @@ -1604,14 +1606,15 @@ export default {
};
```

The default export of your entry point will be assigned to the library name:
In this case, the entry module's `default export` is assigned to the library name.

```js
// if your entry has a default export
const MyLibrary = _entry_return_.default;
```

You can pass an array to `output.library.export` as well, it will be interpreted as a path to a module to be assigned to the library name:
### Example: exporting a nested property

You can also pass an array to define a path to a specific export:

```js
export default {
Expand All @@ -1625,8 +1628,6 @@ export default {
};
```

And here's the library code:

```js
const MyLibrary = _entry_return_.default.subModule;
```
Expand Down
30 changes: 29 additions & 1 deletion src/content/contribute/writers-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,31 @@ Please do not assume things are simple. Avoid words like 'just', 'simply'.

### Configuration defaults and types

Always provide types and defaults to all of the documentation options in order to keep the documentation accessible and well-written. We are adding types and defaults after entitling the documented option:
Webpack configuration defaults can vary depending on the selected mode. The two used are `development` and `production`, and each applies different default optimizations.

#### Development mode defaults

- Optimized for debugging
- Includes useful warnings and error messages
- Output is readable and not minified
- Faster incremental builds

#### Production mode defaults

- Optimized for performance
- Output is minified and optimized
- Removes unnecessary code (e.g. dead code elimination)
- Smaller bundle size

#### Example

```js
module.exports = {
mode: "development",
};
```

Always provide types and defaults for all documented options to keep the documentation clear and accessible. Types and defaults should be added after introducing the option.

**configuration.example.option**

Expand Down Expand Up @@ -223,3 +247,7 @@ An example can be found on the [`options` section of the EvalSourceMapDevToolPlu
### Adding links

Please use relative URLs (such as `/concepts/mode/`) to link our own content instead of absolute URLs (such as `https://webpack.js.org/concepts/mode/`).

```js

```
Loading