@typestyles/build-runner 0.5.2 → 0.5.3

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.
package/dist/index.cjs CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  DEFAULT_EXTRACT_MODULE_CANDIDATES: () => DEFAULT_EXTRACT_MODULE_CANDIDATES,
24
+ DEFAULT_REGISTERED_COMPONENTS_MODULE_BASES: () => DEFAULT_REGISTERED_COMPONENTS_MODULE_BASES,
24
25
  TYPESTYLES_IMPORT_RE: () => TYPESTYLES_IMPORT_RE,
25
26
  VerifyTypestylesBuildError: () => VerifyTypestylesBuildError,
26
27
  buildManifestV2: () => buildManifestV2,
@@ -28,9 +29,11 @@ __export(index_exports, {
28
29
  createModuleLoader: () => createModuleLoader,
29
30
  discoverDefaultExtractModules: () => discoverDefaultExtractModules,
30
31
  discoverNextAppRoutes: () => discoverNextAppRoutes,
32
+ discoverRegisteredComponentsModule: () => discoverRegisteredComponentsModule,
31
33
  extractNamespaces: () => extractNamespaces,
32
34
  getRouteCss: () => getRouteCss,
33
35
  isManifestV2: () => isManifestV2,
36
+ moduleNeedsOverrideHmr: () => moduleNeedsOverrideHmr,
34
37
  normalizeRoutePath: () => normalizeRoutePath,
35
38
  pageRelPathToRoutePath: () => pageRelPathToRoutePath,
36
39
  readCssFile: () => readCssFile,
@@ -59,6 +62,12 @@ var DISCOVERY_EXTENSIONS = [".ts", ".tsx", ".js", ".mjs"];
59
62
  var DEFAULT_EXTRACT_MODULE_CANDIDATES = DEFAULT_EXTRACT_MODULE_BASES.map(
60
63
  (base) => `${base}.ts`
61
64
  );
65
+ var DEFAULT_REGISTERED_COMPONENTS_MODULE_BASES = [
66
+ "src/themeable-refs",
67
+ "src/typestyles/themeable-refs",
68
+ "src/typestyles-registry",
69
+ "styles/themeable-refs"
70
+ ];
62
71
  function discoverDefaultExtractModules(root) {
63
72
  const absRoot = (0, import_node_path.resolve)(root);
64
73
  for (const base of DEFAULT_EXTRACT_MODULE_BASES) {
@@ -71,6 +80,18 @@ function discoverDefaultExtractModules(root) {
71
80
  }
72
81
  return [];
73
82
  }
83
+ function discoverRegisteredComponentsModule(root) {
84
+ const absRoot = (0, import_node_path.resolve)(root);
85
+ for (const base of DEFAULT_REGISTERED_COMPONENTS_MODULE_BASES) {
86
+ for (const ext of DISCOVERY_EXTENSIONS) {
87
+ const rel = `${base}${ext}`;
88
+ if ((0, import_node_fs.existsSync)((0, import_node_path.resolve)(absRoot, rel))) {
89
+ return rel.replace(/\\/g, "/");
90
+ }
91
+ }
92
+ }
93
+ return void 0;
94
+ }
74
95
 
75
96
  // src/namespaces.ts
76
97
  var STYLES_COMPONENT_RE = /styles\.component\(\s*['"]([^'"]+)['"]/g;
@@ -80,7 +101,50 @@ var CREATE_THEME_RE = /(?:tokens\.)?createTheme\(\s*['"]([^'"]+)['"]/g;
80
101
  var KEYFRAMES_CREATE_RE = /keyframes\.create\(\s*['"]([^'"]+)['"]/g;
81
102
  var GLOBAL_STYLE_RE = /global\.style\(\s*['"]([^'"]+)['"]/g;
82
103
  var GLOBAL_FONT_FACE_RE = /global\.fontFace\(\s*['"]([^'"]+)['"]/g;
104
+ var OVERRIDE_HMR_EXPORT_NAMES = /* @__PURE__ */ new Set(["createDesignTheme", "overrideComponent"]);
83
105
  var TYPESTYLES_IMPORT_RE = /(?:from\s+|import\s+|require\s*\(\s*)['"]typestyles['"]/;
106
+ function stripCommentsForHmrScan(code) {
107
+ return code.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1");
108
+ }
109
+ function collectOverrideHmrCallTargets(code) {
110
+ const locals = new Set(OVERRIDE_HMR_EXPORT_NAMES);
111
+ const namespaces = /* @__PURE__ */ new Set();
112
+ for (const match of code.matchAll(/import\s*{([^}]+)}\s*from\s*['"][^'"]+['"]/g)) {
113
+ for (const rawPart of match[1].split(",")) {
114
+ const part = rawPart.trim();
115
+ if (!part || part.startsWith("type ")) continue;
116
+ const asMatch = part.match(/^(\w+)\s+as\s+(\w+)$/);
117
+ if (asMatch) {
118
+ if (OVERRIDE_HMR_EXPORT_NAMES.has(asMatch[1])) {
119
+ locals.add(asMatch[2]);
120
+ }
121
+ continue;
122
+ }
123
+ const name = part.match(/^(\w+)$/)?.[1];
124
+ if (name && OVERRIDE_HMR_EXPORT_NAMES.has(name)) {
125
+ locals.add(name);
126
+ }
127
+ }
128
+ }
129
+ for (const match of code.matchAll(/import\s*\*\s*as\s+(\w+)\s*from\s*['"][^'"]+['"]/g)) {
130
+ namespaces.add(match[1]);
131
+ }
132
+ return { locals, namespaces };
133
+ }
134
+ function moduleNeedsOverrideHmr(code) {
135
+ const scan = stripCommentsForHmrScan(code);
136
+ if (/\bstyles\.override\s*\(/.test(scan)) return true;
137
+ const { locals, namespaces } = collectOverrideHmrCallTargets(scan);
138
+ for (const name of locals) {
139
+ if (new RegExp(`\\b${name}\\s*\\(`).test(scan)) return true;
140
+ }
141
+ for (const ns of namespaces) {
142
+ if (new RegExp(`\\b${ns}\\.(?:createDesignTheme|overrideComponent)\\s*\\(`).test(scan)) {
143
+ return true;
144
+ }
145
+ }
146
+ return false;
147
+ }
84
148
  function extractNamespaces(code) {
85
149
  const keys = [];
86
150
  const prefixes = [];
@@ -123,10 +187,20 @@ function reportDuplicateNamespaces(moduleNamespaces, id, prefixes, reporter) {
123
187
 
124
188
  // src/resolve-extract.ts
125
189
  function resolveExtractModules(root, extract) {
190
+ let modules;
126
191
  if (extract?.modules !== void 0) {
127
- return extract.modules;
192
+ modules = [...extract.modules];
193
+ } else {
194
+ modules = discoverDefaultExtractModules(root);
195
+ }
196
+ let registeredModule = extract?.registeredComponentsModule;
197
+ if (!registeredModule && extract?.include === "allRegisteredComponents") {
198
+ registeredModule = discoverRegisteredComponentsModule(root);
199
+ }
200
+ if (registeredModule && !modules.includes(registeredModule)) {
201
+ modules.push(registeredModule);
128
202
  }
129
- return discoverDefaultExtractModules(root);
203
+ return modules;
130
204
  }
131
205
  function resolveExtractMode(explicitMode, resolvedModules) {
132
206
  return explicitMode ?? (resolvedModules.length > 0 ? "build" : "runtime");
@@ -603,6 +677,7 @@ ${result.stderr || result.stdout || "unknown error"}`
603
677
  // Annotate the CommonJS export names for ESM import in node:
604
678
  0 && (module.exports = {
605
679
  DEFAULT_EXTRACT_MODULE_CANDIDATES,
680
+ DEFAULT_REGISTERED_COMPONENTS_MODULE_BASES,
606
681
  TYPESTYLES_IMPORT_RE,
607
682
  VerifyTypestylesBuildError,
608
683
  buildManifestV2,
@@ -610,9 +685,11 @@ ${result.stderr || result.stdout || "unknown error"}`
610
685
  createModuleLoader,
611
686
  discoverDefaultExtractModules,
612
687
  discoverNextAppRoutes,
688
+ discoverRegisteredComponentsModule,
613
689
  extractNamespaces,
614
690
  getRouteCss,
615
691
  isManifestV2,
692
+ moduleNeedsOverrideHmr,
616
693
  normalizeRoutePath,
617
694
  pageRelPathToRoutePath,
618
695
  readCssFile,
package/dist/index.d.cts CHANGED
@@ -3,13 +3,33 @@
3
3
  * Shared by bundler integrations and `@typestyles/next/build`.
4
4
  */
5
5
  declare const DEFAULT_EXTRACT_MODULE_CANDIDATES: readonly string[];
6
+ /**
7
+ * Side-effect modules that import every recipe and export `getRegisteredComponentRefs(styles)`.
8
+ * Used when `extract.include` is `"allRegisteredComponents"`.
9
+ */
10
+ declare const DEFAULT_REGISTERED_COMPONENTS_MODULE_BASES: readonly ["src/themeable-refs", "src/typestyles/themeable-refs", "src/typestyles-registry", "styles/themeable-refs"];
6
11
  /**
7
12
  * Resolve the default extraction module when the user did not pass explicit `modules`.
8
13
  * Returns at most one path using `/` separators, relative to `root`.
9
14
  */
10
15
  declare function discoverDefaultExtractModules(root: string): string[];
16
+ /**
17
+ * Convention registry module for `extract.include: 'allRegisteredComponents'`.
18
+ * The file should import all recipe modules and
19
+ * export `getRegisteredComponentRefs(styles)` from your `createTypeStyles` entry.
20
+ */
21
+ declare function discoverRegisteredComponentsModule(root: string): string | undefined;
11
22
 
12
23
  declare const TYPESTYLES_IMPORT_RE: RegExp;
24
+ /**
25
+ * True when this module may register `styles.override` rules and needs Vite HMR
26
+ * dispose tracking — including Var UI sugar (`createDesignTheme` / `overrideComponent`)
27
+ * that never spells `styles.override` in source.
28
+ *
29
+ * Detects renamed imports (`createDesignTheme as cdt`) and namespace imports
30
+ * (`Core.createDesignTheme(`), not only the canonical identifier spelling.
31
+ */
32
+ declare function moduleNeedsOverrideHmr(code: string): boolean;
13
33
  /**
14
34
  * Extract namespace information from source code for invalidation and duplicate checks.
15
35
  */
@@ -39,6 +59,19 @@ interface TypestylesExtractOptions {
39
59
  * Output CSS filename. Defaults to `typestyles.css`.
40
60
  */
41
61
  fileName?: string;
62
+ /**
63
+ * Additional module that re-exports {@link getRegisteredComponentRefs} (or an
64
+ * equivalent object of every themeable recipe handle) so extract bundles retain
65
+ * full design-system CSS without a hand-maintained registry object.
66
+ */
67
+ registeredComponentsModule?: string;
68
+ /**
69
+ * When `"allRegisteredComponents"`, appends a convention registry module if present
70
+ * ({@link discoverRegisteredComponentsModule}) or {@link registeredComponentsModule}
71
+ * when set. That file must side-effect-import every recipe and reference
72
+ * `getRegisteredComponentRefs(styles)` — the extract entry alone is not enough.
73
+ */
74
+ include?: 'allRegisteredComponents';
42
75
  }
43
76
  /**
44
77
  * Resolve extraction modules from explicit config or convention entry discovery.
@@ -194,4 +227,4 @@ interface RunTypestylesBuildOptions {
194
227
  */
195
228
  declare function runTypestylesBuild({ root, modules, }: RunTypestylesBuildOptions): Promise<string>;
196
229
 
197
- export { type CollectRouteCssOptions, type CollectRouteCssResult, DEFAULT_EXTRACT_MODULE_CANDIDATES, type DuplicateNamespaceReporter, type GetRouteCssOptions, type NextAppRoute, type RunTypestylesBuildOptions, TYPESTYLES_IMPORT_RE, type TypestylesExtractManifest, type TypestylesExtractManifestV1, type TypestylesExtractManifestV2, type TypestylesExtractOptions, type TypestylesIntegrationMode, type TypestylesRouteCssEntry, VerifyTypestylesBuildError, type VerifyTypestylesBuildOptions, type VerifyTypestylesBuildResult, buildManifestV2, collectAndWriteRouteCss, createModuleLoader, discoverDefaultExtractModules, discoverNextAppRoutes, extractNamespaces, getRouteCss, isManifestV2, normalizeRoutePath, pageRelPathToRoutePath, readCssFile, readTypestylesManifest, reportDuplicateNamespaces, resolveExtractMode, resolveExtractModules, runTypestylesBuild, traceTypestylesModules, verifyTypestylesBuild };
230
+ export { type CollectRouteCssOptions, type CollectRouteCssResult, DEFAULT_EXTRACT_MODULE_CANDIDATES, DEFAULT_REGISTERED_COMPONENTS_MODULE_BASES, type DuplicateNamespaceReporter, type GetRouteCssOptions, type NextAppRoute, type RunTypestylesBuildOptions, TYPESTYLES_IMPORT_RE, type TypestylesExtractManifest, type TypestylesExtractManifestV1, type TypestylesExtractManifestV2, type TypestylesExtractOptions, type TypestylesIntegrationMode, type TypestylesRouteCssEntry, VerifyTypestylesBuildError, type VerifyTypestylesBuildOptions, type VerifyTypestylesBuildResult, buildManifestV2, collectAndWriteRouteCss, createModuleLoader, discoverDefaultExtractModules, discoverNextAppRoutes, discoverRegisteredComponentsModule, extractNamespaces, getRouteCss, isManifestV2, moduleNeedsOverrideHmr, normalizeRoutePath, pageRelPathToRoutePath, readCssFile, readTypestylesManifest, reportDuplicateNamespaces, resolveExtractMode, resolveExtractModules, runTypestylesBuild, traceTypestylesModules, verifyTypestylesBuild };
package/dist/index.d.ts CHANGED
@@ -3,13 +3,33 @@
3
3
  * Shared by bundler integrations and `@typestyles/next/build`.
4
4
  */
5
5
  declare const DEFAULT_EXTRACT_MODULE_CANDIDATES: readonly string[];
6
+ /**
7
+ * Side-effect modules that import every recipe and export `getRegisteredComponentRefs(styles)`.
8
+ * Used when `extract.include` is `"allRegisteredComponents"`.
9
+ */
10
+ declare const DEFAULT_REGISTERED_COMPONENTS_MODULE_BASES: readonly ["src/themeable-refs", "src/typestyles/themeable-refs", "src/typestyles-registry", "styles/themeable-refs"];
6
11
  /**
7
12
  * Resolve the default extraction module when the user did not pass explicit `modules`.
8
13
  * Returns at most one path using `/` separators, relative to `root`.
9
14
  */
10
15
  declare function discoverDefaultExtractModules(root: string): string[];
16
+ /**
17
+ * Convention registry module for `extract.include: 'allRegisteredComponents'`.
18
+ * The file should import all recipe modules and
19
+ * export `getRegisteredComponentRefs(styles)` from your `createTypeStyles` entry.
20
+ */
21
+ declare function discoverRegisteredComponentsModule(root: string): string | undefined;
11
22
 
12
23
  declare const TYPESTYLES_IMPORT_RE: RegExp;
24
+ /**
25
+ * True when this module may register `styles.override` rules and needs Vite HMR
26
+ * dispose tracking — including Var UI sugar (`createDesignTheme` / `overrideComponent`)
27
+ * that never spells `styles.override` in source.
28
+ *
29
+ * Detects renamed imports (`createDesignTheme as cdt`) and namespace imports
30
+ * (`Core.createDesignTheme(`), not only the canonical identifier spelling.
31
+ */
32
+ declare function moduleNeedsOverrideHmr(code: string): boolean;
13
33
  /**
14
34
  * Extract namespace information from source code for invalidation and duplicate checks.
15
35
  */
@@ -39,6 +59,19 @@ interface TypestylesExtractOptions {
39
59
  * Output CSS filename. Defaults to `typestyles.css`.
40
60
  */
41
61
  fileName?: string;
62
+ /**
63
+ * Additional module that re-exports {@link getRegisteredComponentRefs} (or an
64
+ * equivalent object of every themeable recipe handle) so extract bundles retain
65
+ * full design-system CSS without a hand-maintained registry object.
66
+ */
67
+ registeredComponentsModule?: string;
68
+ /**
69
+ * When `"allRegisteredComponents"`, appends a convention registry module if present
70
+ * ({@link discoverRegisteredComponentsModule}) or {@link registeredComponentsModule}
71
+ * when set. That file must side-effect-import every recipe and reference
72
+ * `getRegisteredComponentRefs(styles)` — the extract entry alone is not enough.
73
+ */
74
+ include?: 'allRegisteredComponents';
42
75
  }
43
76
  /**
44
77
  * Resolve extraction modules from explicit config or convention entry discovery.
@@ -194,4 +227,4 @@ interface RunTypestylesBuildOptions {
194
227
  */
195
228
  declare function runTypestylesBuild({ root, modules, }: RunTypestylesBuildOptions): Promise<string>;
196
229
 
197
- export { type CollectRouteCssOptions, type CollectRouteCssResult, DEFAULT_EXTRACT_MODULE_CANDIDATES, type DuplicateNamespaceReporter, type GetRouteCssOptions, type NextAppRoute, type RunTypestylesBuildOptions, TYPESTYLES_IMPORT_RE, type TypestylesExtractManifest, type TypestylesExtractManifestV1, type TypestylesExtractManifestV2, type TypestylesExtractOptions, type TypestylesIntegrationMode, type TypestylesRouteCssEntry, VerifyTypestylesBuildError, type VerifyTypestylesBuildOptions, type VerifyTypestylesBuildResult, buildManifestV2, collectAndWriteRouteCss, createModuleLoader, discoverDefaultExtractModules, discoverNextAppRoutes, extractNamespaces, getRouteCss, isManifestV2, normalizeRoutePath, pageRelPathToRoutePath, readCssFile, readTypestylesManifest, reportDuplicateNamespaces, resolveExtractMode, resolveExtractModules, runTypestylesBuild, traceTypestylesModules, verifyTypestylesBuild };
230
+ export { type CollectRouteCssOptions, type CollectRouteCssResult, DEFAULT_EXTRACT_MODULE_CANDIDATES, DEFAULT_REGISTERED_COMPONENTS_MODULE_BASES, type DuplicateNamespaceReporter, type GetRouteCssOptions, type NextAppRoute, type RunTypestylesBuildOptions, TYPESTYLES_IMPORT_RE, type TypestylesExtractManifest, type TypestylesExtractManifestV1, type TypestylesExtractManifestV2, type TypestylesExtractOptions, type TypestylesIntegrationMode, type TypestylesRouteCssEntry, VerifyTypestylesBuildError, type VerifyTypestylesBuildOptions, type VerifyTypestylesBuildResult, buildManifestV2, collectAndWriteRouteCss, createModuleLoader, discoverDefaultExtractModules, discoverNextAppRoutes, discoverRegisteredComponentsModule, extractNamespaces, getRouteCss, isManifestV2, moduleNeedsOverrideHmr, normalizeRoutePath, pageRelPathToRoutePath, readCssFile, readTypestylesManifest, reportDuplicateNamespaces, resolveExtractMode, resolveExtractModules, runTypestylesBuild, traceTypestylesModules, verifyTypestylesBuild };
package/dist/index.js CHANGED
@@ -13,6 +13,12 @@ var DISCOVERY_EXTENSIONS = [".ts", ".tsx", ".js", ".mjs"];
13
13
  var DEFAULT_EXTRACT_MODULE_CANDIDATES = DEFAULT_EXTRACT_MODULE_BASES.map(
14
14
  (base) => `${base}.ts`
15
15
  );
16
+ var DEFAULT_REGISTERED_COMPONENTS_MODULE_BASES = [
17
+ "src/themeable-refs",
18
+ "src/typestyles/themeable-refs",
19
+ "src/typestyles-registry",
20
+ "styles/themeable-refs"
21
+ ];
16
22
  function discoverDefaultExtractModules(root) {
17
23
  const absRoot = resolvePath(root);
18
24
  for (const base of DEFAULT_EXTRACT_MODULE_BASES) {
@@ -25,6 +31,18 @@ function discoverDefaultExtractModules(root) {
25
31
  }
26
32
  return [];
27
33
  }
34
+ function discoverRegisteredComponentsModule(root) {
35
+ const absRoot = resolvePath(root);
36
+ for (const base of DEFAULT_REGISTERED_COMPONENTS_MODULE_BASES) {
37
+ for (const ext of DISCOVERY_EXTENSIONS) {
38
+ const rel = `${base}${ext}`;
39
+ if (existsSync(resolvePath(absRoot, rel))) {
40
+ return rel.replace(/\\/g, "/");
41
+ }
42
+ }
43
+ }
44
+ return void 0;
45
+ }
28
46
 
29
47
  // src/namespaces.ts
30
48
  var STYLES_COMPONENT_RE = /styles\.component\(\s*['"]([^'"]+)['"]/g;
@@ -34,7 +52,50 @@ var CREATE_THEME_RE = /(?:tokens\.)?createTheme\(\s*['"]([^'"]+)['"]/g;
34
52
  var KEYFRAMES_CREATE_RE = /keyframes\.create\(\s*['"]([^'"]+)['"]/g;
35
53
  var GLOBAL_STYLE_RE = /global\.style\(\s*['"]([^'"]+)['"]/g;
36
54
  var GLOBAL_FONT_FACE_RE = /global\.fontFace\(\s*['"]([^'"]+)['"]/g;
55
+ var OVERRIDE_HMR_EXPORT_NAMES = /* @__PURE__ */ new Set(["createDesignTheme", "overrideComponent"]);
37
56
  var TYPESTYLES_IMPORT_RE = /(?:from\s+|import\s+|require\s*\(\s*)['"]typestyles['"]/;
57
+ function stripCommentsForHmrScan(code) {
58
+ return code.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1");
59
+ }
60
+ function collectOverrideHmrCallTargets(code) {
61
+ const locals = new Set(OVERRIDE_HMR_EXPORT_NAMES);
62
+ const namespaces = /* @__PURE__ */ new Set();
63
+ for (const match of code.matchAll(/import\s*{([^}]+)}\s*from\s*['"][^'"]+['"]/g)) {
64
+ for (const rawPart of match[1].split(",")) {
65
+ const part = rawPart.trim();
66
+ if (!part || part.startsWith("type ")) continue;
67
+ const asMatch = part.match(/^(\w+)\s+as\s+(\w+)$/);
68
+ if (asMatch) {
69
+ if (OVERRIDE_HMR_EXPORT_NAMES.has(asMatch[1])) {
70
+ locals.add(asMatch[2]);
71
+ }
72
+ continue;
73
+ }
74
+ const name = part.match(/^(\w+)$/)?.[1];
75
+ if (name && OVERRIDE_HMR_EXPORT_NAMES.has(name)) {
76
+ locals.add(name);
77
+ }
78
+ }
79
+ }
80
+ for (const match of code.matchAll(/import\s*\*\s*as\s+(\w+)\s*from\s*['"][^'"]+['"]/g)) {
81
+ namespaces.add(match[1]);
82
+ }
83
+ return { locals, namespaces };
84
+ }
85
+ function moduleNeedsOverrideHmr(code) {
86
+ const scan = stripCommentsForHmrScan(code);
87
+ if (/\bstyles\.override\s*\(/.test(scan)) return true;
88
+ const { locals, namespaces } = collectOverrideHmrCallTargets(scan);
89
+ for (const name of locals) {
90
+ if (new RegExp(`\\b${name}\\s*\\(`).test(scan)) return true;
91
+ }
92
+ for (const ns of namespaces) {
93
+ if (new RegExp(`\\b${ns}\\.(?:createDesignTheme|overrideComponent)\\s*\\(`).test(scan)) {
94
+ return true;
95
+ }
96
+ }
97
+ return false;
98
+ }
38
99
  function extractNamespaces(code) {
39
100
  const keys = [];
40
101
  const prefixes = [];
@@ -77,10 +138,20 @@ function reportDuplicateNamespaces(moduleNamespaces, id, prefixes, reporter) {
77
138
 
78
139
  // src/resolve-extract.ts
79
140
  function resolveExtractModules(root, extract) {
141
+ let modules;
80
142
  if (extract?.modules !== void 0) {
81
- return extract.modules;
143
+ modules = [...extract.modules];
144
+ } else {
145
+ modules = discoverDefaultExtractModules(root);
146
+ }
147
+ let registeredModule = extract?.registeredComponentsModule;
148
+ if (!registeredModule && extract?.include === "allRegisteredComponents") {
149
+ registeredModule = discoverRegisteredComponentsModule(root);
150
+ }
151
+ if (registeredModule && !modules.includes(registeredModule)) {
152
+ modules.push(registeredModule);
82
153
  }
83
- return discoverDefaultExtractModules(root);
154
+ return modules;
84
155
  }
85
156
  function resolveExtractMode(explicitMode, resolvedModules) {
86
157
  return explicitMode ?? (resolvedModules.length > 0 ? "build" : "runtime");
@@ -556,6 +627,7 @@ ${result.stderr || result.stdout || "unknown error"}`
556
627
  }
557
628
  export {
558
629
  DEFAULT_EXTRACT_MODULE_CANDIDATES,
630
+ DEFAULT_REGISTERED_COMPONENTS_MODULE_BASES,
559
631
  TYPESTYLES_IMPORT_RE,
560
632
  VerifyTypestylesBuildError,
561
633
  buildManifestV2,
@@ -563,9 +635,11 @@ export {
563
635
  createModuleLoader,
564
636
  discoverDefaultExtractModules,
565
637
  discoverNextAppRoutes,
638
+ discoverRegisteredComponentsModule,
566
639
  extractNamespaces,
567
640
  getRouteCss,
568
641
  isManifestV2,
642
+ moduleNeedsOverrideHmr,
569
643
  normalizeRoutePath,
570
644
  pageRelPathToRoutePath,
571
645
  readCssFile,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typestyles/build-runner",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Shared module execution utilities for typestyles build integrations",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -30,7 +30,7 @@
30
30
  "tsup": "^8.0.0",
31
31
  "typescript": "^5.4.0",
32
32
  "vitest": "^3.0.0",
33
- "typestyles": "0.8.2"
33
+ "typestyles": "0.25.0"
34
34
  },
35
35
  "license": "Apache-2.0",
36
36
  "repository": {