@typestyles/build-runner 0.0.0-unstable.6fa3e9bf6d93 → 0.0.0-unstable.74cb86313f08

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
@@ -20,12 +20,37 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ DEFAULT_EXTRACT_MODULE_CANDIDATES: () => DEFAULT_EXTRACT_MODULE_CANDIDATES,
24
+ discoverDefaultExtractModules: () => discoverDefaultExtractModules,
23
25
  runTypestylesBuild: () => runTypestylesBuild
24
26
  });
25
27
  module.exports = __toCommonJS(index_exports);
26
- var import_esbuild = require("esbuild");
28
+
29
+ // src/discover.ts
27
30
  var import_node_fs = require("fs");
28
31
  var import_node_path = require("path");
32
+ var DEFAULT_EXTRACT_MODULE_CANDIDATES = [
33
+ "src/typestyles-entry.ts",
34
+ "src/typestyles.ts",
35
+ "src/styles/index.ts",
36
+ "src/styles.ts",
37
+ "styles/typestyles-entry.ts",
38
+ "styles/typestyles.ts"
39
+ ];
40
+ function discoverDefaultExtractModules(root) {
41
+ const absRoot = (0, import_node_path.resolve)(root);
42
+ for (const rel of DEFAULT_EXTRACT_MODULE_CANDIDATES) {
43
+ if ((0, import_node_fs.existsSync)((0, import_node_path.resolve)(absRoot, rel))) {
44
+ return [rel.replace(/\\/g, "/")];
45
+ }
46
+ }
47
+ return [];
48
+ }
49
+
50
+ // src/index.ts
51
+ var import_esbuild = require("esbuild");
52
+ var import_node_fs2 = require("fs");
53
+ var import_node_path2 = require("path");
29
54
  var import_node_child_process = require("child_process");
30
55
  function toImportPath(modulePath) {
31
56
  const normalized = modulePath.replace(/\\/g, "/");
@@ -58,12 +83,12 @@ async function runTypestylesBuild({
58
83
  if (!bundledCode) {
59
84
  throw new Error("[typestyles] Failed to produce extraction bundle.");
60
85
  }
61
- const scriptPath = (0, import_node_path.resolve)(root, `.typestyles-extract-${process.pid}.cjs`);
86
+ const scriptPath = (0, import_node_path2.resolve)(root, `.typestyles-extract-${process.pid}.cjs`);
62
87
  const script = `${bundledCode}
63
88
  process.stdout.write(require('typestyles').getRegisteredCss());
64
89
  `;
65
90
  try {
66
- (0, import_node_fs.writeFileSync)(scriptPath, script, "utf8");
91
+ (0, import_node_fs2.writeFileSync)(scriptPath, script, "utf8");
67
92
  const result = (0, import_node_child_process.spawnSync)(process.execPath, [scriptPath], {
68
93
  cwd: root,
69
94
  encoding: "utf8",
@@ -80,9 +105,9 @@ ${result.stderr || result.stdout || "unknown error"}`
80
105
  }
81
106
  return result.stdout ?? "";
82
107
  } finally {
83
- if ((0, import_node_fs.existsSync)(scriptPath)) {
108
+ if ((0, import_node_fs2.existsSync)(scriptPath)) {
84
109
  try {
85
- (0, import_node_fs.unlinkSync)(scriptPath);
110
+ (0, import_node_fs2.unlinkSync)(scriptPath);
86
111
  } catch {
87
112
  }
88
113
  }
@@ -90,5 +115,7 @@ ${result.stderr || result.stdout || "unknown error"}`
90
115
  }
91
116
  // Annotate the CommonJS export names for ESM import in node:
92
117
  0 && (module.exports = {
118
+ DEFAULT_EXTRACT_MODULE_CANDIDATES,
119
+ discoverDefaultExtractModules,
93
120
  runTypestylesBuild
94
121
  });
package/dist/index.d.cts CHANGED
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Relative paths checked (in order) when no explicit extraction entry is configured.
3
+ * Shared by `@typestyles/vite` and `@typestyles/next/build` so defaults stay aligned.
4
+ *
5
+ * Includes `styles/…` paths after `src/…` because many Next.js apps use a top-level `styles`
6
+ * folder instead of `src/`.
7
+ */
8
+ declare const DEFAULT_EXTRACT_MODULE_CANDIDATES: readonly ["src/typestyles-entry.ts", "src/typestyles.ts", "src/styles/index.ts", "src/styles.ts", "styles/typestyles-entry.ts", "styles/typestyles.ts"];
9
+ /**
10
+ * Resolve the default extraction module when the user did not pass explicit `modules`.
11
+ * Returns at most one path using `/` separators, relative to `root`.
12
+ */
13
+ declare function discoverDefaultExtractModules(root: string): string[];
14
+
1
15
  interface RunTypestylesBuildOptions {
2
16
  /**
3
17
  * Project root used to resolve extraction entry modules.
@@ -16,4 +30,4 @@ interface RunTypestylesBuildOptions {
16
30
  */
17
31
  declare function runTypestylesBuild({ root, modules, }: RunTypestylesBuildOptions): Promise<string>;
18
32
 
19
- export { type RunTypestylesBuildOptions, runTypestylesBuild };
33
+ export { DEFAULT_EXTRACT_MODULE_CANDIDATES, type RunTypestylesBuildOptions, discoverDefaultExtractModules, runTypestylesBuild };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Relative paths checked (in order) when no explicit extraction entry is configured.
3
+ * Shared by `@typestyles/vite` and `@typestyles/next/build` so defaults stay aligned.
4
+ *
5
+ * Includes `styles/…` paths after `src/…` because many Next.js apps use a top-level `styles`
6
+ * folder instead of `src/`.
7
+ */
8
+ declare const DEFAULT_EXTRACT_MODULE_CANDIDATES: readonly ["src/typestyles-entry.ts", "src/typestyles.ts", "src/styles/index.ts", "src/styles.ts", "styles/typestyles-entry.ts", "styles/typestyles.ts"];
9
+ /**
10
+ * Resolve the default extraction module when the user did not pass explicit `modules`.
11
+ * Returns at most one path using `/` separators, relative to `root`.
12
+ */
13
+ declare function discoverDefaultExtractModules(root: string): string[];
14
+
1
15
  interface RunTypestylesBuildOptions {
2
16
  /**
3
17
  * Project root used to resolve extraction entry modules.
@@ -16,4 +30,4 @@ interface RunTypestylesBuildOptions {
16
30
  */
17
31
  declare function runTypestylesBuild({ root, modules, }: RunTypestylesBuildOptions): Promise<string>;
18
32
 
19
- export { type RunTypestylesBuildOptions, runTypestylesBuild };
33
+ export { DEFAULT_EXTRACT_MODULE_CANDIDATES, type RunTypestylesBuildOptions, discoverDefaultExtractModules, runTypestylesBuild };
package/dist/index.js CHANGED
@@ -1,6 +1,27 @@
1
+ // src/discover.ts
2
+ import { existsSync } from "fs";
3
+ import { resolve as resolvePath } from "path";
4
+ var DEFAULT_EXTRACT_MODULE_CANDIDATES = [
5
+ "src/typestyles-entry.ts",
6
+ "src/typestyles.ts",
7
+ "src/styles/index.ts",
8
+ "src/styles.ts",
9
+ "styles/typestyles-entry.ts",
10
+ "styles/typestyles.ts"
11
+ ];
12
+ function discoverDefaultExtractModules(root) {
13
+ const absRoot = resolvePath(root);
14
+ for (const rel of DEFAULT_EXTRACT_MODULE_CANDIDATES) {
15
+ if (existsSync(resolvePath(absRoot, rel))) {
16
+ return [rel.replace(/\\/g, "/")];
17
+ }
18
+ }
19
+ return [];
20
+ }
21
+
1
22
  // src/index.ts
2
23
  import { build as esbuildBuild } from "esbuild";
3
- import { existsSync, unlinkSync, writeFileSync } from "fs";
24
+ import { existsSync as existsSync2, unlinkSync, writeFileSync } from "fs";
4
25
  import { resolve } from "path";
5
26
  import { spawnSync } from "child_process";
6
27
  function toImportPath(modulePath) {
@@ -56,7 +77,7 @@ ${result.stderr || result.stdout || "unknown error"}`
56
77
  }
57
78
  return result.stdout ?? "";
58
79
  } finally {
59
- if (existsSync(scriptPath)) {
80
+ if (existsSync2(scriptPath)) {
60
81
  try {
61
82
  unlinkSync(scriptPath);
62
83
  } catch {
@@ -65,5 +86,7 @@ ${result.stderr || result.stdout || "unknown error"}`
65
86
  }
66
87
  }
67
88
  export {
89
+ DEFAULT_EXTRACT_MODULE_CANDIDATES,
90
+ discoverDefaultExtractModules,
68
91
  runTypestylesBuild
69
92
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typestyles/build-runner",
3
- "version": "0.0.0-unstable.6fa3e9bf6d93",
3
+ "version": "0.0.0-unstable.74cb86313f08",
4
4
  "description": "Shared module execution utilities for typestyles build integrations",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",