Skip to content

Commit c33e820

Browse files
byzykjeremenichelli
authored andcommitted
plugins: fix parsing errors
1 parent 0c5e391 commit c33e820

9 files changed

+8527
-70
lines changed

.eslintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"no-extra-semi": 0,
4343
"no-redeclare": 0,
4444
"no-unused-labels": 0,
45-
"no-use-before-define": 0
45+
"no-use-before-define": 0,
46+
"no-mixed-spaces-and-tabs": 0
4647
}
4748
}
4849
]

src/content/plugins/aggressive-splitting-plugin.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: AggressiveSplittingPlugin
33
contributors:
44
- pierreneter
5+
- byzyk
56
---
67

78
The `AggressiveSplittingPlugin` can split bundles into smaller chunks, splitting every chunk until it reaches the specified `maxSize` configured in `options`. It groups modules together by folder structure.
@@ -19,7 +20,7 @@ new webpack.optimize.AggressiveSplittingPlugin(options)
1920

2021
## Options
2122

22-
```js
23+
```ts
2324
{
2425
minSize: 30000, //Byte, split point. Default: 30720
2526
maxSize: 50000, //Byte, maxsize of per file. Default: 51200

src/content/plugins/banner-plugin.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
title: BannerPlugin
33
contributors:
44
- simon04
5+
- byzyk
56
related:
67
- title: banner-plugin-hashing test
78
url: https://github.com/webpack/webpack/blob/master/test/configCases/plugins/banner-plugin-hashing/webpack.config.js
89
---
910

1011
Adds a banner to the top of each generated chunk.
1112

12-
``` javascript
13+
```javascript
1314
new webpack.BannerPlugin(banner)
1415
// or
1516
new webpack.BannerPlugin(options)
@@ -18,7 +19,7 @@ new webpack.BannerPlugin(options)
1819

1920
## Options
2021

21-
```javascript
22+
```ts
2223
{
2324
banner: string, // the banner as string, it will be wrapped in a comment
2425
raw: boolean, // if true, banner will not be wrapped in a comment

src/content/plugins/commons-chunk-plugin.md

+21-17
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ contributors:
77
- kevinzwhuang
88
- jdbevan
99
- jeremenichelli
10+
- byzyk
1011
---
1112

1213
The `CommonsChunkPlugin` is an opt-in feature that creates a separate file (known as a chunk), consisting of common modules shared between multiple entry points.
@@ -22,7 +23,7 @@ new webpack.optimize.CommonsChunkPlugin(options)
2223

2324
## Options
2425

25-
```javascript
26+
```ts
2627
{
2728
name: string, // or
2829
names: string[],
@@ -38,7 +39,7 @@ new webpack.optimize.CommonsChunkPlugin(options)
3839
// If omitted the original filename is not modified (usually `output.filename` or `output.chunkFilename`).
3940
// This option is not permitted if you're using `options.async` as well, see below for more details.
4041

41-
minChunks: number|Infinity|function(module, count) -> boolean,
42+
minChunks: number|Infinity|function(module, count) => boolean,
4243
// The minimum number of chunks which need to contain a module before it's moved into the commons chunk.
4344
// The number must be greater than or equal 2 and lower than or equal to the number of chunks.
4445
// Passing `Infinity` just creates the commons chunk, but moves no modules into it.
@@ -103,21 +104,24 @@ You must load the generated chunk before the entry point:
103104
Split your code into vendor and application.
104105

105106
```javascript
106-
entry: {
107-
vendor: ["jquery", "other-lib"],
108-
app: "./entry"
109-
},
110-
plugins: [
111-
new webpack.optimize.CommonsChunkPlugin({
112-
name: "vendor",
113-
// filename: "vendor.js"
114-
// (Give the chunk a different name)
115-
116-
minChunks: Infinity,
117-
// (with more entries, this ensures that no other module
118-
// goes into the vendor chunk)
119-
})
120-
]
107+
module.exports = {
108+
//...
109+
entry: {
110+
vendor: ["jquery", "other-lib"],
111+
app: "./entry"
112+
},
113+
plugins: [
114+
new webpack.optimize.CommonsChunkPlugin({
115+
name: "vendor",
116+
// filename: "vendor.js"
117+
// (Give the chunk a different name)
118+
119+
minChunks: Infinity,
120+
// (with more entries, this ensures that no other module
121+
// goes into the vendor chunk)
122+
})
123+
]
124+
}
121125
```
122126

123127
```html

src/content/plugins/context-replacement-plugin.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: ContextReplacementPlugin
33
contributors:
44
- simon04
5+
- byzyk
56
related:
67
- title: Issue 2783 - ContextReplacementPlugin Description
78
url: https://github.com/webpack/webpack/issues/2783#issuecomment-234137265
@@ -17,9 +18,9 @@ The `ContextReplacementPlugin` allows you to override the inferred information.
1718
```javascript
1819
new webpack.ContextReplacementPlugin(
1920
resourceRegExp: RegExp,
20-
newContentResource?: string,
21-
newContentRecursive?: boolean,
22-
newContentRegExp?: RegExp
21+
newContentResource: string, // optional
22+
newContentRecursive: boolean, // optional
23+
newContentRegExp: RegExp // optional
2324
)
2425
```
2526

@@ -58,7 +59,7 @@ new webpack.ContextReplacementPlugin(/^\.\/locale$/, (context) => {
5859
regExp: /^\.\/\w+/,
5960
request: '../../locale' // resolved relatively
6061
});
61-
}),
62+
})
6263
```
6364

6465

src/content/plugins/module-concatenation-plugin.md

+15-12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: ModuleConcatenationPlugin
33
contributors:
44
- skipjack
55
- TheLarkInn
6+
- byzyk
67
related:
78
- webpack 3: Official Release!!
89
---
@@ -11,7 +12,7 @@ In the past, one of webpack’s trade-offs when bundling was that each module in
1112

1213
This plugin will enable the same concatenation behavior in webpack.
1314

14-
``` js
15+
```js
1516
new webpack.optimize.ModuleConcatenationPlugin()
1617
```
1718

@@ -29,12 +30,12 @@ As the article explains, webpack attempts to achieve partial scope hoisting. It
2930
Condition | Outcome
3031
--------------------------------------------- | --------
3132
Non ES6 Module | Prevent
32-
Imported By Non Import | Root
33-
Imported From Other Chunk | Root
34-
Imported By Multiple Other Module Groups | Root
35-
Imported With `import()` | Root
33+
Imported By Non Import | Root
34+
Imported From Other Chunk | Root
35+
Imported By Multiple Other Module Groups | Root
36+
Imported With `import()` | Root
3637
Affected By `ProvidePlugin` Or Using `module` | Prevent
37-
HMR Accepted | Root
38+
HMR Accepted | Root
3839
Using `eval()` | Prevent
3940
In Multiple Chunks | Prevent
4041
`export * from "cjs-module"` | Prevent
@@ -90,11 +91,13 @@ function tryToAdd(group, module) {
9091
When using the webpack CLI, the `--display-optimization-bailout` flag will display bailout reasons. When using the webpack config, just add the following to the `stats` object:
9192

9293
```js
93-
{
94-
...stats,
95-
// Examine all modules
96-
maxModules: Infinity,
97-
// Display bailout reasons
98-
optimizationBailout: true
94+
module.exports = {
95+
//...
96+
stats: {
97+
// Examine all modules
98+
maxModules: Infinity,
99+
// Display bailout reasons
100+
optimizationBailout: true
101+
}
99102
}
100103
```

src/content/plugins/source-map-dev-tool-plugin.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ contributors:
44
- johnnyreilly
55
- simon04
66
- neilkennedy
7+
- byzyk
78
related:
89
- title: Building Source Maps
910
url: https://survivejs.com/webpack/building/source-maps/#-sourcemapdevtoolplugin-and-evalsourcemapdevtoolplugin-
1011
---
1112

1213
This plugin enables more fine grained control of source map generation. It is an alternative to the [`devtool`](/configuration/devtool/) configuration option.
1314

14-
``` js
15+
```js
1516
new webpack.SourceMapDevToolPlugin(options)
1617
```
1718

@@ -50,7 +51,7 @@ The following examples demonstrate some common use cases for this plugin.
5051

5152
The following code would exclude source maps for any modules in the `vendor.js` bundle:
5253

53-
``` js
54+
```js
5455
new webpack.SourceMapDevToolPlugin({
5556
filename: '[name].js.map',
5657
exclude: ['vendor.js']
@@ -61,7 +62,7 @@ new webpack.SourceMapDevToolPlugin({
6162

6263
Set a URL for source maps. Useful for hosting them on a host that requires authorization.
6364

64-
``` js
65+
```js
6566
new webpack.SourceMapDevToolPlugin({
6667
append: "\n//# sourceMappingURL=http://example.com/sourcemap/[url]",
6768
filename: '[name].map'
@@ -70,7 +71,7 @@ new webpack.SourceMapDevToolPlugin({
7071

7172
And for cases when source maps are stored in the upper level directory:
7273

73-
``` js
74+
```
7475
project
7576
|- dist
7677
|- public
@@ -81,7 +82,7 @@ project
8182

8283
With next config:
8384

84-
``` js
85+
```js
8586
new webpack.SourceMapDevToolPlugin({
8687
filename: "sourcemaps/[file].map",
8788
publicPath: "https://example.com/project/",
@@ -91,6 +92,6 @@ new webpack.SourceMapDevToolPlugin({
9192

9293
Will produce the following URL:
9394

94-
``` js
95-
https://example.com/project/sourcemaps/bundle-[hash].js.map`
95+
```
96+
https://example.com/project/sourcemaps/bundle-[hash].js.map
9697
```

src/content/plugins/split-chunks-plugin.md

+31-26
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ contributors:
55
- jeremenichelli
66
- chrisdothtml
77
- EugeneHlushko
8-
8+
- byzyk
99
related:
1010
- title: "webpack 4: Code Splitting, chunk graph and the splitChunks optimization"
1111
url: https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
@@ -42,25 +42,30 @@ W> Default configuration was chosen to fit web performance best practices but th
4242
This configuration object represents the default behavior of the `SplitChunksPlugin`.
4343

4444
```js
45-
splitChunks: {
46-
chunks: "async",
47-
minSize: 30000,
48-
minChunks: 1,
49-
maxAsyncRequests: 5,
50-
maxInitialRequests: 3,
51-
automaticNameDelimiter: '~',
52-
name: true,
53-
cacheGroups: {
54-
vendors: {
55-
test: /[\\/]node_modules[\\/]/,
56-
priority: -10
57-
},
58-
default: {
59-
minChunks: 2,
60-
priority: -20,
61-
reuseExistingChunk: true
62-
}
63-
}
45+
module.exports = {
46+
//...
47+
optimization: {
48+
splitChunks: {
49+
chunks: "async",
50+
minSize: 30000,
51+
minChunks: 1,
52+
maxAsyncRequests: 5,
53+
maxInitialRequests: 3,
54+
automaticNameDelimiter: '~',
55+
name: true,
56+
cacheGroups: {
57+
vendors: {
58+
test: /[\\/]node_modules[\\/]/,
59+
priority: -10
60+
},
61+
default: {
62+
minChunks: 2,
63+
priority: -20,
64+
reuseExistingChunk: true
65+
}
66+
}
67+
}
68+
}
6469
}
6570
```
6671

@@ -206,13 +211,13 @@ module.exports = {
206211

207212
### Defaults: Example 1
208213

209-
``` js
214+
```js
210215
// index.js
211216

212217
import("./a"); // dynamic import
213218
```
214219

215-
``` js
220+
```js
216221
// a.js
217222
import "react";
218223

@@ -232,22 +237,22 @@ What's the reasoning behind this? `react` probably won't change as often as your
232237

233238
### Defaults: Example 2
234239

235-
``` js
240+
```js
236241
// entry.js
237242

238243
// dynamic imports
239244
import("./a");
240245
import("./b");
241246
```
242247

243-
``` js
248+
```js
244249
// a.js
245250
import "./helpers"; // helpers is 40kb in size
246251

247252
//...
248253
```
249254

250-
``` js
255+
```js
251256
// b.js
252257
import "./helpers";
253258
import "./more-helpers"; // more-helpers is also 40kb in size
@@ -299,7 +304,7 @@ Create a `vendors` chunk, which includes all code from `node_modules` in the who
299304
__webpack.config.js__
300305

301306

302-
``` js
307+
```js
303308
module.exports = {
304309
//...
305310
optimization: {

0 commit comments

Comments
 (0)