Skip to content

Commit b19c946

Browse files
authored
docs: clean up .js-with-links (webpack#6459)
* docs: clean up js-with-links * add ...
1 parent 8410a18 commit b19c946

File tree

7 files changed

+118
-237
lines changed

7 files changed

+118
-237
lines changed

src/components/Configuration/Configuration.jsx

Lines changed: 0 additions & 88 deletions
This file was deleted.

src/components/Page/Page.jsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Import External Dependencies
2-
import { Children, isValidElement, useEffect, useState } from 'react';
2+
import { useEffect, useState } from 'react';
33
import PropTypes from 'prop-types';
44
import { useLocation } from 'react-router-dom';
55

@@ -8,7 +8,6 @@ import PageLinks from '../PageLinks/PageLinks';
88
import Markdown from '../Markdown/Markdown';
99
import Contributors from '../Contributors/Contributors';
1010
import { PlaceholderString } from '../Placeholder/Placeholder';
11-
import { Pre } from '../Configuration/Configuration';
1211
import AdjacentPages from './AdjacentPages';
1312

1413
// Load Styling
@@ -91,16 +90,6 @@ export default function Page(props) {
9190

9291
if (typeof content === 'function') {
9392
contentRender = content({}).props.children;
94-
contentRender = Children.map(contentRender, (child) => {
95-
if (isValidElement(child)) {
96-
if (child.props.mdxType === 'pre') {
97-
// eslint-disable-next-line
98-
return <Pre children={child.props.children} />;
99-
}
100-
}
101-
102-
return child;
103-
});
10493
} else {
10594
contentRender = (
10695
<div

src/content/api/node.mdx

Lines changed: 71 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,12 @@ import webpack from 'webpack';
4242

4343
The imported `webpack` function is fed a webpack [Configuration Object](/configuration/) and runs the webpack compiler if a callback function is provided:
4444

45-
```js-with-links
45+
```js
4646
const webpack = require('webpack');
4747

48-
webpack({
49-
// [Configuration Object](/configuration/)
50-
}, (err, stats) => { // [Stats Object](#stats-object)
48+
webpack({}, (err, stats) => {
5149
if (err || stats.hasErrors()) {
52-
// [Handle errors here](#error-handling)
50+
// ...
5351
}
5452
// Done processing
5553
});
@@ -96,14 +94,14 @@ again. Concurrent compilations will corrupt the output files.
9694
Calling the `run` method on the `Compiler` instance is much like the quick run
9795
method mentioned above:
9896

99-
```js-with-links
97+
```js
10098
const webpack = require('webpack');
10199

102100
const compiler = webpack({
103-
// [Configuration Object](/configuration/)
101+
// ...
104102
});
105103

106-
compiler.run((err, stats) => { // [Stats Object](#stats-object)
104+
compiler.run((err, stats) => {
107105
// ...
108106

109107
compiler.close((closeErr) => {
@@ -124,21 +122,24 @@ change, runs again. Returns an instance of `Watching`.
124122
watch(watchOptions, callback);
125123
```
126124

127-
```js-with-links
125+
```js
128126
const webpack = require('webpack');
129127

130128
const compiler = webpack({
131-
// [Configuration Object](/configuration/)
129+
// ...
132130
});
133131

134-
const watching = compiler.watch({
135-
// Example [watchOptions](/configuration/watch/#watchoptions)
136-
aggregateTimeout: 300,
137-
poll: undefined
138-
}, (err, stats) => { // [Stats Object](#stats-object)
139-
// Print watch/build result here...
140-
console.log(stats);
141-
});
132+
const watching = compiler.watch(
133+
{
134+
// Example
135+
aggregateTimeout: 300,
136+
poll: undefined,
137+
},
138+
(err, stats) => {
139+
// Print watch/build result here...
140+
console.log(stats);
141+
}
142+
);
142143
```
143144

144145
`Watching` options are covered in detail
@@ -206,8 +207,8 @@ Can be used to check if there were warnings while compiling. Returns `true` or
206207
Returns compilation information as a JSON object. `options` can be either a
207208
string (a preset) or an object for more granular control:
208209

209-
```js-with-links
210-
stats.toJson('minimal'); // [more options: 'verbose', etc](/configuration/stats).
210+
```js
211+
stats.toJson('minimal');
211212
```
212213

213214
```js
@@ -238,22 +239,27 @@ stats.toString({
238239

239240
Here’s an example of `stats.toString()` usage:
240241

241-
```js-with-links
242+
```js
242243
const webpack = require('webpack');
243244

244-
webpack({
245-
// [Configuration Object](/configuration/)
246-
}, (err, stats) => {
247-
if (err) {
248-
console.error(err);
249-
return;
250-
}
245+
webpack(
246+
{
247+
// ...
248+
},
249+
(err, stats) => {
250+
if (err) {
251+
console.error(err);
252+
return;
253+
}
251254

252-
console.log(stats.toString({
253-
chunks: false, // Makes the build much quieter
254-
colors: true // Shows colors in the console
255-
}));
256-
});
255+
console.log(
256+
stats.toString({
257+
chunks: false, // Makes the build much quieter
258+
colors: true, // Shows colors in the console
259+
})
260+
);
261+
}
262+
);
257263
```
258264

259265
## MultiCompiler
@@ -263,15 +269,18 @@ separate compilers. If the `options` parameter in the webpack's NodeJS api is
263269
an array of options, webpack applies separate compilers and calls the
264270
`callback` after all compilers have been executed.
265271

266-
```js-with-links
272+
```js
267273
var webpack = require('webpack');
268274

269-
webpack([
270-
{ entry: './index1.js', output: { filename: 'bundle1.js' } },
271-
{ entry: './index2.js', output: { filename: 'bundle2.js' } }
272-
], (err, stats) => { // [Stats Object](#stats-object)
273-
process.stdout.write(stats.toString() + '\n');
274-
})
275+
webpack(
276+
[
277+
{ entry: './index1.js', output: { filename: 'bundle1.js' } },
278+
{ entry: './index2.js', output: { filename: 'bundle2.js' } },
279+
],
280+
(err, stats) => {
281+
process.stdout.write(stats.toString() + '\n');
282+
}
283+
);
275284
```
276285

277286
W> Multiple configurations will **not be run in parallel**. Each
@@ -288,32 +297,35 @@ For good error handling, you need to account for these three types of errors:
288297

289298
Here’s an example that does all that:
290299

291-
```js-with-links
300+
```js
292301
const webpack = require('webpack');
293302

294-
webpack({
295-
// [Configuration Object](/configuration/)
296-
}, (err, stats) => {
297-
if (err) {
298-
console.error(err.stack || err);
299-
if (err.details) {
300-
console.error(err.details);
303+
webpack(
304+
{
305+
// ...
306+
},
307+
(err, stats) => {
308+
if (err) {
309+
console.error(err.stack || err);
310+
if (err.details) {
311+
console.error(err.details);
312+
}
313+
return;
301314
}
302-
return;
303-
}
304315

305-
const info = stats.toJson();
316+
const info = stats.toJson();
306317

307-
if (stats.hasErrors()) {
308-
console.error(info.errors);
309-
}
318+
if (stats.hasErrors()) {
319+
console.error(info.errors);
320+
}
310321

311-
if (stats.hasWarnings()) {
312-
console.warn(info.warnings);
313-
}
322+
if (stats.hasWarnings()) {
323+
console.warn(info.warnings);
324+
}
314325

315-
// Log result...
316-
});
326+
// Log result...
327+
}
328+
);
317329
```
318330

319331
## Custom File Systems

0 commit comments

Comments
 (0)