You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/configuration/output.mdx
+14-5Lines changed: 14 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1586,12 +1586,17 @@ T> Read the [authoring libraries guide](/guides/author-libraries/) guide for mor
1586
1586
1587
1587
### output.library.export
1588
1588
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.
1590
1590
1591
1591
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.
1592
1592
1593
1593
- Type: `string | string[]`
1594
1594
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
+
1595
1600
#### Example: exporting the default export
1596
1601
1597
1602
```js
@@ -1606,15 +1611,17 @@ export default {
1606
1611
};
1607
1612
```
1608
1613
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:
1610
1615
1611
1616
```js
1617
+
// if your entry has a default export
1612
1618
constMyLibrary=_entry_return_.default;
1613
1619
```
1614
1620
1615
-
### Example: exporting a nested property
1621
+
You can pass an array to `output.library.export` as well...
1616
1622
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.
1618
1625
1619
1626
```js
1620
1627
exportdefault {
@@ -1628,6 +1635,8 @@ export default {
1628
1635
};
1629
1636
```
1630
1637
1638
+
And here's the library code:
1639
+
1631
1640
```js
1632
1641
constMyLibrary=_entry_return_.default.subModule;
1633
1642
```
@@ -1766,7 +1775,7 @@ MySubModule.doSomething();
1766
1775
1767
1776
W> Please use [`output.library.type`](#outputlibrarytype) instead as we might drop support for `output.libraryTarget` in the future.
1768
1777
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`.
1770
1779
1771
1780
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.
Copy file name to clipboardExpand all lines: src/content/contribute/writers-guide.mdx
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -181,6 +181,32 @@ module.exports = {
181
181
182
182
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.
183
183
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.
0 commit comments