Skip to content

Commit d9d601d

Browse files
marioaccskipjack
authored andcommitted
Grammar and spelling enhancements.
1 parent ca58445 commit d9d601d

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/content/guides/author-libraries.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ contributors:
99
- marioacc
1010
---
1111

12-
webpack is a tool which can be used to bundle application code and also to bundle library code. If you are the author of a JavaScript library and are looking to streamline your bundle strategy then this document will help you with the differents webpack configurations to expose your libraries as you think convenient.
12+
Aside from applications, webpack can also be used to bundle JavaScript libraries. The following guide is meant for library authors looking to streamline their bundling strategy..
1313

1414

1515
## Authoring a Library
1616

17-
Let's assume that you are writing a small library ,`webpack-numbers`, allowing to convert numbers 1 to 5 from their numeric representation to the textual one and vice-versa, e.g.: 2 to 'two'.
17+
Let's assume that you are writing a small library ,`webpack-numbers`, allowing to convert numbers 1 to 5 from their numeric representation to the textual one and vice-versa, e.g.: 2 to 'two'.
1818
The basic project structure may look like this.
1919

2020
__project__
@@ -80,8 +80,8 @@ export function wordToNum(word) {
8080
The usage specification for the library use will be as follows:
8181

8282
```javascript
83-
import * as webpackNumbers from 'webpack-numbers';//ES2015 module import
84-
var webpackNumbers = require('webpack-numbers');// CommonJS module require
83+
import * as webpackNumbers from 'webpack-numbers'; //ES2015 module import
84+
var webpackNumbers = require('webpack-numbers'); //CommonJS module require
8585
...
8686
webpackNumbers.wordToNum('Two') //ES2015 and CommonJS module use
8787
...
@@ -103,34 +103,34 @@ The consumer also can use the library loading it with the script tag:
103103
<script>
104104
...
105105
/* Global variable */
106-
webpackNumbers.wordToNum('Five')
106+
webpackNumbers.wordToNum('Five')
107107
/* Property in the window object */
108-
window.webpackNumbers.wordToNum('Five')
108+
window.webpackNumbers.wordToNum('Five')
109109
//
110110
...
111111
</script>
112112
</html>
113113
```
114114

115-
The configurations also can expose the library in the next ways:
115+
The configurations also can expose the library in the following ways:
116116

117117
- Property in the global object, for node.
118-
- Property in the this object.
118+
- Property in the `this` object.
119119

120120

121121
For full library configuration and code please refer to [webpack-library-example](https://github.com/kalcifer/webpack-library-example)
122122

123123

124124
## Configure webpack
125125

126-
Now the agenda is to bundle this library achieving the next goals:
126+
Now the plan is to bundle this library achieving the next goals:
127127

128128
- Without bundling `lodash`, but requiring it to be loaded by the consumer using `externals`.
129129
- Setting the library name as `webpack-numbers`.
130130
- Exposing the library as a variable called `webpackNumbers`.
131131
- Being able to access the library inside Node.js.s
132132

133-
Also, the consumer will be able to access` the library the `next ways:
133+
Also, the consumer will be able to access the library the following ways:
134134

135135
- ES2015 module. i.e. `import webpackNumbers from 'webpack-numbers'`.
136136
- CommonJS module. i.e. `require('webpack-numbers')`.
@@ -222,14 +222,14 @@ module.exports = {
222222
};
223223
```
224224

225-
W>At the moment of webpack 3.5.5, using the next configuration is not working properly as stated in the [issue 4824](https://github.com/webpack/webpack/issues/4824):
225+
W> With webpack 3.5.5, using the following configuration doesn't work properly as stated in [issue 4824](https://github.com/webpack/webpack/issues/4824):
226226

227227
```javascript
228228
module.exports = {
229229
...
230230
output: {
231231
...
232-
232+
233233
libraryTarget: {
234234
root:'_'
235235
}
@@ -244,7 +244,7 @@ W> However, you can set libraryTarget.var='_' to expect the library as a global
244244

245245
For widespread use of the library, we would like it to be compatible in different environments, i.e. CommonJS, AMD, Node.js and as a global variable.
246246

247-
To make your library available for reuse, add `library` property inside `output` in webpack configuration.
247+
To make your library available for reuse, add the `library` property inside `output` in the webpack configuration.
248248

249249
__webpack.config.js__
250250

@@ -259,7 +259,7 @@ module.exports = {
259259
};
260260
```
261261

262-
This makes your library bundle to be available as a global variable named `webpackNumbers` when imported. To make the library compatible with other environments, add `libraryTarget` property to the config. This will add the differents options about how the library can be exposed.
262+
This makes your library bundle available as a global variable named `webpackNumbers` when imported. To make the library compatible with other environments, add `libraryTarget` property to the config. This will add the different options about how the library can be exposed.
263263

264264
__webpack.config.js__
265265

@@ -275,14 +275,14 @@ module.exports = {
275275
};
276276
```
277277

278-
You can expose the library in the next ways:
278+
You can expose the library in the following ways:
279279

280280
- Variable: as a global variable. Available in the `script` tag. i.e. `libraryTarget:'var'`.
281281
- This: available trough the this object. i.e. `libraryTarget:'this'`.
282282
- Window: available trough the `window` object, in the browser. i.e. `libraryTarget:'window'`.
283283
- UMD: available after AMD or CommonJS `require`. i.e. `libraryTarget:'umd'`
284284

285-
If `library` is set and `libraryTarget` is not, `libraryTarget` defaults to `var` as specified in the [output configuration documentation](/configuration/output).
285+
If `library` is set and `libraryTarget` is not, `libraryTarget` defaults to `var` as specified in the [output configuration documentation](/configuration/output).
286286
See [`output.libraryTarget`](/configuration/output#output-librarytarget) there for a detailed list of all available options.
287287

288288

0 commit comments

Comments
 (0)