@asd14/vblocks 8.1.0 → 8.3.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.
@@ -19,8 +19,8 @@ Next.js does.
19
19
  together -->
20
20
 
21
21
  - An app needs only `src/index.tsx` and `src/index.html`
22
- - VBlocks supports SWC, PostCSS, CSS Modules, MDX, React Refresh and `.env`
23
- files
22
+ - VBlocks supports SWC, PostCSS, CSS Modules, MDX with GFM, React Refresh and
23
+ `.env` files
24
24
  - Several apps can share one `package.json` and `node_modules/`
25
25
  - In development, the Agentation toolbar sends UI annotations to an agent
26
26
 
@@ -52,17 +52,8 @@ together -->
52
52
  `import {{text}} from "{{./note.txt}}?raw"`
53
53
  - Import a Markdown or MDX file as a component:\
54
54
  `import {{Intro}} from "{{./intro.mdx}}"`
55
-
56
- ## Conventions
57
-
58
- - Write no Webpack, PostCSS or SWC config. The defaults cover a React app
59
- - To change part of a config, import it from `@asd14/vblocks/postcss` or
60
- `@asd14/vblocks/webpack` in a config of the same name in the app folder,
61
- change it, and return it
62
- - For an advanced use, eg. a micro-frontend, eject the default with
63
- `vblocks eject` and edit the copy
64
- - Put each concern that `src/index.tsx` imports in its own
65
- `src/index.<concern>.tsx`, eg. `index.app.tsx` defines `App`
55
+ - Replace the element MDX renders for a tag, eg. each GFM pipe table:\
56
+ `<Intro components={{ table: Table }} />`
66
57
 
67
58
  ## Index
68
59
 
@@ -72,7 +63,7 @@ recomputes the lines and the counts after each edit of the docs -->
72
63
  Paths are relative to the package root: the VBlocks repo, or
73
64
  `node_modules/@asd14/vblocks/` in the project folder.
74
65
 
75
- **`README.md`**, 614 lines:
66
+ **`README.md`**, 638 lines:
76
67
 
77
68
  - "## Quick Start" L:72-120
78
69
  - "### Keep several apps in one project" L:124-167
@@ -80,22 +71,22 @@ Paths are relative to the package root: the VBlocks repo, or
80
71
  - "### Import from `src/` with `@self`" L:195-216
81
72
  - "### Use CSS Modules" L:218-243
82
73
  - "### Import a file as text" L:245-256
83
- - "### Write a page in Markdown or MDX" L:258-321
84
- - "#### `code` meta as props" L:275-321
85
- - "### Pick the browsers" L:323-340
86
- - "### Replace a config" L:342-379
87
- - "### Extend a config" L:381-440
88
- - "#### PostCSS" L:388-420
89
- - "#### Webpack" L:422-440
90
- - "### Style with Tailwind" L:442-497
91
- - "### Send UI annotations to an AI agent" L:499-517
92
- - "### Open the page from another device" L:519-526
93
- - "### Build a single HTML file" L:528-539
94
- - "### Add VBlocks to an existing project" L:541-578
95
- - "## More docs" L:580-589
96
- - "## Develop" L:591-610
97
-
98
- **`docs/REFERENCE.md`**, 605 lines:
74
+ - "### Write a page in Markdown or MDX" L:258-324
75
+ - "#### `code` meta as props" L:278-324
76
+ - "### Pick the browsers" L:326-343
77
+ - "### Replace a config" L:345-399
78
+ - "### Extend a config" L:401-464
79
+ - "#### PostCSS" L:408-444
80
+ - "#### Webpack" L:446-464
81
+ - "### Style with Tailwind" L:466-521
82
+ - "### Send UI annotations to an AI agent" L:523-541
83
+ - "### Open the page from another device" L:543-550
84
+ - "### Build a single HTML file" L:552-563
85
+ - "### Add VBlocks to an existing project" L:565-602
86
+ - "## More docs" L:604-613
87
+ - "## Develop" L:615-634
88
+
89
+ **`docs/REFERENCE.md`**, 631 lines:
99
90
 
100
91
  - "## Domain Vocabulary" L:27-35
101
92
  - "### `vblocks`" L:39-75
@@ -104,13 +95,13 @@ Paths are relative to the package root: the VBlocks repo, or
104
95
  - "### `vblocks build`" L:191-264
105
96
  - "### `vblocks eject`" L:266-304
106
97
  - "### `webpack.config.js`" L:314-354
107
- - "### `postcss.config.js`" L:356-409
108
- - "### `.swcrc`" L:411-461
109
- - "### `.browserslistrc`" L:463-483
110
- - "### `@asd14/vblocks/postcss`" L:489-526
111
- - "### `@asd14/vblocks/webpack`" L:528-580
112
- - "## Templates" L:582-597
113
- - "## Environment variables" L:599-605
98
+ - "### `postcss.config.js`" L:356-422
99
+ - "### `.swcrc`" L:424-474
100
+ - "### `.browserslistrc`" L:476-496
101
+ - "### `@asd14/vblocks/postcss`" L:502-552
102
+ - "### `@asd14/vblocks/webpack`" L:554-606
103
+ - "## Templates" L:608-623
104
+ - "## Environment variables" L:625-631
114
105
 
115
106
  **`template/`**:
116
107
 
package/README.md CHANGED
@@ -20,7 +20,7 @@ everything set up.
20
20
 
21
21
  **🔋 Maximal support**
22
22
 
23
- - SWC, PostCSS, CSS Modules, MDX, React Refresh, `.env` files
23
+ - SWC, PostCSS, CSS Modules, MDX with GFM, React Refresh, `.env` files
24
24
 
25
25
  **📦 Several apps, one install**
26
26
 
@@ -72,7 +72,7 @@ everything set up.
72
72
  ## Quick Start
73
73
 
74
74
  > [!IMPORTANT]\
75
- > VBlocks needs Node `^22.22.3`, `^24.15.0` or `>=26.0`.
75
+ > VBlocks needs Node `^22.22.3`, `^24.15.0` or `>=26.13`.
76
76
 
77
77
  <!--
78
78
  Using "scaffold", the field's word for what `init` does, eg. Yeoman and
@@ -265,11 +265,14 @@ import Intro from "./intro.mdx"
265
265
  const App = () => <Intro />
266
266
  ```
267
267
 
268
- Pass `components` to replace the element MDX renders for a tag, eg. each `#`
269
- heading:
268
+ VBlocks reads GFM (GitHub Flavored Markdown) with
269
+ [remark-gfm](https://github.com/remarkjs/remark-gfm). A page can use tables,
270
+ strikethrough, task lists, autolinks and footnotes.
271
+
272
+ Pass `components` to replace the element MDX renders for a tag, eg. each table:
270
273
 
271
274
  ```tsx
272
- <Intro components={{ h1: Title }} />
275
+ <Intro components={{ table: Table }} />
273
276
  ```
274
277
 
275
278
  #### `code` meta as props
@@ -362,22 +365,39 @@ A config in your app folder replaces the VBlocks default of the same name:
362
365
  npx vblocks eject postcss > postcss.config.js
363
366
  ```
364
367
 
365
- > [!IMPORTANT]\
366
- > Node resolves the packages an ejected config imports from the project
367
- > folder, not from the VBlocks folder. Install them there. To keep the
368
- > VBlocks config and change part of it, [extend it](#extend-a-config)
369
- > instead.
368
+ > [!IMPORTANT]\
369
+ > Node resolves the packages an ejected config imports from the project folder,
370
+ > not from the VBlocks folder. Install them there. To keep the VBlocks config
371
+ > and change part of it, [extend it](#extend-a-config) instead.
370
372
 
371
- 2. **Install the packages it imports**, see its `import` lines
373
+ 2. **Install the packages it imports, and the ones you add**, eg. one that adds
374
+ the `@custom-media` definitions of `src/media.css` to every CSS file
372
375
 
373
376
  ```sh
374
- npm install --save-dev postcss-preset-env cssnano
377
+ npm install --save-dev postcss-preset-env cssnano @csstools/postcss-global-data
375
378
  ```
376
379
 
377
380
  `swc` and `browserslist` import nothing.
378
381
 
379
382
  3. **Update the ejected file**
380
383
 
384
+ ```diff
385
+ +import { fileURLToPath } from "node:url"
386
+ +
387
+ +import postcssGlobalData from "@csstools/postcss-global-data"
388
+ import cssnano from "cssnano"
389
+ import postcssPresetEnv from "postcss-preset-env"
390
+ +
391
+ +const MEDIA = fileURLToPath(new URL("src/media.css", import.meta.url))
392
+
393
+ /** … */
394
+ const getPostcssConfig = ({ mode }) => ({
395
+ plugins: [
396
+ + // First, so postcss-preset-env finds the `(--name)` definitions it replaces
397
+ + postcssGlobalData({ files: [MEDIA] }),
398
+ postcssPresetEnv({ stage: 2 }),
399
+ ```
400
+
381
401
  ### Extend a config
382
402
 
383
403
  Import the VBlocks config into a config of the same name in your app folder,
@@ -387,35 +407,39 @@ so you install only the ones you add.
387
407
 
388
408
  #### PostCSS
389
409
 
390
- 1. **Install your plugin**, eg. one that adds the `@custom-media` definitions of
391
- `src/media.css` to every CSS file
410
+ 1. **Install the plugin you add**, eg. cssnano, with options of your own
392
411
 
393
412
  ```sh
394
- npm install --save-dev @csstools/postcss-global-data
413
+ npm install --save-dev cssnano
395
414
  ```
396
415
 
397
- 2. **Add it to the VBlocks config, in `postcss.config.js`**
416
+ 2. **Replace the VBlocks cssnano, in `postcss.config.js`**
398
417
 
399
418
  ```js
400
- import { fileURLToPath } from "node:url"
401
-
402
419
  import { getPostcssConfig } from "@asd14/vblocks/postcss"
403
- import postcssGlobalData from "@csstools/postcss-global-data"
420
+ import cssnano from "cssnano"
404
421
 
405
- const MEDIA = fileURLToPath(new URL("src/media.css", import.meta.url))
422
+ // The default preset, which also removes the `/*!` comments
423
+ const CSSNANO_OPTIONS = {
424
+ preset: ["default", { discardComments: { removeAll: true } }],
425
+ }
406
426
 
407
427
  export default api => {
408
- const config = getPostcssConfig(api)
409
- // First, so postcss-preset-env finds the `(--name)` definitions it replaces
410
- config.plugins.unshift(postcssGlobalData({ files: [MEDIA] }))
428
+ const {
429
+ plugins: [presetEnv],
430
+ } = getPostcssConfig(api)
411
431
 
412
- return config
432
+ return {
433
+ plugins: [
434
+ presetEnv,
435
+ ...(api.mode === "production" ? [cssnano(CSSNANO_OPTIONS)] : []),
436
+ ],
437
+ }
413
438
  }
414
439
  ```
415
440
 
416
441
  PostCSS runs the plugins in array order: `postcss-preset-env`, then `cssnano`
417
- in `production`. To replace one, destructure the array, eg.
418
- `const { plugins: [presetEnv, cssnano] } = getPostcssConfig(api)`
442
+ in `production`. Destructure the array to keep the ones you want.
419
443
 
420
444
  See also: [`@asd14/vblocks/postcss`](docs/REFERENCE.md#asd14vblockspostcss)
421
445
 
@@ -596,18 +620,18 @@ vblocks/
596
620
  ├── defaults/ # the configs that eject prints
597
621
  ├── template/ # the templates of init
598
622
  ├── test/
599
- │ ├── mdx-code-meta/ # an MDX page with code meta, built and run in Node
623
+ │ ├── mdx-code-meta/ # an MDX page with code meta and a pipe table, built and run in Node
600
624
  │ └── verify-templates/ # typechecks, builds and serves each template
601
625
  └── types/ # client.d.ts
602
626
  ```
603
627
 
604
- | Script | Does |
605
- | :--------------------------------------- | :-------------------------------------------------------------------- |
606
- | `npm run lint` | Runs ESLint |
607
- | `npm run typecheck` | Typechecks the code and the client types |
608
- | `npm run integration-test` | Runs both integration tests |
609
- | `npm run integration-test:templates` | Typechecks, builds and serves every template `vblocks init` writes |
610
- | `npm run integration-test:mdx-code-meta` | Builds an MDX page and checks the props its `code` component receives |
628
+ | Script | Does |
629
+ | :--------------------------------------- | :--------------------------------------------------------------------------- |
630
+ | `npm run lint` | Runs ESLint |
631
+ | `npm run typecheck` | Typechecks the code and the client types |
632
+ | `npm run integration-test` | Runs both integration tests |
633
+ | `npm run integration-test:templates` | Typechecks, builds and serves every template `vblocks init` writes |
634
+ | `npm run integration-test:mdx-code-meta` | Builds an MDX page and checks what its `code` and `table` components receive |
611
635
 
612
636
  ## License
613
637
 
@@ -16,11 +16,24 @@ import postcssPresetEnv from "postcss-preset-env"
16
16
  * @example
17
17
  * // postcss.config.js, in the app folder
18
18
  * import { getPostcssConfig } from "@asd14/vblocks/postcss"
19
+ * import cssnano from "cssnano"
20
+ *
21
+ * // The default preset, which also removes the `/*!` comments
22
+ * const CSSNANO_OPTIONS = {
23
+ * preset: ["default", { discardComments: { removeAll: true } }],
24
+ * }
19
25
  *
20
26
  * export default api => {
21
- * const { plugins: [presetEnv, cssnano] } = getPostcssConfig(api)
27
+ * const {
28
+ * plugins: [presetEnv],
29
+ * } = getPostcssConfig(api)
22
30
  *
23
- * return { plugins: [presetEnv, ...(cssnano ? [cssnano] : [])] }
31
+ * return {
32
+ * plugins: [
33
+ * presetEnv,
34
+ * ...(api.mode === "production" ? [cssnano(CSSNANO_OPTIONS)] : []),
35
+ * ],
36
+ * }
24
37
  * }
25
38
  */
26
39
  const getPostcssConfig = ({ mode }) => ({
@@ -12,6 +12,7 @@ import HtmlWebPackPlugin from "html-webpack-plugin"
12
12
  import MiniCssExtractPlugin from "mini-css-extract-plugin"
13
13
  import postcss from "postcss"
14
14
  import rehypeMdxCodeProps from "rehype-mdx-code-props"
15
+ import remarkGfm from "remark-gfm"
15
16
  import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer"
16
17
 
17
18
  const logger = buildLogger({ namespace: "vblocks", level: "info" })
@@ -420,10 +421,20 @@ const getWebpackConfig = (
420
421
  {
421
422
  loader: require.resolve("@mdx-js/loader"),
422
423
  options: {
423
- // The meta of a code block, eg. `file="src/app.tsx"`, becomes
424
- // props of the `code` component. `tagName: "code"` replaces
425
- // the default of the plugin, `pre`
426
- rehypePlugins: [[rehypeMdxCodeProps, { tagName: "code" }]],
424
+ // remark-gfm adds tables, strikethrough, task lists, autolinks
425
+ // and footnotes to the CommonMark that MDX reads
426
+ remarkPlugins: [remarkGfm],
427
+ rehypePlugins: [
428
+ [
429
+ // The meta of a code block, eg. `file="src/app.tsx"`,
430
+ // becomes props of the `code` component.
431
+ rehypeMdxCodeProps,
432
+ {
433
+ // `tagName: "code"` replaces the default, `pre`
434
+ tagName: "code",
435
+ },
436
+ ],
437
+ ],
427
438
  },
428
439
  },
429
440
  ],
package/docs/REFERENCE.md CHANGED
@@ -326,7 +326,7 @@ npx vblocks eject webpack > webpack.config.js
326
326
  | Files | Loaders, in the order they run, or the output |
327
327
  | :-------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------ |
328
328
  | `*.ts`, `*.tsx`, outside `node_modules` | `swc-loader`, with [`.swcrc`](#swcrc) |
329
- | `*.md`, `*.mdx`, outside `node_modules` | `@mdx-js/loader`, with `rehype-mdx-code-props`, then `swc-loader` |
329
+ | `*.md`, `*.mdx`, outside `node_modules` | `@mdx-js/loader`, with `remark-gfm` and `rehype-mdx-code-props`, then `swc-loader` |
330
330
  | `*.css` | `postcss-loader`, with [`postcss.config.js`](#postcssconfigjs), then `css-loader`, then the loader of `mini-css-extract-plugin` |
331
331
  | `*.module.css` | the same, and `css-loader` renames each class to a unique name, see [Use CSS Modules](../README.md#use-css-modules) |
332
332
  | `*.jpg`, `*.gif`, `*.png`, `*.svg` | a data URL up to 10 KiB, a file above it. With `--single-file`, a data URL |
@@ -385,11 +385,24 @@ import postcssPresetEnv from "postcss-preset-env"
385
385
  * @example
386
386
  * // postcss.config.js, in the app folder
387
387
  * import { getPostcssConfig } from "@asd14/vblocks/postcss"
388
+ * import cssnano from "cssnano"
389
+ *
390
+ * // The default preset, which also removes the `/*!` comments
391
+ * const CSSNANO_OPTIONS = {
392
+ * preset: ["default", { discardComments: { removeAll: true } }],
393
+ * }
388
394
  *
389
395
  * export default api => {
390
- * const { plugins: [presetEnv, cssnano] } = getPostcssConfig(api)
396
+ * const {
397
+ * plugins: [presetEnv],
398
+ * } = getPostcssConfig(api)
391
399
  *
392
- * return { plugins: [presetEnv, ...(cssnano ? [cssnano] : [])] }
400
+ * return {
401
+ * plugins: [
402
+ * presetEnv,
403
+ * ...(api.mode === "production" ? [cssnano(CSSNANO_OPTIONS)] : []),
404
+ * ],
405
+ * }
393
406
  * }
394
407
  */
395
408
  const getPostcssConfig = ({ mode }) => ({
@@ -503,11 +516,24 @@ getPostcssConfig(api: {
503
516
  ```js
504
517
  // postcss.config.js, in the app folder
505
518
  import { getPostcssConfig } from "@asd14/vblocks/postcss"
519
+ import cssnano from "cssnano"
506
520
 
507
- export default api => {
508
- const { plugins: [presetEnv, cssnano] } = getPostcssConfig(api)
521
+ // The default preset, which also removes the `/*!` comments
522
+ const CSSNANO_OPTIONS = {
523
+ preset: ["default", { discardComments: { removeAll: true } }],
524
+ }
509
525
 
510
- return { plugins: [presetEnv, ...(cssnano ? [cssnano] : [])] }
526
+ export default api => {
527
+ const {
528
+ plugins: [presetEnv],
529
+ } = getPostcssConfig(api)
530
+
531
+ return {
532
+ plugins: [
533
+ presetEnv,
534
+ ...(api.mode === "production" ? [cssnano(CSSNANO_OPTIONS)] : []),
535
+ ],
536
+ }
511
537
  }
512
538
  ```
513
539
 
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": "8.1.0",
4
+ "version": "8.3.0",
5
5
  "description": "Zero-config React builds of an SPA (single-page application), as a folder or a single HTML file",
6
6
  "keywords": [
7
7
  "react",
@@ -79,21 +79,22 @@
79
79
  "html-webpack-plugin": "^5.6.8",
80
80
  "mini-css-extract-plugin": "^2.10.2",
81
81
  "postcss": "^8.5.33",
82
- "postcss-loader": "^8.2.1",
82
+ "postcss-loader": "^8.2.2",
83
83
  "postcss-preset-env": "^11.6.3",
84
84
  "react-refresh": "^0.19.0",
85
85
  "rehype-mdx-code-props": "^3.0.1",
86
+ "remark-gfm": "^4.0.1",
86
87
  "swc-loader": "^0.2.7",
87
- "webpack": "^5.112.2",
88
+ "webpack": "^5.113.0",
88
89
  "webpack-bundle-analyzer": "^5.4.3",
89
90
  "webpack-cli": "^7.3.1",
90
91
  "webpack-dev-server": "^6.1.0"
91
92
  },
92
93
  "devDependencies": {
93
- "@asd14/eslint-config": "^17.0.0",
94
- "@asd14/prettier-config": "^1.5.0",
95
- "@asd14/semantic-release-config": "^1.1.0",
96
- "@asd14/ts-config": "^2.0.0",
94
+ "@asd14/eslint-config": "^17.1.0",
95
+ "@asd14/prettier-config": "^1.6.0",
96
+ "@asd14/semantic-release-config": "^2.0.0",
97
+ "@asd14/ts-config": "^2.1.0",
97
98
  "@commitlint/cli": "^21.2.4",
98
99
  "@commitlint/config-conventional": "^21.2.4",
99
100
  "@tailwindcss/postcss": "^4.3.5",
@@ -105,7 +106,7 @@
105
106
  "agentation": "^3.1.2",
106
107
  "eslint": "^9.39.5",
107
108
  "prettier": "^3.10.1",
108
- "semantic-release": "^25.0.9",
109
+ "semantic-release": "^26.0.1",
109
110
  "tailwindcss": "^4.3.5",
110
111
  "typescript": "^6.0.3"
111
112
  },
@@ -114,6 +115,6 @@
114
115
  "react-dom": "^18 || ^19"
115
116
  },
116
117
  "engines": {
117
- "node": "^22.22.3 || ^24.15.0 || >=26.0"
118
+ "node": "^22.22.3 || ^24.15.0 || >=26.13"
118
119
  }
119
120
  }
@@ -14,7 +14,7 @@
14
14
  "react-dom": "^19"
15
15
  },
16
16
  "devDependencies": {
17
- "@asd14/ts-config": "^2.0.0",
17
+ "@asd14/ts-config": "^2.1.0",
18
18
  "@asd14/vblocks": "*",
19
19
  "@types/react": "^19",
20
20
  "@types/react-dom": "^19",