@asd14/vblocks 5.4.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,95 @@
1
+ #!/bin/sh
2
+
3
+ # vblocks.sh - What every command of vblocks shares:
4
+ # - lib.sh, the folders, the styles of the output and the header
5
+
6
+ # The caller sets _SCRIPT_DIR to the folder of vblocks.sh, then sources it
7
+ : "${_SCRIPT_DIR:?the caller sets _SCRIPT_DIR before it sources vblocks.sh}"
8
+
9
+ _VB_DIR=$(dirname "$(dirname "$_SCRIPT_DIR")")
10
+
11
+ # tools/update-lib downloads lib.sh from @asd14/posix-utils. Never edit lib.sh
12
+ # here
13
+ # shellcheck source=lib.sh
14
+ . "$_SCRIPT_DIR/lib.sh"
15
+
16
+ # _log reads LOG_NAMESPACE, LOG_LEVEL and NO_LOG_TIME.
17
+ #
18
+ # - NO_LOG_TIME drops the time, which adds no fact to a message
19
+ # - Send each stderr message through _ok, _info, _warn or _fail
20
+ # - Only the header, the summaries and `help` print on their own
21
+ LOG_NAMESPACE="vblocks"
22
+ LOG_LEVEL="info"
23
+ NO_LOG_TIME="true"
24
+
25
+ # `cd` follows an exported CDPATH and prints the folder it picked, which
26
+ # `$(cd ... && pwd)` would capture
27
+ unset CDPATH
28
+
29
+ # ╭───
30
+ # │ Primitives
31
+ # ╰───
32
+
33
+ # _shorten_home <path>
34
+ #
35
+ # Print <path> with the home folder as "~".
36
+ _shorten_home() {
37
+ if [ -n "${HOME:-}" ]; then
38
+ case "$1" in
39
+ "$HOME"/*)
40
+ # shellcheck disable=SC2088 # a literal "~", for display
41
+ printf '~/%s\n' "${1#"$HOME"/}"
42
+ return 0
43
+ ;;
44
+ esac
45
+ fi
46
+
47
+ printf '%s\n' "$1"
48
+ }
49
+
50
+ # ╭───
51
+ # │ Domain primitives
52
+ # ╰───
53
+
54
+ # _export_version
55
+ #
56
+ # Read the version of VBlocks from its package.json, and export it as
57
+ # VB_VERSION: the commands pass it to the header, and the post-init hooks read
58
+ # it. Guard node before the call.
59
+ _export_version() {
60
+ VB_VERSION=$(node -p 'require(process.argv[1]).version' "$_VB_DIR/package.json")
61
+ export VB_VERSION
62
+ }
63
+
64
+ # _print_header <version> <title>
65
+ #
66
+ # Print the name of VBlocks and <version> in the top border, then <title>, then
67
+ # close the box. The lines after it hold the details. Print nothing unless
68
+ # _IS_TERMINAL is set. The header holds no fact a reader acts on.
69
+ _print_header() {
70
+ [ -n "$_IS_TERMINAL" ] || return 0
71
+
72
+ printf '╭───────────┤ %s\n' "${_GREEN} VBlocks v$1${_RESET}"
73
+ printf '│ %s\n' "$2"
74
+ printf '╰──┤\n'
75
+ }
76
+
77
+ # ╭───
78
+ # │ Bootstrap
79
+ # ╰───
80
+
81
+ # Style the summary and the file lists, and show the header, only when stdout
82
+ # and stderr are both terminals that show color. A pipe on either one, eg.
83
+ # `| tee` or an agent that reads the output, means plain text with only the
84
+ # facts
85
+ _IS_TERMINAL=""
86
+ _BOLD="" _GREEN="" _YELLOW="" _RED="" _GRAY="" _RESET=""
87
+ if _has_color 1 && _has_color 2; then
88
+ _IS_TERMINAL="true"
89
+ _BOLD=$(printf '\033[1m')
90
+ _GREEN=$(printf '\033[32m')
91
+ _YELLOW=$(printf '\033[33m')
92
+ _RED=$(printf '\033[31m')
93
+ _GRAY=$(printf '\033[90m')
94
+ _RESET=$(printf '\033[0m')
95
+ fi
@@ -0,0 +1,120 @@
1
+ #!/bin/sh
2
+
3
+ # webpack.sh - The primitives of serve and build: the --mode and --log-level
4
+ # guards, the defaults, the summary and the Webpack run
5
+
6
+ # ╭───
7
+ # │ Domain primitives
8
+ # ╰───
9
+
10
+ # _guard_log_level <level>
11
+ #
12
+ # EXIT
13
+ # 2 <level> is empty or not one of --log-level: error, warn, info or verbose
14
+ _guard_log_level() {
15
+ gll_levels="error,warn,info,verbose"
16
+ case "$1" in
17
+ error | warn | info | verbose) ;;
18
+ "") _fail 2 -v available_levels "$gll_levels" "--log-level needs a level" ;;
19
+ *) _fail 2 -v level "$1" -v available_levels "$gll_levels" "Unknown level" ;;
20
+ esac
21
+ }
22
+
23
+ # _guard_mode <mode>
24
+ #
25
+ # EXIT
26
+ # 2 <mode> is empty or not one of --mode: development or production
27
+ _guard_mode() {
28
+ gm_modes="development,production"
29
+ case "$1" in
30
+ development | production) ;;
31
+ "") _fail 2 -v available_modes "$gm_modes" "--mode needs a mode" ;;
32
+ *) _fail 2 -v mode "$1" -v available_modes "$gm_modes" "Unknown mode" ;;
33
+ esac
34
+ }
35
+
36
+ # _pick_file <app-dir> <path>
37
+ #
38
+ # Print <path> in <app-dir> when the file exists, otherwise the default of
39
+ # VBlocks at the same <path> in defaults/. defaults/ is laid out like an app
40
+ # folder.
41
+ _pick_file() {
42
+ if [ -f "$1/$2" ]; then
43
+ printf '%s\n' "$1/$2"
44
+ else
45
+ printf '%s\n' "$_VB_DIR/defaults/$2"
46
+ fi
47
+ }
48
+
49
+ # _print_file_path <file> <app-dir>
50
+ #
51
+ # Print the path of <file>, its folder as $APP_DIR, or as $VBLOCKS_DIR in gray
52
+ # for a default of VBlocks.
53
+ _print_file_path() {
54
+ case "$1" in
55
+ "$2"/*) printf '%s\n' "\$APP_DIR/${1#"$2"/}" ;;
56
+ "$_VB_DIR"/*) printf '%s\n' "${_GRAY}\$VBLOCKS_DIR/${1#"$_VB_DIR"/}${_RESET}" ;;
57
+ *) printf '%s\n' "$1" ;;
58
+ esac
59
+ }
60
+
61
+ # _print_summary <app-dir> <webpack-config> <postcss-config> <swc-config> <robots-file> <favicon-file>
62
+ #
63
+ # Print the app folder, the VBlocks folder and the files Webpack runs with. An
64
+ # empty <robots-file> prints no Robots line.
65
+ _print_summary() {
66
+ # The icons of the tools and the files, only on a terminal
67
+ ps_webpack_icon="" ps_postcss_icon="" ps_swc_icon=""
68
+ ps_robots_icon="" ps_favicon_icon=""
69
+ if [ -n "$_IS_TERMINAL" ]; then
70
+ ps_webpack_icon=" "
71
+ ps_postcss_icon=" "
72
+ ps_swc_icon="󱡮 "
73
+ ps_robots_icon="󰚩 "
74
+ ps_favicon_icon=" "
75
+ fi
76
+
77
+ printf '%s\t%s\n' "${_BOLD}\$APP_DIR${_RESET}" "$(_shorten_home "$1")"
78
+ printf '%s\t%s\n' "${_BOLD}\$VBLOCKS_DIR${_RESET}" "${_GRAY}$(_shorten_home "$_VB_DIR")${_RESET}"
79
+ printf '\n'
80
+ printf '%s\t%s\n' "${ps_webpack_icon}${_BOLD}Webpack${_RESET}" "$(_print_file_path "$2" "$1")"
81
+ printf '%s\t%s\n' "${ps_postcss_icon}${_BOLD}PostCSS${_RESET}" "$(_print_file_path "$3" "$1")"
82
+ printf '%s\t%s\n' "${ps_swc_icon}${_BOLD}SWC${_RESET}" "$(_print_file_path "$4" "$1")"
83
+ if [ -n "$5" ]; then
84
+ printf '%s\t%s\n' "${ps_robots_icon}${_BOLD}Robots${_RESET}" "$(_print_file_path "$5" "$1")"
85
+ fi
86
+ printf '%s\t%s\n' "${ps_favicon_icon}${_BOLD}Favicon${_RESET}" "$(_print_file_path "$6" "$1")"
87
+ printf '\n'
88
+ }
89
+
90
+ # _run_webpack <action> <webpack-config> [<webpack option>...]
91
+ #
92
+ # Run `webpack <action>` with <webpack-config> and the options, through the
93
+ # webpack-cli of VBlocks.
94
+ #
95
+ # EXIT
96
+ # 2 Webpack rejected an option or the config
97
+ # 3 Webpack failed
98
+ _run_webpack() {
99
+ rw_action=$1
100
+ rw_config=$2
101
+ shift 2
102
+
103
+ # Run the webpack-cli of VBlocks, the version VBlocks depends on. npx
104
+ # would run the first one it finds from the current folder, or offer to
105
+ # install one
106
+ rw_cli_file=$(node -p \
107
+ 'require.resolve("webpack-cli/bin/cli.js", { paths: [process.argv[1]] })' \
108
+ "$_VB_DIR") || _fail 3 "Could not find the webpack-cli of VBlocks"
109
+
110
+ rw_status=0
111
+ node "$rw_cli_file" "$rw_action" --config "$rw_config" "$@" || rw_status=$?
112
+
113
+ # webpack-cli exits 1 when the build has errors, 2 when an option or the
114
+ # config is wrong
115
+ case "$rw_status" in
116
+ 0) return 0 ;;
117
+ 2) _fail 2 "Webpack rejected an option or the config" ;;
118
+ *) _fail 3 "Webpack failed" ;;
119
+ esac
120
+ }
@@ -0,0 +1,14 @@
1
+ import cssnano from "cssnano"
2
+ import postcssPresetEnv from "postcss-preset-env"
3
+
4
+ /**
5
+ * Import the plugins, so Node resolves them from this file's folder
6
+ *
7
+ * @param {{ mode: "production" | "development" | "none" }} api
8
+ */
9
+ export default ({ mode }) => ({
10
+ plugins: [
11
+ postcssPresetEnv({ stage: 2 }),
12
+ ...(mode === "production" ? [cssnano({ preset: "default" })] : []),
13
+ ],
14
+ })
@@ -1,6 +1,8 @@
1
1
  /** @typedef {import("webpack").Configuration} WebpackConfiguration */
2
2
 
3
3
  import fs from "node:fs"
4
+ import { createRequire } from "node:module"
5
+ import path from "node:path"
4
6
  import "webpack-dev-server"
5
7
  import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin"
6
8
  import CopyPlugin from "copy-webpack-plugin"
@@ -10,25 +12,15 @@ import MiniCssExtractPlugin from "mini-css-extract-plugin"
10
12
  import webpack from "webpack"
11
13
  import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer"
12
14
 
13
- // `bin/vblocks.sh` sets them to the PostCSS and SWC configs it picked, the
14
- // app's own or the default
15
- const VB_SWC_CONFIG = process.env["VB_SWC_CONFIG"]
16
- const VB_POSTCSS_CONFIG = process.env["VB_POSTCSS_CONFIG"]
17
-
18
- if (!VB_SWC_CONFIG)
19
- throw new Error("VB_SWC_CONFIG environment variable is not defined")
20
-
21
- if (!VB_POSTCSS_CONFIG)
22
- throw new Error("VB_POSTCSS_CONFIG environment variable is not defined")
23
-
24
15
  /**
25
16
  * Read the SWC config, set the browser targets it lacks, and turn on React
26
17
  * Refresh when `hasReactRefresh` is true
27
18
  *
19
+ * @param {string} path
28
20
  * @param {{ hasReactRefresh: boolean }} options
29
21
  */
30
- const loadSwcConfig = ({ hasReactRefresh }) => {
31
- const content = fs.readFileSync(VB_SWC_CONFIG, "utf8")
22
+ const loadSwcConfig = (path, { hasReactRefresh }) => {
23
+ const content = fs.readFileSync(path, "utf8")
32
24
  const config = /** @type {unknown} */ (JSON.parse(content))
33
25
  const typedConfig = /** @type {import("@swc/core").Config} */ (config)
34
26
 
@@ -81,8 +73,9 @@ const getCssModuleOptions = isProduction => ({
81
73
  * @param {"local" | "global"} options.classScope - `local` renames each class
82
74
  * to a unique name, for `*.module.css`. `global` keeps the names as written
83
75
  * @param {boolean} options.isProduction
76
+ * @param {string} options.postcssConfigPath
84
77
  */
85
- const getCssLoaders = ({ classScope, isProduction }) => [
78
+ const getCssLoaders = ({ classScope, isProduction, postcssConfigPath }) => [
86
79
  {
87
80
  loader: MiniCssExtractPlugin.loader,
88
81
  },
@@ -105,7 +98,7 @@ const getCssLoaders = ({ classScope, isProduction }) => [
105
98
  loader: "postcss-loader",
106
99
  options: {
107
100
  postcssOptions: {
108
- config: VB_POSTCSS_CONFIG,
101
+ config: postcssConfigPath,
109
102
  },
110
103
  },
111
104
  },
@@ -234,7 +227,7 @@ const inlineAssets = compiler => {
234
227
  ...tag,
235
228
  attributes: {
236
229
  rel,
237
- // `bin/vblocks.sh` only passes a `favicon.svg`
230
+ // `bin/vblocks.d/webpack.sh` only passes a `favicon.svg`
238
231
  href: `data:image/svg+xml;base64,${Buffer.from(takeAsset(href)).toString("base64")}`,
239
232
  },
240
233
  }
@@ -257,7 +250,9 @@ const inlineAssets = compiler => {
257
250
  * @typedef {Object} VBlocksEnvironment
258
251
  *
259
252
  * @property {string} entryDir - The app folder: `--prefix`, or the folder VBlocks runs in
260
- * @property {string} robotsPath - Path to the robots.txt copied to the output folder
253
+ * @property {string} postcssConfigPath - Path to the PostCSS config, the app's own or the default
254
+ * @property {string} swcConfigPath - Path to the SWC config, the app's own or the default
255
+ * @property {string} [robotsPath] - Path to the robots.txt copied to the output folder, missing in a single-file build
261
256
  * @property {string} faviconPath - Path to the favicon.svg copied to the output folder
262
257
  * @property {boolean} [single] - Build one standalone index.html, every asset inlined
263
258
  * @property {boolean} [analyze] - Run the bundle analyzer next to the dev server
@@ -286,7 +281,16 @@ const STATS_BY_LOG_LEVEL = /** @type {const} */ ({
286
281
  * @returns {WebpackConfiguration}
287
282
  */
288
283
  export default (
289
- { entryDir, robotsPath, faviconPath, single, analyze, logLevel = "warn" },
284
+ {
285
+ entryDir,
286
+ postcssConfigPath,
287
+ swcConfigPath,
288
+ robotsPath,
289
+ faviconPath,
290
+ single,
291
+ analyze,
292
+ logLevel = "warn",
293
+ },
290
294
  { mode }
291
295
  ) => {
292
296
  const isProduction = mode === "production"
@@ -294,7 +298,7 @@ export default (
294
298
  const isSingle = Boolean(single) && !isServe
295
299
  const isAnalyze = Boolean(analyze) && isServe
296
300
  const hasReactRefresh = isServe && mode === "development"
297
- const swcConfig = loadSwcConfig({ hasReactRefresh })
301
+ const swcConfig = loadSwcConfig(swcConfigPath, { hasReactRefresh })
298
302
 
299
303
  const paths = {
300
304
  appEntry: `${entryDir}/src/index.tsx`,
@@ -362,12 +366,20 @@ export default (
362
366
  },
363
367
  {
364
368
  test: /\.module\.css$/,
365
- use: getCssLoaders({ classScope: "local", isProduction }),
369
+ use: getCssLoaders({
370
+ classScope: "local",
371
+ isProduction,
372
+ postcssConfigPath,
373
+ }),
366
374
  },
367
375
  {
368
376
  test: /\.css$/,
369
377
  exclude: /\.module\.css$/,
370
- use: getCssLoaders({ classScope: "global", isProduction }),
378
+ use: getCssLoaders({
379
+ classScope: "global",
380
+ isProduction,
381
+ postcssConfigPath,
382
+ }),
371
383
  },
372
384
  {
373
385
  test: /\.(jpg|gif|png|svg)$/,
@@ -466,6 +478,7 @@ export default (
466
478
  }),
467
479
 
468
480
  !isSingle &&
481
+ paths.robots &&
469
482
  new CopyPlugin({
470
483
  patterns: [
471
484
  {
@@ -496,6 +509,12 @@ export default (
496
509
  extensions: [".tsx", ".ts", ".jsx", ".js"],
497
510
  alias: {
498
511
  "@self": `${entryDir}/src`,
512
+ // React Refresh imports the dev server's client. Use the one VBlocks runs
513
+ "webpack-dev-server": path.dirname(
514
+ createRequire(import.meta.url).resolve(
515
+ "webpack-dev-server/package.json"
516
+ )
517
+ ),
499
518
  },
500
519
  },
501
520
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@asd14/vblocks",
4
- "version": "5.4.0",
4
+ "version": "6.1.0",
5
5
  "description": "Zero-config React builds, as a static site or a single HTML file",
6
6
  "keywords": [
7
7
  "react",
@@ -34,18 +34,19 @@
34
34
  },
35
35
  "files": [
36
36
  "bin",
37
- "src",
38
- "template"
37
+ "defaults",
38
+ "template",
39
+ "types"
39
40
  ],
40
41
  "type": "module",
41
42
  "exports": {
42
43
  "./client": {
43
- "types": "./src/types/client.d.ts"
44
+ "types": "./types/client.d.ts"
44
45
  },
45
46
  "./package.json": "./package.json"
46
47
  },
47
48
  "bin": {
48
- "vblocks": "bin/vblocks.sh"
49
+ "vblocks": "bin/vblocks"
49
50
  },
50
51
  "scripts": {
51
52
  "----UTIL": "",
@@ -53,7 +54,9 @@
53
54
  "format": "eslint --fix .",
54
55
  "----CODE-QA": "",
55
56
  "lint": "eslint .",
56
- "typecheck": "tsc --noEmit",
57
+ "typecheck:code": "tsc --noEmit --project ./.tsconfig/code.json",
58
+ "typecheck:client-types": "tsc --noEmit --project ./.tsconfig/client-types.json",
59
+ "typecheck": "npm run typecheck:code && npm run typecheck:client-types",
57
60
  "unit-test:template": "tools/verify-templates",
58
61
  "unit-test": "npm run unit-test:template"
59
62
  },
@@ -61,32 +64,33 @@
61
64
  "@mdx-js/loader": "^3.1.1",
62
65
  "@pmmmwh/react-refresh-webpack-plugin": "^0.6.3",
63
66
  "@swc/helpers": "^0.5.23",
64
- "browserslist": "^4.29.3",
67
+ "browserslist": "^4.29.4",
65
68
  "copy-webpack-plugin": "^14.0.0",
66
69
  "css-loader": "^7.1.5",
67
70
  "cssnano": "^9.9.0",
68
71
  "dotenv-webpack": "^9.0.0",
69
72
  "html-webpack-plugin": "^5.6.8",
70
73
  "mini-css-extract-plugin": "^2.10.2",
71
- "postcss": "^8.5.30",
74
+ "postcss": "^8.5.31",
72
75
  "postcss-loader": "^8.2.1",
73
76
  "postcss-preset-env": "^11.6.1",
74
77
  "react-refresh": "^0.19.0",
75
78
  "swc-loader": "^0.2.7",
76
- "webpack": "^5.112.0",
79
+ "webpack": "^5.112.1",
77
80
  "webpack-bundle-analyzer": "^5.4.0",
78
81
  "webpack-cli": "^7.2.3",
79
- "webpack-dev-server": "^6.0.0"
82
+ "webpack-dev-server": "^6.1.0"
80
83
  },
81
84
  "devDependencies": {
82
- "@asd14/eslint-config": "^16.0.0",
85
+ "@asd14/eslint-config": "^16.2.0",
83
86
  "@asd14/prettier-config": "^1.5.0",
84
- "@asd14/semantic-release-config": "^1.0.1",
87
+ "@asd14/semantic-release-config": "^1.1.0",
85
88
  "@asd14/ts-config": "^1.6.0",
86
- "@commitlint/cli": "^21.2.3",
87
- "@commitlint/config-conventional": "^21.2.3",
89
+ "@commitlint/cli": "^21.2.4",
90
+ "@commitlint/config-conventional": "^21.2.4",
88
91
  "@tailwindcss/postcss": "^4.3.3",
89
92
  "@types/dotenv-webpack": "^7.0.8",
93
+ "@types/react": "^19.3.0",
90
94
  "@types/webpack-bundle-analyzer": "^4.7.0",
91
95
  "@xyflow/react": "^12.12.0",
92
96
  "eslint": "^9.39.5",
@@ -1,13 +1,14 @@
1
+ import tailwindcss from "@tailwindcss/postcss"
2
+ import cssnano from "cssnano"
3
+
1
4
  /**
5
+ * Import the plugins, so Node resolves them from this file's folder
6
+ *
2
7
  * @param {{ mode: "production" | "development" | "none" }} api
3
8
  */
4
9
  export default ({ mode }) => ({
5
- plugins: {
6
- "@tailwindcss/postcss": {
7
- optimize: mode === "production",
8
- },
9
- "cssnano": mode === "production" && {
10
- preset: "default",
11
- },
12
- },
10
+ plugins: [
11
+ tailwindcss({ optimize: mode === "production" }),
12
+ ...(mode === "production" ? [cssnano({ preset: "default" })] : []),
13
+ ],
13
14
  })
@@ -17,7 +17,6 @@ import {
17
17
  type OnSelectionChangeFunc,
18
18
  } from "@xyflow/react"
19
19
 
20
- import { ZoomLevel } from "./ui/zoom-level"
21
20
  import { CELL_SIZE, toPixels } from "./utils/grid"
22
21
 
23
22
  type StepNode = Node<{ label: string; detail: string }, "step">
@@ -142,7 +141,6 @@ const Diagram = ({ onSelect }: DiagramProps) => {
142
141
  fitViewOptions={{ minZoom: 1, maxZoom: 1 }}>
143
142
  <Background gap={CELL_SIZE} />
144
143
  <Controls />
145
- <ZoomLevel />
146
144
  </ReactFlow>
147
145
  )
148
146
  }
@@ -8,6 +8,7 @@ set -eu
8
8
  npm pkg set \
9
9
  "dependencies.@xyflow/react=^12" \
10
10
  "devDependencies.@tailwindcss/postcss=^4" \
11
+ "devDependencies.cssnano=^9" \
11
12
  "devDependencies.tailwindcss=^4"
12
13
 
13
14
  # Name the page in the browser tab.
@@ -1,13 +1,14 @@
1
+ import tailwindcss from "@tailwindcss/postcss"
2
+ import cssnano from "cssnano"
3
+
1
4
  /**
5
+ * Import the plugins, so Node resolves them from this file's folder
6
+ *
2
7
  * @param {{ mode: "production" | "development" | "none" }} api
3
8
  */
4
9
  export default ({ mode }) => ({
5
- plugins: {
6
- "@tailwindcss/postcss": {
7
- optimize: mode === "production",
8
- },
9
- "cssnano": mode === "production" && {
10
- preset: "default",
11
- },
12
- },
10
+ plugins: [
11
+ tailwindcss({ optimize: mode === "production" }),
12
+ ...(mode === "production" ? [cssnano({ preset: "default" })] : []),
13
+ ],
13
14
  })
@@ -8,6 +8,7 @@ set -eu
8
8
  npm pkg set \
9
9
  "dependencies.@xyflow/react=^12" \
10
10
  "devDependencies.@tailwindcss/postcss=^4" \
11
+ "devDependencies.cssnano=^9" \
11
12
  "devDependencies.tailwindcss=^4"
12
13
 
13
14
  # Name the page in the browser tab.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Types for the files `../webpack.config.js` teaches `import` to load.
2
+ * Types for the files `../defaults/webpack.config.js` teaches `import` to load.
3
3
  *
4
4
  * @example
5
5
  * // tsconfig.json
@@ -74,6 +74,25 @@ declare module "*.eot" {
74
74
  export default url
75
75
  }
76
76
 
77
+ /**
78
+ * The MDX document as a React component. `components` replaces the element
79
+ * MDX renders for a tag, eg. `{ h1: Title }`.
80
+ *
81
+ * @example
82
+ * import Intro from "./intro.mdx"
83
+ *
84
+ * <Intro components={{ h1: Title }} />
85
+ */
86
+ declare module "*.mdx" {
87
+ import type { ComponentType } from "react"
88
+
89
+ const MDXContent: ComponentType<{
90
+ components?: Record<string, ComponentType<Record<string, unknown>>>
91
+ }>
92
+
93
+ export default MDXContent
94
+ }
95
+
77
96
  /**
78
97
  * The `.env` variables Webpack writes into the bundle. The browser has no
79
98
  * other part of Node's `process`.