Skip to content

Commit 7cffde0

Browse files
Resolve merge conflict and improve clarity
1 parent 4ac4d7c commit 7cffde0

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

src/content/configuration/output.mdx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,12 +1586,17 @@ T> Read the [authoring libraries guide](/guides/author-libraries/) guide for mor
15861586

15871587
### output.library.export
15881588

1589-
Specify which part of your module should be exposed as the library when it is consumed by other applications.
1589+
Specify which export should be exposed as a library.In other words, this option lets you control which part of your module is exposed when used by other applications.
15901590

15911591
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.
15921592

15931593
- Type: `string | string[]`
15941594

1595+
It is `undefined` by default, which will export the whole (namespace) object.
1596+
1597+
### Explanation
1598+
By default, webpack exposes the entire module, but you can configure it to export only a specific part.
1599+
15951600
#### Example: exporting the default export
15961601

15971602
```js
@@ -1606,15 +1611,17 @@ export default {
16061611
};
16071612
```
16081613

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

16111616
```js
1617+
// if your entry has a default export
16121618
const MyLibrary = _entry_return_.default;
16131619
```
16141620

1615-
### Example: exporting a nested property
1621+
You can pass an array to `output.library.export` as well...
16161622

1617-
You can also pass an array to define a path to a specific export:
1623+
### Simplified Explanation
1624+
This allows you to access nested properties inside your module.
16181625

16191626
```js
16201627
export default {
@@ -1628,6 +1635,8 @@ export default {
16281635
};
16291636
```
16301637

1638+
And here's the library code:
1639+
16311640
```js
16321641
const MyLibrary = _entry_return_.default.subModule;
16331642
```
@@ -1766,7 +1775,7 @@ MySubModule.doSomething();
17661775

17671776
W> Please use [`output.library.type`](#outputlibrarytype) instead as we might drop support for `output.libraryTarget` in the future.
17681777

1769-
Configure how the library will be exposed. Any one of the following options can be used. Please note that this option works in conjunction with the value assigned to [`output.library`](#outputlibrary). For the following examples, it is assumed that the value of [`output.library`](#outputlibrary) is configured as `MyLibrary`.
1778+
Configure how the library is exposed and accessed by consumers in different environments (such as browser, Node.js, or module systems). This option defines the format of the generated bundle and how it will be consumed by other applications.Any one of the following options can be used. Please note that this option works in conjunction with the value assigned to [`output.library`](#outputlibrary). For the following examples, it is assumed that the value of [`output.library`](#outputlibrary) is configured as `MyLibrary`.
17701779

17711780
T> Note that `_entry_return_` in the example code below is the value returned by the entry point. In the bundle itself, it is the output of the function that is generated by webpack from the entry point.
17721781

src/content/contribute/writers-guide.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,32 @@ module.exports = {
181181

182182
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.
183183

184+
Webpack configuration defaults can vary depending on the selected mode. The two used are `development` and `production`, and each applies different default optimizations.
185+
186+
#### Development mode defaults
187+
188+
- Optimized for debugging
189+
- Includes useful warnings and error messages
190+
- Output is readable and not minified
191+
- Faster incremental builds
192+
193+
#### Production mode defaults
194+
195+
- Optimized for performance
196+
- Output is minified and optimized
197+
- Removes unnecessary code (e.g. dead code elimination)
198+
- Smaller bundle size
199+
200+
#### Example
201+
202+
```js
203+
module.exports = {
204+
mode: "development",
205+
};
206+
```
207+
208+
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.
209+
184210
**configuration.example.option**
185211

186212
`string = 'none'`

0 commit comments

Comments
 (0)