@astryxdesign/cli 0.7.15 → 0.7.16-canary.g54dd64e

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.
Files changed (123) hide show
  1. package/README.md +5 -3
  2. package/api/component/_adapter.d.mts +1 -1
  3. package/api/component/_adapter.mjs +28 -1
  4. package/api/doctor/_adapter.d.mts +17 -0
  5. package/api/doctor/_adapter.mjs +35 -0
  6. package/api/doctor/doctor.mjs +18 -4
  7. package/api/integration/pack-check.mjs +13 -7
  8. package/api/integration/validate-integration.mjs +1 -1
  9. package/api/theme/_adapter.d.mts +5 -2
  10. package/api/theme/_adapter.mjs +43 -12
  11. package/api/theme/build/build.d.mts +64 -27
  12. package/api/theme/build/build.mjs +341 -69
  13. package/api/theme/eject/eject.mjs +22 -1
  14. package/api/theme/template/template.d.mts +19 -0
  15. package/api/theme/template/template.mjs +102 -25
  16. package/api/theme/theme.type.d.mts +5 -1
  17. package/api/theme/theme.type.mjs +2 -1
  18. package/api/theme/themeBuild.doc.mjs +3 -3
  19. package/api/theme/themeEject.doc.mjs +1 -1
  20. package/api/theme/themeTemplate.doc.mjs +9 -3
  21. package/api/theme-edit/_adapter.d.mts +33 -0
  22. package/api/theme-edit/_adapter.mjs +208 -31
  23. package/api/theme-edit/_check.d.mts +38 -0
  24. package/api/theme-edit/_check.mjs +1326 -211
  25. package/api/theme-edit/_color.d.mts +2 -8
  26. package/api/theme-edit/_color.mjs +292 -219
  27. package/api/theme-edit/_compiler.d.mts +1 -0
  28. package/api/theme-edit/_compiler.mjs +20 -1
  29. package/api/theme-edit/_context.d.mts +29 -0
  30. package/api/theme-edit/_context.mjs +329 -30
  31. package/api/theme-edit/_css.d.mts +60 -1
  32. package/api/theme-edit/_css.mjs +404 -28
  33. package/api/theme-edit/_edit.d.mts +9 -0
  34. package/api/theme-edit/_edit.mjs +1025 -126
  35. package/api/theme-edit/_how-commands.d.mts +11 -26
  36. package/api/theme-edit/_how-commands.mjs +30 -2
  37. package/api/theme-edit/_how-question.d.mts +7 -0
  38. package/api/theme-edit/_how-question.mjs +1304 -176
  39. package/api/theme-edit/_how.mjs +144 -30
  40. package/api/theme-edit/_overview.mjs +2 -0
  41. package/api/theme-edit/_palette.d.mts +11 -0
  42. package/api/theme-edit/_palette.mjs +194 -65
  43. package/api/theme-edit/_parts.d.mts +16 -0
  44. package/api/theme-edit/_parts.mjs +59 -7
  45. package/api/theme-edit/_png.mjs +19 -14
  46. package/api/theme-edit/_preview-app.d.mts +3 -0
  47. package/api/theme-edit/_preview-app.mjs +843 -45
  48. package/api/theme-edit/_preview.d.mts +16 -3
  49. package/api/theme-edit/_preview.mjs +310 -29
  50. package/api/theme-edit/_project.d.mts +11 -0
  51. package/api/theme-edit/_project.mjs +46 -12
  52. package/api/theme-edit/_settings.d.mts +178 -5
  53. package/api/theme-edit/_settings.mjs +2035 -86
  54. package/api/theme-edit/_tables.d.mts +24 -0
  55. package/api/theme-edit/_tables.mjs +211 -149
  56. package/api/theme-edit/_vet.d.mts +42 -0
  57. package/api/theme-edit/_vet.mjs +144 -0
  58. package/api/theme-edit/theme-edit.type.d.mts +2 -1
  59. package/api/theme-edit/theme-edit.type.mjs +1 -1
  60. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  61. package/api/theme-edit/themeEditShow.doc.mjs +11 -3
  62. package/api/upgrade/registry/registry.mjs +6 -1
  63. package/assets/docs/tree/single-component.doc.mjs +11 -2
  64. package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
  65. package/assets/docs.generated.json +2 -2
  66. package/assets/preview-app/next.config.mjs +7 -1
  67. package/assets/preview-app/package.json +1 -0
  68. package/assets/preview-app/src/app/globals.css +1 -0
  69. package/assets/self-audit.generated.json +1 -1
  70. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
  71. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
  72. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
  73. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
  74. package/assets/templates/components.generated.json +1 -1
  75. package/assets/templates/pages/dashboard/page.tsx +1 -1
  76. package/authoring/doctypes/_schema.d.mts +52 -5
  77. package/authoring/doctypes/_schema.mjs +62 -7
  78. package/authoring/doctypes/base/type.ts +10 -0
  79. package/authoring/doctypes/component/component.doc.mjs +1 -1
  80. package/authoring/doctypes/function/function.doc.mjs +6 -0
  81. package/authoring/doctypes/function/type.ts +3 -0
  82. package/authoring/doctypes/legacy.mjs +5 -1
  83. package/authoring/index.d.ts +1 -0
  84. package/clients/cli/build-id.generated.json +1 -1
  85. package/clients/cli/commands/doctor.doc.mjs +2 -2
  86. package/clients/cli/commands/experimental/theme.mjs +190 -37
  87. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  88. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
  89. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
  90. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  91. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  92. package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
  93. package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
  94. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  95. package/clients/cli/commands/theme-eject.doc.mjs +1 -1
  96. package/clients/cli/commands/theme-template.doc.mjs +3 -1
  97. package/clients/cli/commands/theme.mjs +168 -45
  98. package/clients/cli/formatters/index.mjs +7 -4
  99. package/clients/cli/lib/cli-error.mjs +9 -3
  100. package/clients/cli/lib/component-format.mjs +27 -9
  101. package/clients/cli/lib/json-shim.mjs +40 -2
  102. package/clients/cli/manifest.generated.json +1 -1
  103. package/clients/cli/run.mjs +49 -0
  104. package/foundation/config/project.mjs +50 -14
  105. package/foundation/discovery/theme-discovery.d.mts +5 -1
  106. package/foundation/discovery/theme-discovery.mjs +24 -3
  107. package/foundation/fs/gather-cache.d.mts +9 -2
  108. package/foundation/fs/gather-cache.mjs +79 -15
  109. package/foundation/fs/paths.d.mts +31 -0
  110. package/foundation/fs/paths.mjs +43 -10
  111. package/foundation/render/host-exit.d.mts +8 -0
  112. package/foundation/render/host-exit.mjs +11 -0
  113. package/foundation/render/page-host.mjs +56 -10
  114. package/foundation/render/page-worker.mjs +14 -0
  115. package/foundation/render/render-page.mjs +37 -2
  116. package/foundation/response/error-codes.d.mts +2 -1
  117. package/foundation/response/error-codes.d.ts +1 -0
  118. package/foundation/response/error-codes.doc.mjs +5 -0
  119. package/foundation/response/error-codes.mjs +3 -0
  120. package/foundation/response/json.d.mts +15 -0
  121. package/foundation/response/json.mjs +52 -1
  122. package/foundation/response/response-types.doc.mjs +1 -1
  123. package/package.json +7 -6
@@ -0,0 +1,144 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The one place every `set` command a refusal suggests is checked
5
+ * before it is shown: each runs through the same check `set` uses (in
6
+ * memory, nothing written, nothing built), and one `set` would refuse is
7
+ * dropped, so a "do this instead" never leads to a second refusal.
8
+ *
9
+ * @position api/theme-edit — imported by _edit.mjs
10
+ */
11
+
12
+ import {AstryxError} from '../error.mjs';
13
+ import {checkSetting} from './_check.mjs';
14
+ import {P} from './_tables.mjs';
15
+
16
+ /**
17
+ * Split a printed command into its arguments, as a POSIX shell reads them:
18
+ * single quotes (with `'\''` for a quote inside), double quotes and
19
+ * backslashes. `null` when the quotes do not close.
20
+ * @param {string} line
21
+ * @returns {string[] | null}
22
+ */
23
+ export function splitCommand(line) {
24
+ /** @type {string[]} */
25
+ const out = [];
26
+ let cur = '';
27
+ let has = false;
28
+ for (let i = 0; i < line.length; i += 1) {
29
+ const c = line[i];
30
+ if (c === "'") {
31
+ const end = line.indexOf("'", i + 1);
32
+ if (end < 0) return null;
33
+ cur += line.slice(i + 1, end);
34
+ has = true;
35
+ i = end;
36
+ } else if (c === '"') {
37
+ let j = i + 1;
38
+ for (; j < line.length && line[j] !== '"'; j += 1) {
39
+ if (line[j] === '\\' && j + 1 < line.length) j += 1;
40
+ cur += line[j];
41
+ }
42
+ if (j >= line.length) return null;
43
+ has = true;
44
+ i = j;
45
+ } else if (c === '\\' && i + 1 < line.length) {
46
+ cur += line[i + 1];
47
+ has = true;
48
+ i += 1;
49
+ } else if (/\s/.test(c)) {
50
+ if (has) out.push(cur);
51
+ cur = '';
52
+ has = false;
53
+ } else {
54
+ cur += c;
55
+ has = true;
56
+ }
57
+ }
58
+ if (has) out.push(cur);
59
+ return out;
60
+ }
61
+
62
+ const VALUE_FLAGS = new Set(['on', 'when', 'state', 'mode']);
63
+
64
+ /**
65
+ * Read a suggested `set <slug> <thing> <value> [flags]` line; `null` when it
66
+ * is not one this check can read (another command or theme, a placeholder,
67
+ * an unknown flag): such a line is kept as it is.
68
+ * @param {string} name
69
+ * @param {string} slug
70
+ */
71
+ export function readSetLine(name, slug) {
72
+ const prefix = `${P} set ${slug} `;
73
+ if (!name.startsWith(prefix)) return null;
74
+ const rest = name.slice(prefix.length);
75
+ // A placeholder (`<a color>`, `…`) is a pattern, not a command to run.
76
+ if (/<[^>]*>|…/.test(rest)) return null;
77
+ const args = splitCommand(rest);
78
+ if (!args || !args.length) return null;
79
+ /** @type {string[]} */
80
+ const pos = [];
81
+ /** @type {{on?: string, when?: string, state?: string, mode?: string, only?: boolean}} */
82
+ const flags = {};
83
+ for (let i = 0; i < args.length; i += 1) {
84
+ const a = args[i];
85
+ const m = /^--([a-z]+)(?:=(.*))?$/.exec(a);
86
+ // A token (`--color-accent`) is the thing, not a flag.
87
+ if (m && (VALUE_FLAGS.has(m[1]) || m[1] === 'only') && pos.length) {
88
+ if (m[1] === 'only') {
89
+ flags.only = true;
90
+ continue;
91
+ }
92
+ const v = m[2] ?? args[(i += 1)];
93
+ if (v == null) return null;
94
+ /** @type {any} */ (flags)[m[1]] = v;
95
+ } else if (m && pos.length) {
96
+ // Some other flag (`--png`): not part of the setting.
97
+ if (m[1] === 'png') continue;
98
+ return null;
99
+ } else pos.push(a);
100
+ }
101
+ if (pos.length > 2 || !pos.length) return null;
102
+ return {thing: pos[0], value: pos[1] ?? '', flags};
103
+ }
104
+
105
+ /**
106
+ * Drop each `set` suggestion of a refusal that `set` itself would refuse,
107
+ * checked against the theme as it is now (a copy: nothing is changed). Any
108
+ * other suggestion is kept. When every suggestion goes, the refusal points
109
+ * at `set --help`.
110
+ * @template T
111
+ * @param {T} e the error thrown
112
+ * @param {import('./_settings.mjs').Ctx | null | undefined} ctx
113
+ * @param {string} slug
114
+ * @param {import('./_settings.mjs').ThemeData | null | undefined} data
115
+ * @returns {T}
116
+ */
117
+ export function vetSuggestions(e, ctx, slug, data) {
118
+ if (!(e instanceof AstryxError) || !ctx || !data) return e;
119
+ const list = e.suggestions ?? [];
120
+ if (!list.length) return e;
121
+ const kept = list.filter(s => {
122
+ const line = readSetLine(s.name, slug);
123
+ if (!line) return true;
124
+ try {
125
+ checkSetting(
126
+ ctx,
127
+ slug,
128
+ structuredClone(data),
129
+ line.thing,
130
+ line.value,
131
+ line.flags,
132
+ false,
133
+ );
134
+ return true;
135
+ } catch {
136
+ return false;
137
+ }
138
+ });
139
+ if (kept.length === list.length) return e;
140
+ e.suggestions = kept.length
141
+ ? kept
142
+ : [{name: `${P} set --help`, reason: 'see what set takes'}];
143
+ return e;
144
+ }
@@ -441,7 +441,7 @@ export type ThemeEditPreviewListOptions = {
441
441
  export type ThemeEditPreviewListResponse = {
442
442
  type: "themeEdit.previewList";
443
443
  /**
444
- * - `themeMissing`: the theme the preview wears is gone, so its route does not build; `notes`: what else to know, such as the command that switches it.
444
+ * - `themeMissing`: the theme the preview wears is gone, so its route does not build; a page's `missing`: its file is gone; `notes`: what else to know, such as the command that fixes it.
445
445
  */
446
446
  data: {
447
447
  folder: string | null;
@@ -450,6 +450,7 @@ export type ThemeEditPreviewListResponse = {
450
450
  pages: Array<{
451
451
  id: string;
452
452
  label: string;
453
+ missing?: boolean;
453
454
  }>;
454
455
  notes: string[];
455
456
  };
@@ -227,7 +227,7 @@
227
227
  * @experimental May change or be removed in a patch release.
228
228
  * @typedef {object} ThemeEditPreviewListResponse
229
229
  * @property {'themeEdit.previewList'} type
230
- * @property {{folder: string | null, theme: string | null, themeMissing: boolean, pages: Array<{id: string, label: string}>, notes: string[]}} data - `themeMissing`: the theme the preview wears is gone, so its route does not build; `notes`: what else to know, such as the command that switches it.
230
+ * @property {{folder: string | null, theme: string | null, themeMissing: boolean, pages: Array<{id: string, label: string, missing?: boolean}>, notes: string[]}} data - `themeMissing`: the theme the preview wears is gone, so its route does not build; a page's `missing`: its file is gone; `notes`: what else to know, such as the command that fixes it.
231
231
  */
232
232
 
233
233
  /**
@@ -12,7 +12,7 @@ export const doc = {
12
12
  displayName: 'themeEditNew()',
13
13
  summary: 'Start a theme in themes/<theme>/, optionally on a built-in theme.',
14
14
  description:
15
- 'Makes themes/<theme>/ with <theme>.settings.json (the settings this command owns), the generated <theme>.settings.ts, <theme>.theme.ts (which extends it and is yours), and the built <theme>.css and <theme>.js (the same build as `astryx theme build`), then writes preview.html, the sample app page with the theme. --like builds on a built-in theme (neutral, stone, matcha, y2k, gothic, chocolate, butter; its package must be installed); without it the theme starts from Astryx defaults. `settings` takes any `set` dial by name ({accent: "#7c3aed", font: "inter", corners: "round", vibrancy: "60"}): the same names, values and checks as `set`, all applied in the one build, with one result that lists them. Change the base later with `astryx experimental theme editor set <theme> base <theme|none>`. Afterwards, <theme>.theme.ts is yours: it extends the generated <theme>.settings.ts, and every later change rewrites only the settings files, so your own edits in <theme>.theme.ts survive. A theme name is lowercase letters, digits and dashes. Experimental: it may change or be removed in a patch release.',
15
+ 'Makes themes/<theme>/ with <theme>.settings.json (the settings this command owns), the generated <theme>.settings.ts, <theme>.theme.ts (which extends it and is yours), and the built <theme>.css and <theme>.js (build them again with `astryx experimental theme compile themes/<theme>/<theme>.theme.ts`, which checks the editor settings first), then writes preview.html, the sample app page with the theme. --like builds on a built-in theme (neutral, stone, matcha, y2k, gothic, chocolate, butter; its package must be installed); without it the theme starts from Astryx defaults. `settings` takes any `set` dial by name ({accent: "#7c3aed", font: "inter", corners: "round", vibrancy: "60"}): the same names, values and checks as `set`, all applied in the one build, with one result that lists them. Change the base later with `astryx experimental theme editor set <theme> base <theme|none>`. Afterwards, <theme>.theme.ts is yours: it extends the generated <theme>.settings.ts, and every later change rewrites only the settings files, so your own edits in <theme>.theme.ts survive. A theme name is lowercase letters, digits and dashes. Experimental: it may change or be removed in a patch release.',
16
16
  importPath: '@astryxdesign/cli/api/experimental',
17
17
  signature: 'themeEditNew(theme: string, options?: object): Promise<object>',
18
18
  keywords: [
@@ -13,7 +13,7 @@ export const doc = {
13
13
  summary:
14
14
  'Every setting, key values, problems the theme caused, and the theme-building page with every component.',
15
15
  description:
16
- 'Lists every setting with where it applies and its source (dial, token or property), the resolved value of key tokens in each mode, the colors (the vibrancy; each color with its seed and the shade each token uses in light and dark, marked when an exact token setting wins; any shade moved so text reads), contrast problems this theme caused versus its base, font notes, and last the generated color files. Writes two self-contained HTML files: preview.html (the sample app page) and sheet.html (the theme-building page: every component grouped, each variant side by side, overlays open, and real template pages, with an auto/light/dark switch). A theme with no build is built first, and an in-app preview (`preview add`) of the theme has its route and Colors page rewritten. --section limits the sheet to one section. Experimental: it may change or be removed in a patch release.',
16
+ 'Lists every setting with where it applies and its source (dial, token or property), the resolved value of key tokens in each mode, the colors (the vibrancy; each color with its seed and the shade each token uses in light and dark, marked when an exact token setting wins; any shade moved so text reads), contrast problems this theme caused versus its base, font notes, and last the generated color files. Writes two self-contained HTML files: preview.html (the sample app page) and sheet.html (the theme-building page: every component grouped, each variant side by side, overlays open, and real template pages, with an auto/light/dark switch). A theme with no build is built first, and an in-app preview (`preview add`) of the theme has its route and Colors page rewritten. --section limits the sheet to one section. An own change to <theme>.theme.ts since the last build is built first, and the colors mark where it wins over a generated shade; a theme source that no longer builds, or a token in it that is not text, is refused (ERR_THEME_INVALID, exit 1) and the folder stays as it was. Experimental: it may change or be removed in a patch release.',
17
17
  importPath: '@astryxdesign/cli/api/experimental',
18
18
  signature: 'themeEditShow(theme: string, options?: object): Promise<object>',
19
19
  keywords: [
@@ -61,7 +61,7 @@ export const doc = {
61
61
  },
62
62
  {
63
63
  code: 'ERR_UNKNOWN_THEME',
64
- when: 'the theme does not exist; the suggestion is the `new` command',
64
+ when: 'the theme does not exist (the suggestion is the `new` command), or its base theme package is not installed (the suggestion installs it, such as `npm install @astryxdesign/theme-neutral`)',
65
65
  },
66
66
  {
67
67
  code: 'ERR_PROJECT_REQUIRED',
@@ -73,7 +73,15 @@ export const doc = {
73
73
  },
74
74
  {
75
75
  code: 'ERR_THEME_INVALID',
76
- when: 'the theme does not build (the change is undone)',
76
+ when: 'the theme does not build, its own <theme>.theme.ts does not parse, or a token in it is not text; the folder stays as it was',
77
+ },
78
+ {
79
+ code: 'ERR_FILE_EXISTS',
80
+ when: 'a folder sits where the build writes a file (such as themes/<theme>/<theme>.d.ts); the suggestion lists it',
81
+ },
82
+ {
83
+ code: 'ERR_WRITE_FAILED',
84
+ when: 'a built file cannot be read or replaced (its permissions), or a file cannot be written; the suggestion shows its permissions',
77
85
  },
78
86
  {
79
87
  code: 'ERR_RENDER_FAILED',
@@ -1120,8 +1120,13 @@ export function logRegistryCompositionSummary(summary) {
1120
1120
  ) {
1121
1121
  continue;
1122
1122
  }
1123
+ // Only an apply writes the conflict file; a dry run names where it
1124
+ // would go, so it does not send the reader to review a file that is
1125
+ // not there.
1123
1126
  const detail = file.conflictFile
1124
- ? ` Review ${file.conflictFile}.`
1127
+ ? summary.applied
1128
+ ? ` Review ${file.conflictFile}.`
1129
+ : ` Re-run with --apply to write ${file.conflictFile} for review.`
1125
1130
  : file.message
1126
1131
  ? ` ${file.message}.`
1127
1132
  : '';
@@ -25,7 +25,7 @@ export const docs = {
25
25
  content: [
26
26
  {
27
27
  type: 'prose',
28
- text: '`integration add component` creates the normal doc for one public component. Keep the generated identity and import, then replace its sample text and props with the component\'s real public contract.',
28
+ text: "`integration add component` creates the normal doc for one public component. Keep the generated identity and import, then replace its sample text and props with the component's real public contract.",
29
29
  },
30
30
  {
31
31
  type: 'code',
@@ -149,10 +149,19 @@ export default {
149
149
  code: `examples: [
150
150
  {
151
151
  label: 'Automatic rotation',
152
- code: '<AcmeCarousel slides={slides} interval={5000} />',
152
+ code: '<AcmeCarousel slides={["/one.jpg", "/two.jpg"]} interval={5000} />',
153
+ },
154
+ {
155
+ label: 'Wrap the app',
156
+ kind: 'setup',
157
+ code: '<AcmeCarouselProvider locale={locale}>{children}</AcmeCarouselProvider>',
153
158
  },
154
159
  ],`,
155
160
  },
161
+ {
162
+ type: 'prose',
163
+ text: "An example's `kind` is `'demo'` by default: it runs on its own, so a docs site may show it as a live preview. Set `kind: 'setup'` for code that cannot run on its own, such as an app setup file, a server route, or a snippet that uses variables defined elsewhere; it is always shown as code only.",
164
+ },
156
165
  ],
157
166
  },
158
167
  {
@@ -2,7 +2,8 @@
2
2
 
3
3
  /**
4
4
  * @file `astryx docs styling/tokens-and-setup`: using design tokens in custom
5
- * styles and configuring a StyleX compiler for swizzled components.
5
+ * styles, configuring a StyleX compiler for swizzled components, and keeping
6
+ * Next.js webpack builds small.
6
7
  */
7
8
 
8
9
  /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
@@ -14,8 +15,16 @@ export const docs = {
14
15
  placement: {parent: 'namespace:styling', slot: 'guides', order: 30},
15
16
  category: 'guide',
16
17
  description:
17
- 'Using design tokens in custom styles and configuring a StyleX compiler for swizzled components.',
18
- keywords: ['StyleX setup', 'swizzle', 'webpack', 'Vite', 'Next.js'],
18
+ 'Using design tokens in custom styles, configuring a StyleX compiler for swizzled components, and keeping Next.js webpack builds small.',
19
+ keywords: [
20
+ 'StyleX setup',
21
+ 'swizzle',
22
+ 'webpack',
23
+ 'Vite',
24
+ 'Next.js',
25
+ 'optimizePackageImports',
26
+ 'Server Components',
27
+ ],
19
28
 
20
29
  sections: [
21
30
  {
@@ -129,5 +138,32 @@ export default stylexPlugin({
129
138
  },
130
139
  ],
131
140
  },
141
+ {
142
+ id: 'nextjs-webpack',
143
+ title: 'Next.js with webpack',
144
+ content: [
145
+ {
146
+ type: 'prose',
147
+ text: 'If your Next.js app builds with webpack (`next build --webpack`), add `@astryxdesign/core` to `experimental.optimizePackageImports`. With webpack, a Server Component that imports from the package root would otherwise ship every client component; this keeps first load to what the page uses. Turbopack, the default bundler in Next.js 16, needs no change, and the setting is safe to keep there.',
148
+ },
149
+ {
150
+ type: 'code',
151
+ lang: 'js',
152
+ label: 'next.config.mjs',
153
+ code: `/** @type {import('next').NextConfig} */
154
+ const nextConfig = {
155
+ experimental: {
156
+ optimizePackageImports: ['@astryxdesign/core'],
157
+ },
158
+ };
159
+
160
+ export default nextConfig;`,
161
+ },
162
+ {
163
+ type: 'prose',
164
+ text: "In Server Components, also import each component from its own entry, for example `import {Button} from '@astryxdesign/core/Button'`. `{@command component <Name>}` prints that entry. Files that start with `'use client'` are not affected.",
165
+ },
166
+ ],
167
+ },
132
168
  ],
133
169
  };