diff --git a/.markdownlint.json b/.markdownlint.json index 076470ed892d..916a1ee4a813 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -3,13 +3,17 @@ "MD002": false, "MD004": { "style": "dash" }, "MD007": { "indent": 2 }, - "MD013": { "line_length": 600 }, + "MD013": { "line_length": 600, "code_blocks": false }, + "MD024": { + "siblings_only": true + }, "MD026": false, "MD029": { "style": "ordered" }, "MD033": false, "MD034": false, "MD036": false, "MD041": false, + "MD053": false, "no-hard-tabs": false, "whitespace": false } diff --git a/.markdownlintignore b/.markdownlintignore new file mode 100644 index 000000000000..3c3629e647f5 --- /dev/null +++ b/.markdownlintignore @@ -0,0 +1 @@ +node_modules diff --git a/package.json b/package.json index 9867f454451b..f47d056a39ee 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,8 @@ "lint": "run-s lint:*", "lint:js": "npm run lint-js .", "lint-js": "eslint --cache --cache-location .cache/.eslintcache", - "lint:markdown": "npm run lint-markdown *.md", - "lint-markdown": "markdownlint --config ./.markdownlint.json --ignore '.vale/**/*.md' --ignore '.github/**/*.md'", + "lint:markdown": "npm run lint-markdown '**/*.{md,mdx}'", + "lint-markdown": "markdownlint --config ./.markdownlint.json", "lint:prose": "vale --config='.vale.ini' src/content", "lint:links": "hyperlink -c 8 --root dist -r dist/index.html --canonicalroot https://webpack.js.org/ --internal --skip /plugins/extract-text-webpack-plugin/ --skip /printable --skip https:// --skip http:// --skip sw.js > internal-links.tap; cat internal-links.tap | tap-spot", "sitemap": "cd dist && sitemap-static --ignore-file=../sitemap-ignore.json --pretty --prefix=https://webpack.js.org/ > sitemap.xml", @@ -62,7 +62,7 @@ "*.{js,jsx,md,mdx}": [ "npm run lint-js" ], - "*.md": [ + "*.{md,mdx}": [ "npm run lint-markdown" ], "*.{js,jsx,css,scss,md,mdx,json}": [ diff --git a/src/content/api/loaders.mdx b/src/content/api/loaders.mdx index 1c6e41e051c8..e1f9047ee0bc 100644 --- a/src/content/api/loaders.mdx +++ b/src/content/api/loaders.mdx @@ -645,7 +645,7 @@ module.exports = function (source) { The module will get bundled like this: -``` +```text /***/ "./src/loader.js!./src/lib.js": /*!************************************!*\ !*** ./src/loader.js!./src/lib.js ***! @@ -722,7 +722,10 @@ module.exports = function (source) { if (STYLES_REGEXP.test(source)) { source = source.replace(STYLES_REGEXP, ''); return `import ${JSON.stringify( - this.utils.contextify(this.context || this.rootContext, `${this.resource}.css!=!${getStylesLoader}!${this.remainingRequest}`) + this.utils.contextify( + this.context || this.rootContext, + `${this.resource}.css!=!${getStylesLoader}!${this.remainingRequest}` + ) )};${source}`; } return source; diff --git a/src/content/api/module-variables.mdx b/src/content/api/module-variables.mdx index d02f43cebbc3..e8d7ba2b05fa 100644 --- a/src/content/api/module-variables.mdx +++ b/src/content/api/module-variables.mdx @@ -130,6 +130,7 @@ Returns the same value as `require.context` but only for `javascript/auto` and ` - Available: 5.70.0+ - Example: + ```js const contextRequire = import.meta.webpackContext('.', { recursive: false, @@ -285,6 +286,7 @@ Change base URI at runtime. - Type: `string` - Available: 5.21.0+ - Example: + ```js __webpack_base_uri__ = 'https://example.com'; ``` diff --git a/src/content/configuration/experiments.mdx b/src/content/configuration/experiments.mdx index 26ff622399d0..a1ef7fbb67dc 100644 --- a/src/content/configuration/experiments.mdx +++ b/src/content/configuration/experiments.mdx @@ -74,6 +74,7 @@ When enabled, webpack can build remote resources that begin with the `http(s):` A shortcut for [`experiments.buildHttp.allowedUris`](#experimentsbuildhttpalloweduris). - `HttpUriOptions` + ```ts { allowedUris: (string|RegExp|(uri: string) => boolean)[], @@ -134,6 +135,7 @@ Define the location for caching remote resources. - `string` - `false` - Example + ```javascript // webpack.config.js module.exports = { @@ -259,6 +261,7 @@ Compile entrypoints and dynamic `import`s only when they are in use. It can be u - Available: 5.17.0+ - Example 1: + ```js module.exports = { // … @@ -267,6 +270,7 @@ Compile entrypoints and dynamic `import`s only when they are in use. It can be u }, }; ``` + - Example 2: ```js diff --git a/src/content/configuration/module.mdx b/src/content/configuration/module.mdx index 551127762c9c..80f7034df65f 100644 --- a/src/content/configuration/module.mdx +++ b/src/content/configuration/module.mdx @@ -147,6 +147,7 @@ Enable [magic comments](/api/module-methods/#magic-comments) support for CommonJ - Type: `boolean` - Available: 5.17.0+ - Example: + ```js module.exports = { module: { @@ -172,6 +173,7 @@ Specifies global mode for dynamic import. - Type: `'eager' | 'weak' | 'lazy' | 'lazy-once'` - Available: 5.73.0+ - Example: + ```js module.exports = { module: { @@ -191,6 +193,7 @@ Specifies global prefetch for dynamic import. - Type: ` number | boolean` - Available: 5.73.0+ - Example: + ```js module.exports = { module: { @@ -210,6 +213,7 @@ Specifies global preload for dynamic import. - Type: ` number | boolean` - Available: 5.73.0+ - Example: + ```js module.exports = { module: { @@ -229,6 +233,7 @@ Specifies the behavior of invalid export names in `\"import ... from ...\"` and - Type: `'error' | 'warn' | 'auto' | false` - Available: 5.62.0+ - Example: + ```js module.exports = { module: { @@ -248,6 +253,7 @@ Specifies the behavior of invalid export names in `\"import ... from ...\"`. - Type: `'error' | 'warn' | 'auto' | false` - Available: 5.62.0+ - Example: + ```js module.exports = { module: { @@ -267,6 +273,7 @@ Enable or disable evaluating `import.meta`. - Type: `boolean = true` - Available: 5.68.0+ - Example: + ```js module.exports = { module: { @@ -286,6 +293,7 @@ Enable/disable evaluating [`import.meta.webpackContext`](/api/module-variables/# - Type: `boolean` - Available: 5.70.0+ - Example: + ```js module.exports = { module: { @@ -305,6 +313,7 @@ Specifies the behavior of invalid export names in `\"export ... from ...\"`. Thi - Type: `'error' | 'warn' | 'auto' | false` - Available: 5.62.0+ - Example: + ```js module.exports = { module: { @@ -323,6 +332,7 @@ Enable parsing of `new URL()` syntax. - Type: `boolean = true` | `'relative'` - Example: + ```js module.exports = { module: { @@ -337,12 +347,12 @@ Enable parsing of `new URL()` syntax. The `'relative'` value for `module.parser.javascript.url` is available since webpack . When used, webpack would generate relative URLs for `new URL()` syntax, i.e., there's no base URL included in the result URL: -``` +```html - + - + ``` 1. This is useful for SSR (Server side rendering) when base URL is not known by server (and it saves a few bytes). To be identical it must also be used for the client build. diff --git a/src/content/configuration/output.mdx b/src/content/configuration/output.mdx index 1fa1f2331058..e6867a4a5927 100644 --- a/src/content/configuration/output.mdx +++ b/src/content/configuration/output.mdx @@ -912,6 +912,7 @@ module.exports = { Specify a name for the library. - Type: + ```ts string | string[] | {amd?: string, commonjs?: string, root?: string | string[]} ``` diff --git a/src/content/configuration/resolve.mdx b/src/content/configuration/resolve.mdx index 72e593b07190..f75c6e1182d2 100644 --- a/src/content/configuration/resolve.mdx +++ b/src/content/configuration/resolve.mdx @@ -708,6 +708,7 @@ Configure resolve options by the type of module request. - Type: `[type: string]: ResolveOptions` - Example: + ```js module.exports = { // ... diff --git a/src/content/configuration/watch.mdx b/src/content/configuration/watch.mdx index 556b4b72c260..bdcc652ec7a4 100644 --- a/src/content/configuration/watch.mdx +++ b/src/content/configuration/watch.mdx @@ -150,6 +150,7 @@ Follow symbolic links while looking for a file. This is usually not needed as we - Type: `boolean` - Example: + ```js module.exports = { //... @@ -165,6 +166,7 @@ Stop watching when stdin stream has ended. - Type: `boolean` - Example: + ```js module.exports = { //... diff --git a/yarn.lock b/yarn.lock index 61cfbdb964d0..7439a88ca647 100644 --- a/yarn.lock +++ b/yarn.lock @@ -364,12 +364,7 @@ resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz#38d3acb654b4701a9b77fb0615a96f775c3a9e63" integrity sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw== -"@babel/helper-validator-identifier@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz#9c97e30d31b2b8c72a1d08984f2ca9b574d7a076" - integrity sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g== - -"@babel/helper-validator-identifier@^7.19.1": +"@babel/helper-validator-identifier@^7.18.6", "@babel/helper-validator-identifier@^7.19.1": version "7.19.1" resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2" integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==