@vwala/tooling-config 1.7.0 → 1.7.1

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.
@@ -108,7 +108,7 @@ Use the helper's sequenced watch mode, with a package script for alias rewriting
108
108
  pnpm exec compile-react-library --project tsconfig.build.json --format esm --watch --after build:finish
109
109
  ```
110
110
 
111
- `build:finish` must finish before the next rebuild starts. The watch helper owns TypeScript emission too; do not start `tsc --watch` alongside it. Compiler-on/off comparisons use the same helper and post-build script.
111
+ `build:finish` must finish before the next rebuild starts. The watch helper owns TypeScript emission too; do not start `tsc --watch` alongside it. Compiler-on/off comparisons use the same helper and post-build script. `compile-react-library` also runs on Windows, where stopping a watch build force-stops the whole build process tree with `taskkill /T /F`.
112
112
 
113
113
  The watcher observes TypeScript sources and the selected build tsconfig. Restart it after changing an inherited tsconfig outside the package. The helper preserves the configured JSX runtime and maps; it does not add JavaScript downlevel transforms for older runtime targets. A contradictory `.mts`/CommonJS or `.cts`/ESM request fails explicitly.
114
114
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vwala/tooling-config",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "type": "module",
5
5
  "description": "Shared tooling configuration for Vwala repositories",
6
6
  "license": "MIT",
@@ -42,6 +42,7 @@
42
42
  "@babel/traverse": "7.29.8",
43
43
  "babel-plugin-react-compiler": "1.0.0",
44
44
  "commitlint-config-gitmoji": "^2.3.1",
45
+ "cross-spawn": "7.0.6",
45
46
  "jsonc-parser": "3.3.1"
46
47
  },
47
48
  "scripts": {
@@ -1,4 +1,27 @@
1
- import { spawn } from "node:child_process";
1
+ import { spawnSync } from "node:child_process";
2
+ import spawn from "cross-spawn";
3
+
4
+ const isWindows = process.platform === "win32";
5
+
6
+ function stopProcessTree(pid) {
7
+ if (isWindows) {
8
+ const result = spawnSync("taskkill", ["/pid", String(pid), "/T", "/F"], {
9
+ stdio: "ignore",
10
+ windowsHide: true,
11
+ });
12
+ if (result.error) {
13
+ throw result.error;
14
+ }
15
+ return;
16
+ }
17
+ try {
18
+ process.kill(-pid, "SIGTERM");
19
+ } catch (error) {
20
+ if (error.code !== "ESRCH") {
21
+ throw error;
22
+ }
23
+ }
24
+ }
2
25
 
3
26
  /** Own one sequential build command and its descendant process lifetime. */
4
27
  export function createBuildCommandProcess() {
@@ -12,8 +35,9 @@ export function createBuildCommandProcess() {
12
35
  return new Promise((resolve, reject) => {
13
36
  const child = spawn("pnpm", args, {
14
37
  cwd,
15
- detached: true,
38
+ detached: !isWindows,
16
39
  stdio: ["ignore", "pipe", "pipe"],
40
+ windowsHide: true,
17
41
  });
18
42
  active = child;
19
43
  let stdout = "";
@@ -45,13 +69,7 @@ export function createBuildCommandProcess() {
45
69
  stop() {
46
70
  stopped = true;
47
71
  if (active?.pid) {
48
- try {
49
- process.kill(-active.pid, "SIGTERM");
50
- } catch (error) {
51
- if (error.code !== "ESRCH") {
52
- throw error;
53
- }
54
- }
72
+ stopProcessTree(active.pid);
55
73
  }
56
74
  },
57
75
  };
@@ -1,17 +1,15 @@
1
- import { execFileSync } from "node:child_process";
2
1
  import path from "node:path";
2
+ import { runPnpmSync } from "./run-pnpm-sync.mjs";
3
3
 
4
4
  export function readBuildProject(projectPath) {
5
5
  const configPath = path.resolve(projectPath);
6
6
  const directory = path.dirname(configPath);
7
- const config = JSON.parse(
8
- execFileSync(
9
- "pnpm",
10
- ["exec", "tsc", "--project", configPath, "--showConfig"],
11
- { cwd: directory, encoding: "utf8" },
12
- ),
7
+ const { compilerOptions: options, files } = JSON.parse(
8
+ runPnpmSync({
9
+ args: ["exec", "tsc", "--project", configPath, "--showConfig"],
10
+ cwd: directory,
11
+ }),
13
12
  );
14
- const { compilerOptions: options, files } = config;
15
13
  if (!options.rootDir || !options.outDir) {
16
14
  throw new Error(
17
15
  "React library builds require explicit rootDir and outDir in the build tsconfig.",
@@ -0,0 +1,23 @@
1
+ import spawn from "cross-spawn";
2
+
3
+ export function runPnpmSync({ args, cwd }) {
4
+ const result = spawn.sync("pnpm", args, {
5
+ cwd,
6
+ encoding: "utf8",
7
+ windowsHide: true,
8
+ });
9
+ if (result.stderr) {
10
+ process.stderr.write(result.stderr);
11
+ }
12
+ if (result.error) {
13
+ throw result.error;
14
+ }
15
+ if (result.status !== 0) {
16
+ const message = `Command failed: pnpm ${args.join(" ")}`;
17
+ throw Object.assign(
18
+ new Error(result.stderr ? `${message}\n${result.stderr}` : message),
19
+ { stdout: result.stdout, stderr: result.stderr },
20
+ );
21
+ }
22
+ return result.stdout;
23
+ }