@10up/wp-vite-plugins 1.0.0-alpha.2 → 1.0.0-alpha.4
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/LICENSE +338 -0
- package/README.md +129 -53
- package/dist/index.d.ts +429 -244
- package/dist/index.js +4334 -2623
- package/dist/php/wp-boot/Page.php +803 -0
- package/dist/php/wp-boot/Pages.php +133 -0
- package/dist/php/wp-vite-dev-server/Bridge.php +507 -0
- package/dist/php/wp-vite-dev-server/HotFile.php +95 -0
- package/package.json +19 -46
- package/dist/build.d.ts +0 -13
- package/dist/build.js +0 -396
- package/dist/build.js.map +0 -1
- package/dist/cli.js +0 -550
- package/dist/cli.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/runner-WUYCS-nx.d.ts +0 -178
- package/dist/watch.d.ts +0 -12
- package/dist/watch.js +0 -381
- package/dist/watch.js.map +0 -1
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared internals for the `wp-vite` commands.
|
|
3
|
-
*
|
|
4
|
-
* `wp-vite build` and `wp-vite watch` are the same idea run two ways: take a
|
|
5
|
-
* dual-pass project (`vite build` for classic scripts, `vite build --mode
|
|
6
|
-
* modules` for Script Modules), clean the out dir once, then drive both passes
|
|
7
|
-
* — sequentially for a build, concurrently for a watch — as a single process
|
|
8
|
-
* with prefixed output and signal-clean shutdown.
|
|
9
|
-
*
|
|
10
|
-
* Everything they have in common lives here: out-dir cleaning, module-pass
|
|
11
|
-
* detection, Vite binary resolution, child spawning with line prefixing,
|
|
12
|
-
* signal forwarding, and argv parsing. The commands themselves are in
|
|
13
|
-
* `./build` and `./watch`.
|
|
14
|
-
*
|
|
15
|
-
* No Vite internals are used — the commands only shell out to the consuming
|
|
16
|
-
* package's own `vite` (or `vp`) binary.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/** The two Vite passes the commands can drive. */
|
|
20
|
-
type PassName = 'script' | 'modules';
|
|
21
|
-
/** Which command is driving the passes. Exposed to children as `WP_VITE_RUNNER`. */
|
|
22
|
-
type RunnerName = 'build' | 'watch';
|
|
23
|
-
/**
|
|
24
|
-
* Signals the commands forward. Spelled out rather than pulled from the
|
|
25
|
-
* ambient Node signal type, which this repo's ESLint config reports as an
|
|
26
|
-
* undefined global.
|
|
27
|
-
*/
|
|
28
|
-
type RunnerSignal = 'SIGINT' | 'SIGTERM';
|
|
29
|
-
/** Sink for prefixed child output. `process.stdout` satisfies it. */
|
|
30
|
-
interface OutputSink {
|
|
31
|
-
write(text: string): unknown;
|
|
32
|
-
}
|
|
33
|
-
/** Options shared by `build()` and `watch()`. */
|
|
34
|
-
interface RunnerOptions {
|
|
35
|
-
/** Package directory the passes run in. Default: `process.cwd()`. */
|
|
36
|
-
cwd?: string;
|
|
37
|
-
/**
|
|
38
|
-
* Directory cleaned once at startup. Must match `build.outDir` of the
|
|
39
|
-
* Vite config. Default: `'dist'`.
|
|
40
|
-
*/
|
|
41
|
-
outDir?: string;
|
|
42
|
-
/**
|
|
43
|
-
* Force the module pass on/off. When omitted, `detectModulePass` decides.
|
|
44
|
-
*/
|
|
45
|
-
modules?: boolean;
|
|
46
|
-
/** `--mode` value for the module pass. Default: `'modules'`. */
|
|
47
|
-
modulesMode?: string;
|
|
48
|
-
/**
|
|
49
|
-
* Binary to run. A bare name (`'vite'`, `'vp'`) is looked up in the
|
|
50
|
-
* nearest `node_modules/.bin`; a path is used as-is. When omitted, `vite`
|
|
51
|
-
* is preferred over `vp` (see `resolveViteBin`).
|
|
52
|
-
*/
|
|
53
|
-
bin?: string;
|
|
54
|
-
/** Extra arguments appended to both passes. */
|
|
55
|
-
args?: string[];
|
|
56
|
-
/** Skip the startup clean. Default: `false` (it cleans). */
|
|
57
|
-
clean?: boolean;
|
|
58
|
-
/** Install SIGINT/SIGTERM handlers on `process`. Default: `true`. */
|
|
59
|
-
handleSignals?: boolean;
|
|
60
|
-
/** Extra environment for the children. */
|
|
61
|
-
env?: Record<string, string | undefined>;
|
|
62
|
-
/** Output sinks. Default: `process.stdout` / `process.stderr`. */
|
|
63
|
-
stdout?: OutputSink;
|
|
64
|
-
stderr?: OutputSink;
|
|
65
|
-
/**
|
|
66
|
-
* Replaces the built-in argv (`DEFAULT_BUILD_ARGS` / `DEFAULT_WATCH_ARGS`)
|
|
67
|
-
* for every pass. Escape hatch for tests — it lets a stand-in child stand
|
|
68
|
-
* in for a real Vite invocation.
|
|
69
|
-
*/
|
|
70
|
-
buildArgs?: string[];
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Arguments every `wp-vite build` pass gets, before the pass-specific
|
|
74
|
-
* `--mode`.
|
|
75
|
-
*
|
|
76
|
-
* `--no-emptyOutDir` makes the runner's own one-time clean the single source
|
|
77
|
-
* of truth, so no pass can delete another's output no matter how the config
|
|
78
|
-
* sets `emptyOutDir`. `--no-clearScreen` keeps the second pass from erasing
|
|
79
|
-
* the first pass' summary.
|
|
80
|
-
*/
|
|
81
|
-
declare const DEFAULT_BUILD_ARGS: string[];
|
|
82
|
-
/**
|
|
83
|
-
* Arguments every `wp-vite watch` pass gets, before the pass-specific
|
|
84
|
-
* `--mode`.
|
|
85
|
-
*
|
|
86
|
-
* `--no-emptyOutDir` is what stops the script pass from wiping the module
|
|
87
|
-
* pass' chunks out of dist/ on every rebuild; it overrides `emptyOutDir: true`
|
|
88
|
-
* from the config file (verified on Vite 8). `--no-clearScreen` stops two
|
|
89
|
-
* watchers sharing one terminal from clearing each other's output.
|
|
90
|
-
*/
|
|
91
|
-
declare const DEFAULT_WATCH_ARGS: string[];
|
|
92
|
-
/** Binary names tried, in order, when `bin` is not given. */
|
|
93
|
-
declare const BIN_CANDIDATES: readonly ["vite", "vp"];
|
|
94
|
-
interface ModulePassDetection {
|
|
95
|
-
modules: boolean;
|
|
96
|
-
/** Why — surfaced in the startup log so the heuristic is never a mystery. */
|
|
97
|
-
reason: string;
|
|
98
|
-
}
|
|
99
|
-
interface DetectModulePassOptions {
|
|
100
|
-
cwd?: string;
|
|
101
|
-
modulesMode?: string;
|
|
102
|
-
/** Explicit override; wins over every heuristic. */
|
|
103
|
-
modules?: boolean;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Decide whether this package has a module pass.
|
|
107
|
-
*
|
|
108
|
-
* The commands deliberately do not import the user's Vite config (top-level
|
|
109
|
-
* side effects) and cannot discover Script Module entries themselves — that
|
|
110
|
-
* needs `blocksDir` / `adminPagesDir`, which only the config knows. So they
|
|
111
|
-
* use a cheap, predictable, read-only heuristic:
|
|
112
|
-
*
|
|
113
|
-
* 1. an explicit `modules` option (`--modules` / `--no-modules`) wins;
|
|
114
|
-
* 2. a `package.json` script whose command contains `--mode <modulesMode>`;
|
|
115
|
-
* 3. a Vite config file whose source text contains the mode as a string
|
|
116
|
-
* literal (`mode === 'modules'`, `'modules'` in a map, …).
|
|
117
|
-
*
|
|
118
|
-
* Everything else means "script pass only".
|
|
119
|
-
*/
|
|
120
|
-
declare function detectModulePass(options?: DetectModulePassOptions): ModulePassDetection;
|
|
121
|
-
interface ResolvedBin {
|
|
122
|
-
/** Binary name, or the raw value when an explicit path was given. */
|
|
123
|
-
name: string;
|
|
124
|
-
/** What gets handed to `spawn`. */
|
|
125
|
-
path: string;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Find the Vite CLI the consuming package would use.
|
|
129
|
-
*
|
|
130
|
-
* Walks `node_modules/.bin` from `cwd` upwards, so workspace packages find a
|
|
131
|
-
* hoisted binary at the monorepo root. `vite` is preferred over `vp`: plain
|
|
132
|
-
* Vite is present in every setup (Vite+ installs it too) and `vp build`'s
|
|
133
|
-
* extra orchestration buys these commands nothing. Packages that need `vp` —
|
|
134
|
-
* for its caching or remote-cache layer — pass `--bin vp`.
|
|
135
|
-
*/
|
|
136
|
-
declare function resolveViteBin(cwd?: string, candidates?: readonly string[]): ResolvedBin;
|
|
137
|
-
/**
|
|
138
|
-
* Remove `outDir` — once, before any pass runs. Returns the absolute path that
|
|
139
|
-
* was cleaned.
|
|
140
|
-
*/
|
|
141
|
-
declare function cleanOutDir(outDir?: string, cwd?: string): Promise<string>;
|
|
142
|
-
interface LinePrefixer {
|
|
143
|
-
/** Feed a (possibly partial) chunk of child output. */
|
|
144
|
-
write(chunk: string): void;
|
|
145
|
-
/** Emit a trailing line that never got its newline. */
|
|
146
|
-
flush(): void;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Prefix child output line by line. Chunks arrive on arbitrary boundaries, so
|
|
150
|
-
* a partial trailing line is buffered until its newline shows up.
|
|
151
|
-
*
|
|
152
|
-
* Two cosmetic rules keep interleaved passes readable: blank lines pass
|
|
153
|
-
* through unprefixed (Vite prints plenty, and `[script] ` alone is noise), and
|
|
154
|
-
* a line redrawn with carriage returns is reduced to what a terminal would
|
|
155
|
-
* actually show — the text after the last CR, minus the erase codes.
|
|
156
|
-
*/
|
|
157
|
-
declare function createLinePrefixer(prefix: string, write: (text: string) => void): LinePrefixer;
|
|
158
|
-
interface ParsedCliArgs {
|
|
159
|
-
command: string | undefined;
|
|
160
|
-
options: RunnerOptions;
|
|
161
|
-
help: boolean;
|
|
162
|
-
version: boolean;
|
|
163
|
-
/** Flags that are not recognised — the CLI reports these and exits 1. */
|
|
164
|
-
unknown: string[];
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Hand-rolled argv parser (no dependency). Supports:
|
|
168
|
-
*
|
|
169
|
-
* wp-vite <build|watch> [--out-dir dist] [--modules|--no-modules]
|
|
170
|
-
* [--modules-mode modules] [--bin vite|vp|<path>]
|
|
171
|
-
* [--no-clean] [--cwd <dir>] [-- <extra vite args>]
|
|
172
|
-
*
|
|
173
|
-
* `--flag=value` and `--flag value` are both accepted. Everything after a
|
|
174
|
-
* bare `--` is forwarded verbatim to both Vite passes.
|
|
175
|
-
*/
|
|
176
|
-
declare function parseCliArgs(argv: readonly string[]): ParsedCliArgs;
|
|
177
|
-
|
|
178
|
-
export { BIN_CANDIDATES as B, DEFAULT_BUILD_ARGS as D, type LinePrefixer as L, type ModulePassDetection as M, type OutputSink as O, type ParsedCliArgs as P, type RunnerOptions as R, DEFAULT_WATCH_ARGS as a, type DetectModulePassOptions as b, type PassName as c, type ResolvedBin as d, type RunnerName as e, type RunnerSignal as f, cleanOutDir as g, createLinePrefixer as h, detectModulePass as i, parseCliArgs as p, resolveViteBin as r };
|
package/dist/watch.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { R as RunnerOptions } from './runner-WUYCS-nx.js';
|
|
2
|
-
export { B as BIN_CANDIDATES, D as DEFAULT_BUILD_ARGS, a as DEFAULT_WATCH_ARGS, b as DetectModulePassOptions, L as LinePrefixer, M as ModulePassDetection, O as OutputSink, P as ParsedCliArgs, c as PassName, d as ResolvedBin, e as RunnerName, f as RunnerSignal, g as cleanOutDir, h as createLinePrefixer, i as detectModulePass, p as parseCliArgs, r as resolveViteBin } from './runner-WUYCS-nx.js';
|
|
3
|
-
|
|
4
|
-
/** Options for `watch()`. Identical to `build()`'s — see `RunnerOptions`. */
|
|
5
|
-
type WatchOptions = RunnerOptions;
|
|
6
|
-
/**
|
|
7
|
-
* Run the unified watcher. Resolves with the process exit code: `0` for a
|
|
8
|
-
* clean shutdown (SIGINT/SIGTERM), non-zero when a pass died unexpectedly.
|
|
9
|
-
*/
|
|
10
|
-
declare function watch(options?: WatchOptions): Promise<number>;
|
|
11
|
-
|
|
12
|
-
export { RunnerOptions, type WatchOptions, watch };
|
package/dist/watch.js
DELETED
|
@@ -1,381 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'child_process';
|
|
2
|
-
import { existsSync, readFileSync } from 'fs';
|
|
3
|
-
import { rm } from 'fs/promises';
|
|
4
|
-
import { resolve, join, parse, dirname, isAbsolute, sep } from 'path';
|
|
5
|
-
|
|
6
|
-
// src/runner.ts
|
|
7
|
-
var DEFAULT_BUILD_ARGS = ["build", "--no-emptyOutDir", "--no-clearScreen"];
|
|
8
|
-
var DEFAULT_WATCH_ARGS = ["build", "--watch", "--no-emptyOutDir", "--no-clearScreen"];
|
|
9
|
-
var BIN_CANDIDATES = ["vite", "vp"];
|
|
10
|
-
function spawnPass(options) {
|
|
11
|
-
const { pass, stdout, stderr } = options;
|
|
12
|
-
const child = spawn(options.bin, options.argv, {
|
|
13
|
-
cwd: options.cwd,
|
|
14
|
-
env: {
|
|
15
|
-
...process.env,
|
|
16
|
-
...options.env,
|
|
17
|
-
WP_VITE_RUNNER: options.runner,
|
|
18
|
-
WP_VITE_PASS: pass,
|
|
19
|
-
// Kept for the documented watch-only guard:
|
|
20
|
-
// `emptyOutDir: !isModulePass && !process.env.WP_VITE_UNIFIED_WATCH`.
|
|
21
|
-
...options.runner === "watch" ? { WP_VITE_UNIFIED_WATCH: "1" } : {}
|
|
22
|
-
},
|
|
23
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
24
|
-
// .cmd shims are not directly executable on Windows.
|
|
25
|
-
shell: process.platform === "win32"
|
|
26
|
-
});
|
|
27
|
-
const outPrefixer = createLinePrefixer(`[${pass}] `, (text) => stdout.write(text));
|
|
28
|
-
const errPrefixer = createLinePrefixer(`[${pass}] `, (text) => stderr.write(text));
|
|
29
|
-
child.stdout?.setEncoding("utf8");
|
|
30
|
-
child.stdout?.on("data", (chunk) => outPrefixer.write(chunk));
|
|
31
|
-
child.stderr?.setEncoding("utf8");
|
|
32
|
-
child.stderr?.on("data", (chunk) => errPrefixer.write(chunk));
|
|
33
|
-
const result = new Promise((settle) => {
|
|
34
|
-
let settled = false;
|
|
35
|
-
const finish = (passResult) => {
|
|
36
|
-
if (settled) return;
|
|
37
|
-
settled = true;
|
|
38
|
-
outPrefixer.flush();
|
|
39
|
-
errPrefixer.flush();
|
|
40
|
-
settle(passResult);
|
|
41
|
-
};
|
|
42
|
-
child.on("error", (error) => {
|
|
43
|
-
stderr.write(`[wp-vite] the ${pass} pass failed to start: ${error.message}
|
|
44
|
-
`);
|
|
45
|
-
finish({ pass, code: null, signal: null, error });
|
|
46
|
-
});
|
|
47
|
-
child.on("close", (code, signal) => finish({ pass, code, signal }));
|
|
48
|
-
});
|
|
49
|
-
return { pass, child, result };
|
|
50
|
-
}
|
|
51
|
-
function passArgs(base, pass, modulesMode, extra = []) {
|
|
52
|
-
return [...base, ...pass === "modules" ? ["--mode", modulesMode] : [], ...extra];
|
|
53
|
-
}
|
|
54
|
-
function forwardSignals(handler) {
|
|
55
|
-
const bound = ["SIGINT", "SIGTERM"].map(
|
|
56
|
-
(signal) => [signal, () => handler(signal)]
|
|
57
|
-
);
|
|
58
|
-
for (const [signal, listener] of bound) process.on(signal, listener);
|
|
59
|
-
return () => {
|
|
60
|
-
for (const [signal, listener] of bound) process.off(signal, listener);
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function describeExit(code, signal) {
|
|
64
|
-
if (signal) return `signal ${signal}`;
|
|
65
|
-
if (code === null) return "unknown cause";
|
|
66
|
-
return `exit code ${code}`;
|
|
67
|
-
}
|
|
68
|
-
var VITE_CONFIG_FILES = [
|
|
69
|
-
"vite.config.ts",
|
|
70
|
-
"vite.config.mts",
|
|
71
|
-
"vite.config.cts",
|
|
72
|
-
"vite.config.js",
|
|
73
|
-
"vite.config.mjs",
|
|
74
|
-
"vite.config.cjs"
|
|
75
|
-
];
|
|
76
|
-
function detectModulePass(options = {}) {
|
|
77
|
-
if (typeof options.modules === "boolean") {
|
|
78
|
-
return {
|
|
79
|
-
modules: options.modules,
|
|
80
|
-
reason: `explicit --${options.modules ? "modules" : "no-modules"} flag`
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
const cwd = resolve(options.cwd ?? process.cwd());
|
|
84
|
-
const modulesMode = options.modulesMode ?? "modules";
|
|
85
|
-
const escapedMode = escapeRegExp(modulesMode);
|
|
86
|
-
const scriptMatch = new RegExp(`(?:--mode[=\\s]+|(?:^|\\s)-m\\s+)${escapedMode}(?![\\w-])`);
|
|
87
|
-
const packageJson = readJson(join(cwd, "package.json"));
|
|
88
|
-
const scripts = packageJson?.scripts;
|
|
89
|
-
if (scripts && typeof scripts === "object") {
|
|
90
|
-
for (const [name, command] of Object.entries(scripts)) {
|
|
91
|
-
if (typeof command === "string" && scriptMatch.test(command)) {
|
|
92
|
-
return {
|
|
93
|
-
modules: true,
|
|
94
|
-
reason: `package.json script "${name}" runs --mode ${modulesMode}`
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const configMatch = new RegExp(`(['"\`])${escapedMode}\\1`);
|
|
100
|
-
for (const fileName of VITE_CONFIG_FILES) {
|
|
101
|
-
const filePath = join(cwd, fileName);
|
|
102
|
-
const source = readFileIfExists(filePath);
|
|
103
|
-
if (source === null) continue;
|
|
104
|
-
if (configMatch.test(source)) {
|
|
105
|
-
return { modules: true, reason: `${fileName} mentions the "${modulesMode}" mode` };
|
|
106
|
-
}
|
|
107
|
-
return {
|
|
108
|
-
modules: false,
|
|
109
|
-
reason: `${fileName} never mentions the "${modulesMode}" mode`
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
return {
|
|
113
|
-
modules: false,
|
|
114
|
-
reason: `no package.json script or Vite config mentions the "${modulesMode}" mode`
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function resolveViteBin(cwd = process.cwd(), candidates = BIN_CANDIDATES) {
|
|
118
|
-
const searched = [];
|
|
119
|
-
for (const binDir of nodeModulesBinDirs(cwd)) {
|
|
120
|
-
for (const name of candidates) {
|
|
121
|
-
for (const fileName of binFileNames(name)) {
|
|
122
|
-
const candidatePath = join(binDir, fileName);
|
|
123
|
-
searched.push(candidatePath);
|
|
124
|
-
if (existsSync(candidatePath)) return { name, path: candidatePath };
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
throw new Error(
|
|
129
|
-
`[wp-vite] could not find a Vite binary (${candidates.join(" or ")}) in any node_modules/.bin above ${cwd}. Install vite in the package, or pass --bin <name|path>. Looked at:
|
|
130
|
-
${searched.join("\n ")}`
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
function resolveBin(bin, cwd) {
|
|
134
|
-
if (!bin) return resolveViteBin(cwd).path;
|
|
135
|
-
if (isAbsolute(bin) || bin.includes("/") || bin.includes("\\")) return bin;
|
|
136
|
-
try {
|
|
137
|
-
return resolveViteBin(cwd, [bin]).path;
|
|
138
|
-
} catch {
|
|
139
|
-
return bin;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function nodeModulesBinDirs(from) {
|
|
143
|
-
const dirs = [];
|
|
144
|
-
let current = resolve(from);
|
|
145
|
-
const { root } = parse(current);
|
|
146
|
-
while (true) {
|
|
147
|
-
dirs.push(join(current, "node_modules", ".bin"));
|
|
148
|
-
if (current === root) break;
|
|
149
|
-
const parent = dirname(current);
|
|
150
|
-
if (parent === current) break;
|
|
151
|
-
current = parent;
|
|
152
|
-
}
|
|
153
|
-
return dirs;
|
|
154
|
-
}
|
|
155
|
-
function binFileNames(name) {
|
|
156
|
-
return process.platform === "win32" ? [`${name}.cmd`, name] : [name];
|
|
157
|
-
}
|
|
158
|
-
async function cleanOutDir(outDir = "dist", cwd = process.cwd()) {
|
|
159
|
-
const base = resolve(cwd);
|
|
160
|
-
const target = isAbsolute(outDir) ? resolve(outDir) : resolve(base, outDir);
|
|
161
|
-
if (target === parse(target).root || target === base || !target.startsWith(base + sep)) {
|
|
162
|
-
throw new Error(
|
|
163
|
-
`[wp-vite] refusing to clean ${target}: the out dir must be inside ${base}`
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
await rm(target, { recursive: true, force: true });
|
|
167
|
-
return target;
|
|
168
|
-
}
|
|
169
|
-
var ESCAPE = String.fromCharCode(27);
|
|
170
|
-
var ERASE_SEQUENCE = new RegExp(`^(?:${ESCAPE}\\[[0-2]?[KJ])+`);
|
|
171
|
-
function createLinePrefixer(prefix, write) {
|
|
172
|
-
let buffer = "";
|
|
173
|
-
const emit = (line) => {
|
|
174
|
-
const withoutCrlf = line.endsWith("\r") ? line.slice(0, -1) : line;
|
|
175
|
-
const rendered = withoutCrlf.split("\r").pop() ?? "";
|
|
176
|
-
const content = rendered.replace(ERASE_SEQUENCE, "");
|
|
177
|
-
write(content.length === 0 ? "\n" : `${prefix}${content}
|
|
178
|
-
`);
|
|
179
|
-
};
|
|
180
|
-
return {
|
|
181
|
-
write(chunk) {
|
|
182
|
-
buffer += chunk;
|
|
183
|
-
const lines = buffer.split("\n");
|
|
184
|
-
buffer = lines.pop() ?? "";
|
|
185
|
-
for (const line of lines) emit(line);
|
|
186
|
-
},
|
|
187
|
-
flush() {
|
|
188
|
-
if (buffer.length === 0) return;
|
|
189
|
-
const pending = buffer;
|
|
190
|
-
buffer = "";
|
|
191
|
-
emit(pending);
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
function parseCliArgs(argv) {
|
|
196
|
-
const parsed = {
|
|
197
|
-
command: void 0,
|
|
198
|
-
options: {},
|
|
199
|
-
help: false,
|
|
200
|
-
version: false,
|
|
201
|
-
unknown: []
|
|
202
|
-
};
|
|
203
|
-
const passthrough = [];
|
|
204
|
-
let index = 0;
|
|
205
|
-
for (; index < argv.length; index += 1) {
|
|
206
|
-
const arg = argv[index];
|
|
207
|
-
if (arg === "--") {
|
|
208
|
-
passthrough.push(...argv.slice(index + 1));
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
if (!arg.startsWith("-")) {
|
|
212
|
-
if (parsed.command === void 0) parsed.command = arg;
|
|
213
|
-
else parsed.unknown.push(arg);
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
const equalsAt = arg.indexOf("=");
|
|
217
|
-
const flag = equalsAt === -1 ? arg : arg.slice(0, equalsAt);
|
|
218
|
-
const inlineValue = equalsAt === -1 ? void 0 : arg.slice(equalsAt + 1);
|
|
219
|
-
const takeValue = () => {
|
|
220
|
-
if (inlineValue !== void 0) return inlineValue;
|
|
221
|
-
const next = argv[index + 1];
|
|
222
|
-
if (next === void 0 || next.startsWith("-")) return void 0;
|
|
223
|
-
index += 1;
|
|
224
|
-
return next;
|
|
225
|
-
};
|
|
226
|
-
switch (flag) {
|
|
227
|
-
case "-h":
|
|
228
|
-
case "--help":
|
|
229
|
-
parsed.help = true;
|
|
230
|
-
break;
|
|
231
|
-
case "-v":
|
|
232
|
-
case "--version":
|
|
233
|
-
parsed.version = true;
|
|
234
|
-
break;
|
|
235
|
-
case "--out-dir":
|
|
236
|
-
case "--outDir": {
|
|
237
|
-
const value = takeValue();
|
|
238
|
-
if (value === void 0) parsed.unknown.push(`${flag} (missing value)`);
|
|
239
|
-
else parsed.options.outDir = value;
|
|
240
|
-
break;
|
|
241
|
-
}
|
|
242
|
-
case "--modules-mode":
|
|
243
|
-
case "--modulesMode": {
|
|
244
|
-
const value = takeValue();
|
|
245
|
-
if (value === void 0) parsed.unknown.push(`${flag} (missing value)`);
|
|
246
|
-
else parsed.options.modulesMode = value;
|
|
247
|
-
break;
|
|
248
|
-
}
|
|
249
|
-
case "--bin": {
|
|
250
|
-
const value = takeValue();
|
|
251
|
-
if (value === void 0) parsed.unknown.push(`${flag} (missing value)`);
|
|
252
|
-
else parsed.options.bin = value;
|
|
253
|
-
break;
|
|
254
|
-
}
|
|
255
|
-
case "--cwd": {
|
|
256
|
-
const value = takeValue();
|
|
257
|
-
if (value === void 0) parsed.unknown.push(`${flag} (missing value)`);
|
|
258
|
-
else parsed.options.cwd = value;
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
case "--modules":
|
|
262
|
-
parsed.options.modules = true;
|
|
263
|
-
break;
|
|
264
|
-
case "--no-modules":
|
|
265
|
-
parsed.options.modules = false;
|
|
266
|
-
break;
|
|
267
|
-
case "--clean":
|
|
268
|
-
parsed.options.clean = true;
|
|
269
|
-
break;
|
|
270
|
-
case "--no-clean":
|
|
271
|
-
parsed.options.clean = false;
|
|
272
|
-
break;
|
|
273
|
-
default:
|
|
274
|
-
parsed.unknown.push(flag);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
if (passthrough.length > 0) parsed.options.args = passthrough;
|
|
278
|
-
return parsed;
|
|
279
|
-
}
|
|
280
|
-
async function prepareRun(options, runner) {
|
|
281
|
-
const cwd = resolve(options.cwd ?? process.cwd());
|
|
282
|
-
const outDir = options.outDir ?? "dist";
|
|
283
|
-
const modulesMode = options.modulesMode ?? "modules";
|
|
284
|
-
const stdout = options.stdout ?? process.stdout;
|
|
285
|
-
const stderr = options.stderr ?? process.stderr;
|
|
286
|
-
const bin = resolveBin(options.bin, cwd);
|
|
287
|
-
const detection = detectModulePass({ cwd, modulesMode, modules: options.modules });
|
|
288
|
-
const passes = detection.modules ? ["script", "modules"] : ["script"];
|
|
289
|
-
if (options.clean !== false) {
|
|
290
|
-
const cleaned = await cleanOutDir(outDir, cwd);
|
|
291
|
-
stdout.write(`[wp-vite] cleaned ${cleaned}
|
|
292
|
-
`);
|
|
293
|
-
}
|
|
294
|
-
stdout.write(
|
|
295
|
-
`[wp-vite] module pass ${detection.modules ? "enabled" : "disabled"} \u2014 ${detection.reason}; ${"watching" } ${passes.join(" + " )} via ${bin}
|
|
296
|
-
`
|
|
297
|
-
);
|
|
298
|
-
return { cwd, bin, modulesMode, passes, stdout, stderr };
|
|
299
|
-
}
|
|
300
|
-
function escapeRegExp(value) {
|
|
301
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
302
|
-
}
|
|
303
|
-
function readFileIfExists(filePath) {
|
|
304
|
-
try {
|
|
305
|
-
return readFileSync(filePath, "utf8");
|
|
306
|
-
} catch {
|
|
307
|
-
return null;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
function readJson(filePath) {
|
|
311
|
-
const source = readFileIfExists(filePath);
|
|
312
|
-
if (source === null) return null;
|
|
313
|
-
try {
|
|
314
|
-
return JSON.parse(source);
|
|
315
|
-
} catch {
|
|
316
|
-
return null;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
// src/watch.ts
|
|
321
|
-
async function watch(options = {}) {
|
|
322
|
-
const { cwd, bin, modulesMode, passes, stdout, stderr } = await prepareRun(options);
|
|
323
|
-
const children = [];
|
|
324
|
-
let shuttingDown = false;
|
|
325
|
-
let exitCode = 0;
|
|
326
|
-
const shutdown = (signal) => {
|
|
327
|
-
shuttingDown = true;
|
|
328
|
-
for (const child of children) {
|
|
329
|
-
if (child.exitCode === null && child.signalCode === null) child.kill(signal);
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
const disposeSignals = options.handleSignals === false ? () => {
|
|
333
|
-
} : forwardSignals((signal) => {
|
|
334
|
-
if (shuttingDown) return;
|
|
335
|
-
exitCode = 0;
|
|
336
|
-
shutdown(signal);
|
|
337
|
-
});
|
|
338
|
-
const spawned = passes.map(
|
|
339
|
-
(pass) => spawnPass({
|
|
340
|
-
pass,
|
|
341
|
-
runner: "watch",
|
|
342
|
-
bin,
|
|
343
|
-
cwd,
|
|
344
|
-
argv: passArgs(
|
|
345
|
-
options.buildArgs ?? DEFAULT_WATCH_ARGS,
|
|
346
|
-
pass,
|
|
347
|
-
modulesMode,
|
|
348
|
-
options.args ?? []
|
|
349
|
-
),
|
|
350
|
-
env: options.env,
|
|
351
|
-
stdout,
|
|
352
|
-
stderr
|
|
353
|
-
})
|
|
354
|
-
);
|
|
355
|
-
children.push(...spawned.map(({ child }) => child));
|
|
356
|
-
let running = spawned.length;
|
|
357
|
-
try {
|
|
358
|
-
await Promise.all(
|
|
359
|
-
spawned.map(async ({ pass, result }) => {
|
|
360
|
-
const passResult = await result;
|
|
361
|
-
running -= 1;
|
|
362
|
-
if (shuttingDown) return;
|
|
363
|
-
const unexpected = passResult.error != null || passResult.code === null || passResult.code !== 0 || running > 0;
|
|
364
|
-
if (!unexpected) return;
|
|
365
|
-
exitCode = passResult.code && passResult.code !== 0 ? passResult.code : 1;
|
|
366
|
-
stderr.write(
|
|
367
|
-
`[wp-vite] the ${pass} pass exited unexpectedly (${describeExit(passResult.code, passResult.signal)}) \u2014 stopping
|
|
368
|
-
`
|
|
369
|
-
);
|
|
370
|
-
shutdown("SIGTERM");
|
|
371
|
-
})
|
|
372
|
-
);
|
|
373
|
-
return exitCode;
|
|
374
|
-
} finally {
|
|
375
|
-
disposeSignals();
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
export { BIN_CANDIDATES, DEFAULT_BUILD_ARGS, DEFAULT_WATCH_ARGS, cleanOutDir, createLinePrefixer, detectModulePass, parseCliArgs, resolveViteBin, watch };
|
|
380
|
-
//# sourceMappingURL=watch.js.map
|
|
381
|
-
//# sourceMappingURL=watch.js.map
|
package/dist/watch.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runner.ts","../src/watch.ts"],"names":["parsePath"],"mappings":";;;;;;AAyFO,IAAM,kBAAA,GAAqB,CAAC,OAAA,EAAS,kBAAA,EAAoB,kBAAkB;AAW3E,IAAM,kBAAA,GAAqB,CAAC,OAAA,EAAS,SAAA,EAAW,oBAAoB,kBAAkB;AAGtF,IAAM,cAAA,GAAiB,CAAC,MAAA,EAAQ,IAAI;AAqCpC,SAAS,UAAU,OAAA,EAAwC;AACjE,EAAA,MAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,MAAA,EAAO,GAAI,OAAA;AAEjC,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,OAAA,CAAQ,GAAA,EAAK,QAAQ,IAAA,EAAM;AAAA,IAC9C,KAAK,OAAA,CAAQ,GAAA;AAAA,IACb,GAAA,EAAK;AAAA,MACJ,GAAG,OAAA,CAAQ,GAAA;AAAA,MACX,GAAG,OAAA,CAAQ,GAAA;AAAA,MACX,gBAAgB,OAAA,CAAQ,MAAA;AAAA,MACxB,YAAA,EAAc,IAAA;AAAA;AAAA;AAAA,MAGd,GAAI,QAAQ,MAAA,KAAW,OAAA,GAAU,EAAE,qBAAA,EAAuB,GAAA,KAAQ;AAAC,KACpE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AAA,IAAS,IAAA,IACpB,UAAA,CAAW,SAAS,IAAA,IACpB,UAAA,CAAW,IAAA,KAAS,CAAA,IACpB,OAAA,GAAU,CAAA;AACX,QAAA,IAAI,CAAC,UAAA,EAAY;AACjB,QAAA,QAAA,GAAW,WAAW,IAAA,IAAQ,UAAA,CAAW,IAAA,KAAS,CAAA,GAAI,WAAW,IAAA,GAAO,CAAA;AACxE,QAAA,MAAA,CAAO,KAAA;AAAA,UACN,CAAA,cAAA,EAAiB,IAAI,CAAA,2BAAA,EAChB,YAAA,CAAa,WAAW,IAAA,EAAM,UAAA,CAAW,MAAM,CAAC,CAAA;AAAA;AAAA,SACtD;AACA,QAAA,QAAA,CAAS,SAAS,CAAA;AAAA,MACnB,CAAC;AAAA,KACF;AACA,IAAA,OAAO,QAAA;AAAA,EACR,CAAA,SAAE;AACD,IAAA,cAAA,EAAe;AAAA,EAChB;AACD","file":"watch.js","sourcesContent":["/**\n * Shared internals for the `wp-vite` commands.\n *\n * `wp-vite build` and `wp-vite watch` are the same idea run two ways: take a\n * dual-pass project (`vite build` for classic scripts, `vite build --mode\n * modules` for Script Modules), clean the out dir once, then drive both passes\n * — sequentially for a build, concurrently for a watch — as a single process\n * with prefixed output and signal-clean shutdown.\n *\n * Everything they have in common lives here: out-dir cleaning, module-pass\n * detection, Vite binary resolution, child spawning with line prefixing,\n * signal forwarding, and argv parsing. The commands themselves are in\n * `./build` and `./watch`.\n *\n * No Vite internals are used — the commands only shell out to the consuming\n * package's own `vite` (or `vp`) binary.\n */\nimport { spawn, type ChildProcess } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { dirname, isAbsolute, join, parse as parsePath, resolve, sep } from 'node:path';\n\n/** The two Vite passes the commands can drive. */\nexport type PassName = 'script' | 'modules';\n\n/** Which command is driving the passes. Exposed to children as `WP_VITE_RUNNER`. */\nexport type RunnerName = 'build' | 'watch';\n\n/**\n * Signals the commands forward. Spelled out rather than pulled from the\n * ambient Node signal type, which this repo's ESLint config reports as an\n * undefined global.\n */\nexport type RunnerSignal = 'SIGINT' | 'SIGTERM';\n\n/** Sink for prefixed child output. `process.stdout` satisfies it. */\nexport interface OutputSink {\n\twrite(text: string): unknown;\n}\n\n/** Options shared by `build()` and `watch()`. */\nexport interface RunnerOptions {\n\t/** Package directory the passes run in. Default: `process.cwd()`. */\n\tcwd?: string;\n\t/**\n\t * Directory cleaned once at startup. Must match `build.outDir` of the\n\t * Vite config. Default: `'dist'`.\n\t */\n\toutDir?: string;\n\t/**\n\t * Force the module pass on/off. When omitted, `detectModulePass` decides.\n\t */\n\tmodules?: boolean;\n\t/** `--mode` value for the module pass. Default: `'modules'`. */\n\tmodulesMode?: string;\n\t/**\n\t * Binary to run. A bare name (`'vite'`, `'vp'`) is looked up in the\n\t * nearest `node_modules/.bin`; a path is used as-is. When omitted, `vite`\n\t * is preferred over `vp` (see `resolveViteBin`).\n\t */\n\tbin?: string;\n\t/** Extra arguments appended to both passes. */\n\targs?: string[];\n\t/** Skip the startup clean. Default: `false` (it cleans). */\n\tclean?: boolean;\n\t/** Install SIGINT/SIGTERM handlers on `process`. Default: `true`. */\n\thandleSignals?: boolean;\n\t/** Extra environment for the children. */\n\tenv?: Record<string, string | undefined>;\n\t/** Output sinks. Default: `process.stdout` / `process.stderr`. */\n\tstdout?: OutputSink;\n\tstderr?: OutputSink;\n\t/**\n\t * Replaces the built-in argv (`DEFAULT_BUILD_ARGS` / `DEFAULT_WATCH_ARGS`)\n\t * for every pass. Escape hatch for tests — it lets a stand-in child stand\n\t * in for a real Vite invocation.\n\t */\n\tbuildArgs?: string[];\n}\n\n/**\n * Arguments every `wp-vite build` pass gets, before the pass-specific\n * `--mode`.\n *\n * `--no-emptyOutDir` makes the runner's own one-time clean the single source\n * of truth, so no pass can delete another's output no matter how the config\n * sets `emptyOutDir`. `--no-clearScreen` keeps the second pass from erasing\n * the first pass' summary.\n */\nexport const DEFAULT_BUILD_ARGS = ['build', '--no-emptyOutDir', '--no-clearScreen'];\n\n/**\n * Arguments every `wp-vite watch` pass gets, before the pass-specific\n * `--mode`.\n *\n * `--no-emptyOutDir` is what stops the script pass from wiping the module\n * pass' chunks out of dist/ on every rebuild; it overrides `emptyOutDir: true`\n * from the config file (verified on Vite 8). `--no-clearScreen` stops two\n * watchers sharing one terminal from clearing each other's output.\n */\nexport const DEFAULT_WATCH_ARGS = ['build', '--watch', '--no-emptyOutDir', '--no-clearScreen'];\n\n/** Binary names tried, in order, when `bin` is not given. */\nexport const BIN_CANDIDATES = ['vite', 'vp'] as const;\n\n/** How a pass ended. */\nexport interface PassResult {\n\tpass: PassName;\n\tcode: number | null;\n\tsignal: string | null;\n\t/** Set when the binary could not be spawned at all. */\n\terror?: Error;\n}\n\nexport interface SpawnPassOptions {\n\tpass: PassName;\n\t/** Which command is driving — surfaced to the child as `WP_VITE_RUNNER`. */\n\trunner: RunnerName;\n\tbin: string;\n\targv: string[];\n\tcwd: string;\n\tenv?: Record<string, string | undefined>;\n\tstdout: OutputSink;\n\tstderr: OutputSink;\n}\n\nexport interface SpawnedPass {\n\tpass: PassName;\n\tchild: ChildProcess;\n\t/** Resolves once the child is gone *and* its output has been flushed. */\n\tresult: Promise<PassResult>;\n}\n\n/**\n * Spawn one pass with its output prefixed (`[script] ` / `[modules] `).\n *\n * The child gets `WP_VITE_RUNNER` and `WP_VITE_PASS` so a Vite config can tell\n * it is being driven by `wp-vite`, plus `WP_VITE_UNIFIED_WATCH=1` for the\n * watch command specifically (the documented `emptyOutDir` guard).\n */\nexport function spawnPass(options: SpawnPassOptions): SpawnedPass {\n\tconst { pass, stdout, stderr } = options;\n\n\tconst child = spawn(options.bin, options.argv, {\n\t\tcwd: options.cwd,\n\t\tenv: {\n\t\t\t...process.env,\n\t\t\t...options.env,\n\t\t\tWP_VITE_RUNNER: options.runner,\n\t\t\tWP_VITE_PASS: pass,\n\t\t\t// Kept for the documented watch-only guard:\n\t\t\t// `emptyOutDir: !isModulePass && !process.env.WP_VITE_UNIFIED_WATCH`.\n\t\t\t...(options.runner === 'watch' ? { WP_VITE_UNIFIED_WATCH: '1' } : {}),\n\t\t},\n\t\tstdio: ['ignore', 'pipe', 'pipe'],\n\t\t// .cmd shims are not directly executable on Windows.\n\t\tshell: process.platform === 'win32',\n\t});\n\n\tconst outPrefixer = createLinePrefixer(`[${pass}] `, (text) => stdout.write(text));\n\tconst errPrefixer = createLinePrefixer(`[${pass}] `, (text) => stderr.write(text));\n\tchild.stdout?.setEncoding('utf8');\n\tchild.stdout?.on('data', (chunk: string) => outPrefixer.write(chunk));\n\tchild.stderr?.setEncoding('utf8');\n\tchild.stderr?.on('data', (chunk: string) => errPrefixer.write(chunk));\n\n\tconst result = new Promise<PassResult>((settle) => {\n\t\tlet settled = false;\n\t\tconst finish = (passResult: PassResult) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\toutPrefixer.flush();\n\t\t\terrPrefixer.flush();\n\t\t\tsettle(passResult);\n\t\t};\n\t\tchild.on('error', (error: Error) => {\n\t\t\tstderr.write(`[wp-vite] the ${pass} pass failed to start: ${error.message}\\n`);\n\t\t\tfinish({ pass, code: null, signal: null, error });\n\t\t});\n\t\tchild.on('close', (code, signal) => finish({ pass, code, signal }));\n\t});\n\n\treturn { pass, child, result };\n}\n\n/** Full argv for a pass: base args, then `--mode` for the module pass, then passthrough. */\nexport function passArgs(\n\tbase: readonly string[],\n\tpass: PassName,\n\tmodulesMode: string,\n\textra: readonly string[] = [],\n): string[] {\n\treturn [...base, ...(pass === 'modules' ? ['--mode', modulesMode] : []), ...extra];\n}\n\n/**\n * Register SIGINT/SIGTERM handlers that call `handler` with the signal that\n * fired. Returns a disposer.\n *\n * One bound handler per signal: the forwarded signal comes from the binding,\n * not from the event argument (which is absent when a test or a wrapper emits\n * the event by hand).\n */\nexport function forwardSignals(handler: (signal: RunnerSignal) => void): () => void {\n\tconst bound: Array<[RunnerSignal, () => void]> = (['SIGINT', 'SIGTERM'] as RunnerSignal[]).map(\n\t\t(signal) => [signal, () => handler(signal)],\n\t);\n\tfor (const [signal, listener] of bound) process.on(signal, listener);\n\treturn () => {\n\t\tfor (const [signal, listener] of bound) process.off(signal, listener);\n\t};\n}\n\n/** Human-readable cause of a child exit. */\nexport function describeExit(code: number | null, signal: string | null): string {\n\tif (signal) return `signal ${signal}`;\n\tif (code === null) return 'unknown cause';\n\treturn `exit code ${code}`;\n}\n\n/** Shell convention: a process killed by signal N reports `128 + N`. */\nconst SIGNAL_EXIT_CODES: Record<string, number> = {\n\tSIGINT: 130,\n\tSIGTERM: 143,\n\tSIGHUP: 129,\n\tSIGQUIT: 131,\n};\n\n/** Exit code for a signalled death: `128 + signo`, or `1` for anything unmapped. */\nexport function signalExitCode(signal: string | null): number {\n\tif (!signal) return 1;\n\treturn SIGNAL_EXIT_CODES[signal] ?? 1;\n}\n\n/** The exit code a pass result should produce. `0` only for a clean exit. */\nexport function passExitCode(result: PassResult): number {\n\tif (result.error) return 1;\n\tif (result.code !== null) return result.code;\n\treturn signalExitCode(result.signal);\n}\n\nexport interface ModulePassDetection {\n\tmodules: boolean;\n\t/** Why — surfaced in the startup log so the heuristic is never a mystery. */\n\treason: string;\n}\n\nexport interface DetectModulePassOptions {\n\tcwd?: string;\n\tmodulesMode?: string;\n\t/** Explicit override; wins over every heuristic. */\n\tmodules?: boolean;\n}\n\n/** Config file names probed for the module mode string, nearest-first. */\nconst VITE_CONFIG_FILES = [\n\t'vite.config.ts',\n\t'vite.config.mts',\n\t'vite.config.cts',\n\t'vite.config.js',\n\t'vite.config.mjs',\n\t'vite.config.cjs',\n];\n\n/**\n * Decide whether this package has a module pass.\n *\n * The commands deliberately do not import the user's Vite config (top-level\n * side effects) and cannot discover Script Module entries themselves — that\n * needs `blocksDir` / `adminPagesDir`, which only the config knows. So they\n * use a cheap, predictable, read-only heuristic:\n *\n * 1. an explicit `modules` option (`--modules` / `--no-modules`) wins;\n * 2. a `package.json` script whose command contains `--mode <modulesMode>`;\n * 3. a Vite config file whose source text contains the mode as a string\n * literal (`mode === 'modules'`, `'modules'` in a map, …).\n *\n * Everything else means \"script pass only\".\n */\nexport function detectModulePass(options: DetectModulePassOptions = {}): ModulePassDetection {\n\tif (typeof options.modules === 'boolean') {\n\t\treturn {\n\t\t\tmodules: options.modules,\n\t\t\treason: `explicit --${options.modules ? 'modules' : 'no-modules'} flag`,\n\t\t};\n\t}\n\n\tconst cwd = resolve(options.cwd ?? process.cwd());\n\tconst modulesMode = options.modulesMode ?? 'modules';\n\tconst escapedMode = escapeRegExp(modulesMode);\n\n\tconst scriptMatch = new RegExp(`(?:--mode[=\\\\s]+|(?:^|\\\\s)-m\\\\s+)${escapedMode}(?![\\\\w-])`);\n\tconst packageJson = readJson(join(cwd, 'package.json'));\n\tconst scripts = packageJson?.scripts;\n\tif (scripts && typeof scripts === 'object') {\n\t\tfor (const [name, command] of Object.entries(scripts as Record<string, unknown>)) {\n\t\t\tif (typeof command === 'string' && scriptMatch.test(command)) {\n\t\t\t\treturn {\n\t\t\t\t\tmodules: true,\n\t\t\t\t\treason: `package.json script \"${name}\" runs --mode ${modulesMode}`,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\tconst configMatch = new RegExp(`(['\"\\`])${escapedMode}\\\\1`);\n\tfor (const fileName of VITE_CONFIG_FILES) {\n\t\tconst filePath = join(cwd, fileName);\n\t\tconst source = readFileIfExists(filePath);\n\t\tif (source === null) continue;\n\t\tif (configMatch.test(source)) {\n\t\t\treturn { modules: true, reason: `${fileName} mentions the \"${modulesMode}\" mode` };\n\t\t}\n\t\t// The nearest config wins — don't keep probing alternate extensions.\n\t\treturn {\n\t\t\tmodules: false,\n\t\t\treason: `${fileName} never mentions the \"${modulesMode}\" mode`,\n\t\t};\n\t}\n\n\treturn {\n\t\tmodules: false,\n\t\treason: `no package.json script or Vite config mentions the \"${modulesMode}\" mode`,\n\t};\n}\n\nexport interface ResolvedBin {\n\t/** Binary name, or the raw value when an explicit path was given. */\n\tname: string;\n\t/** What gets handed to `spawn`. */\n\tpath: string;\n}\n\n/**\n * Find the Vite CLI the consuming package would use.\n *\n * Walks `node_modules/.bin` from `cwd` upwards, so workspace packages find a\n * hoisted binary at the monorepo root. `vite` is preferred over `vp`: plain\n * Vite is present in every setup (Vite+ installs it too) and `vp build`'s\n * extra orchestration buys these commands nothing. Packages that need `vp` —\n * for its caching or remote-cache layer — pass `--bin vp`.\n */\nexport function resolveViteBin(\n\tcwd: string = process.cwd(),\n\tcandidates: readonly string[] = BIN_CANDIDATES,\n): ResolvedBin {\n\tconst searched: string[] = [];\n\tfor (const binDir of nodeModulesBinDirs(cwd)) {\n\t\tfor (const name of candidates) {\n\t\t\tfor (const fileName of binFileNames(name)) {\n\t\t\t\tconst candidatePath = join(binDir, fileName);\n\t\t\t\tsearched.push(candidatePath);\n\t\t\t\tif (existsSync(candidatePath)) return { name, path: candidatePath };\n\t\t\t}\n\t\t}\n\t}\n\tthrow new Error(\n\t\t`[wp-vite] could not find a Vite binary (${candidates.join(' or ')}) in any ` +\n\t\t\t`node_modules/.bin above ${cwd}. Install vite in the package, or pass --bin <name|path>. ` +\n\t\t\t`Looked at:\\n ${searched.join('\\n ')}`,\n\t);\n}\n\n/** Resolve the `bin` option: a path is used as-is, a bare name is looked up. */\nexport function resolveBin(bin: string | undefined, cwd: string): string {\n\tif (!bin) return resolveViteBin(cwd).path;\n\tif (isAbsolute(bin) || bin.includes('/') || bin.includes('\\\\')) return bin;\n\ttry {\n\t\treturn resolveViteBin(cwd, [bin]).path;\n\t} catch {\n\t\t// Not in node_modules/.bin — let the OS resolve it from PATH.\n\t\treturn bin;\n\t}\n}\n\n/** Every `node_modules/.bin` from `from` up to the filesystem root. */\nfunction nodeModulesBinDirs(from: string): string[] {\n\tconst dirs: string[] = [];\n\tlet current = resolve(from);\n\tconst { root } = parsePath(current);\n\twhile (true) {\n\t\tdirs.push(join(current, 'node_modules', '.bin'));\n\t\tif (current === root) break;\n\t\tconst parent = dirname(current);\n\t\tif (parent === current) break;\n\t\tcurrent = parent;\n\t}\n\treturn dirs;\n}\n\n/** Windows shims first, then the POSIX name. */\nfunction binFileNames(name: string): string[] {\n\treturn process.platform === 'win32' ? [`${name}.cmd`, name] : [name];\n}\n\n/**\n * Remove `outDir` — once, before any pass runs. Returns the absolute path that\n * was cleaned.\n */\nexport async function cleanOutDir(outDir = 'dist', cwd: string = process.cwd()): Promise<string> {\n\tconst base = resolve(cwd);\n\tconst target = isAbsolute(outDir) ? resolve(outDir) : resolve(base, outDir);\n\t// Never let a stray `--out-dir ..` or `--out-dir /` delete the world.\n\tif (target === parsePath(target).root || target === base || !target.startsWith(base + sep)) {\n\t\tthrow new Error(\n\t\t\t`[wp-vite] refusing to clean ${target}: the out dir must be inside ${base}`,\n\t\t);\n\t}\n\tawait rm(target, { recursive: true, force: true });\n\treturn target;\n}\n\nexport interface LinePrefixer {\n\t/** Feed a (possibly partial) chunk of child output. */\n\twrite(chunk: string): void;\n\t/** Emit a trailing line that never got its newline. */\n\tflush(): void;\n}\n\n/** Leading erase-line/erase-display sequences left over from CR redraws. */\nconst ESCAPE = String.fromCharCode(27);\nconst ERASE_SEQUENCE = new RegExp(`^(?:${ESCAPE}\\\\[[0-2]?[KJ])+`);\n\n/**\n * Prefix child output line by line. Chunks arrive on arbitrary boundaries, so\n * a partial trailing line is buffered until its newline shows up.\n *\n * Two cosmetic rules keep interleaved passes readable: blank lines pass\n * through unprefixed (Vite prints plenty, and `[script] ` alone is noise), and\n * a line redrawn with carriage returns is reduced to what a terminal would\n * actually show — the text after the last CR, minus the erase codes.\n */\nexport function createLinePrefixer(prefix: string, write: (text: string) => void): LinePrefixer {\n\tlet buffer = '';\n\tconst emit = (line: string) => {\n\t\t// A trailing CR is just CRLF; earlier CRs are redraws of the same line.\n\t\tconst withoutCrlf = line.endsWith('\\r') ? line.slice(0, -1) : line;\n\t\tconst rendered = withoutCrlf.split('\\r').pop() ?? '';\n\t\tconst content = rendered.replace(ERASE_SEQUENCE, '');\n\t\twrite(content.length === 0 ? '\\n' : `${prefix}${content}\\n`);\n\t};\n\treturn {\n\t\twrite(chunk: string) {\n\t\t\tbuffer += chunk;\n\t\t\tconst lines = buffer.split('\\n');\n\t\t\tbuffer = lines.pop() ?? '';\n\t\t\tfor (const line of lines) emit(line);\n\t\t},\n\t\tflush() {\n\t\t\tif (buffer.length === 0) return;\n\t\t\tconst pending = buffer;\n\t\t\tbuffer = '';\n\t\t\temit(pending);\n\t\t},\n\t};\n}\n\nexport interface ParsedCliArgs {\n\tcommand: string | undefined;\n\toptions: RunnerOptions;\n\thelp: boolean;\n\tversion: boolean;\n\t/** Flags that are not recognised — the CLI reports these and exits 1. */\n\tunknown: string[];\n}\n\n/**\n * Hand-rolled argv parser (no dependency). Supports:\n *\n * wp-vite <build|watch> [--out-dir dist] [--modules|--no-modules]\n * [--modules-mode modules] [--bin vite|vp|<path>]\n * [--no-clean] [--cwd <dir>] [-- <extra vite args>]\n *\n * `--flag=value` and `--flag value` are both accepted. Everything after a\n * bare `--` is forwarded verbatim to both Vite passes.\n */\nexport function parseCliArgs(argv: readonly string[]): ParsedCliArgs {\n\tconst parsed: ParsedCliArgs = {\n\t\tcommand: undefined,\n\t\toptions: {},\n\t\thelp: false,\n\t\tversion: false,\n\t\tunknown: [],\n\t};\n\tconst passthrough: string[] = [];\n\tlet index = 0;\n\n\tfor (; index < argv.length; index += 1) {\n\t\tconst arg = argv[index];\n\n\t\tif (arg === '--') {\n\t\t\tpassthrough.push(...argv.slice(index + 1));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (!arg.startsWith('-')) {\n\t\t\tif (parsed.command === undefined) parsed.command = arg;\n\t\t\telse parsed.unknown.push(arg);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst equalsAt = arg.indexOf('=');\n\t\tconst flag = equalsAt === -1 ? arg : arg.slice(0, equalsAt);\n\t\tconst inlineValue = equalsAt === -1 ? undefined : arg.slice(equalsAt + 1);\n\t\tconst takeValue = (): string | undefined => {\n\t\t\tif (inlineValue !== undefined) return inlineValue;\n\t\t\tconst next = argv[index + 1];\n\t\t\tif (next === undefined || next.startsWith('-')) return undefined;\n\t\t\tindex += 1;\n\t\t\treturn next;\n\t\t};\n\n\t\tswitch (flag) {\n\t\t\tcase '-h':\n\t\t\tcase '--help':\n\t\t\t\tparsed.help = true;\n\t\t\t\tbreak;\n\t\t\tcase '-v':\n\t\t\tcase '--version':\n\t\t\t\tparsed.version = true;\n\t\t\t\tbreak;\n\t\t\tcase '--out-dir':\n\t\t\tcase '--outDir': {\n\t\t\t\tconst value = takeValue();\n\t\t\t\tif (value === undefined) parsed.unknown.push(`${flag} (missing value)`);\n\t\t\t\telse parsed.options.outDir = value;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase '--modules-mode':\n\t\t\tcase '--modulesMode': {\n\t\t\t\tconst value = takeValue();\n\t\t\t\tif (value === undefined) parsed.unknown.push(`${flag} (missing value)`);\n\t\t\t\telse parsed.options.modulesMode = value;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase '--bin': {\n\t\t\t\tconst value = takeValue();\n\t\t\t\tif (value === undefined) parsed.unknown.push(`${flag} (missing value)`);\n\t\t\t\telse parsed.options.bin = value;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase '--cwd': {\n\t\t\t\tconst value = takeValue();\n\t\t\t\tif (value === undefined) parsed.unknown.push(`${flag} (missing value)`);\n\t\t\t\telse parsed.options.cwd = value;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase '--modules':\n\t\t\t\tparsed.options.modules = true;\n\t\t\t\tbreak;\n\t\t\tcase '--no-modules':\n\t\t\t\tparsed.options.modules = false;\n\t\t\t\tbreak;\n\t\t\tcase '--clean':\n\t\t\t\tparsed.options.clean = true;\n\t\t\t\tbreak;\n\t\t\tcase '--no-clean':\n\t\t\t\tparsed.options.clean = false;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tparsed.unknown.push(flag);\n\t\t}\n\t}\n\n\tif (passthrough.length > 0) parsed.options.args = passthrough;\n\treturn parsed;\n}\n\n/**\n * Shared preamble: resolve the binary, decide on the module pass, clean the\n * out dir once, and log both decisions.\n */\nexport async function prepareRun(\n\toptions: RunnerOptions,\n\trunner: RunnerName,\n): Promise<{\n\tcwd: string;\n\tbin: string;\n\tmodulesMode: string;\n\tpasses: PassName[];\n\tstdout: OutputSink;\n\tstderr: OutputSink;\n}> {\n\tconst cwd = resolve(options.cwd ?? process.cwd());\n\tconst outDir = options.outDir ?? 'dist';\n\tconst modulesMode = options.modulesMode ?? 'modules';\n\tconst stdout = options.stdout ?? process.stdout;\n\tconst stderr = options.stderr ?? process.stderr;\n\n\tconst bin = resolveBin(options.bin, cwd);\n\tconst detection = detectModulePass({ cwd, modulesMode, modules: options.modules });\n\tconst passes: PassName[] = detection.modules ? ['script', 'modules'] : ['script'];\n\n\t// Cleaning here, once, is what lets every pass run with `--no-emptyOutDir`\n\t// and still start from an empty dist/.\n\tif (options.clean !== false) {\n\t\tconst cleaned = await cleanOutDir(outDir, cwd);\n\t\tstdout.write(`[wp-vite] cleaned ${cleaned}\\n`);\n\t}\n\n\tstdout.write(\n\t\t`[wp-vite] module pass ${detection.modules ? 'enabled' : 'disabled'} — ${detection.reason}; ` +\n\t\t\t`${runner === 'watch' ? 'watching' : 'building'} ${passes.join(runner === 'watch' ? ' + ' : ' then ')} via ${bin}\\n`,\n\t);\n\n\treturn { cwd, bin, modulesMode, passes, stdout, stderr };\n}\n\nfunction escapeRegExp(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nfunction readFileIfExists(filePath: string): string | null {\n\ttry {\n\t\treturn readFileSync(filePath, 'utf8');\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction readJson(filePath: string): Record<string, unknown> | null {\n\tconst source = readFileIfExists(filePath);\n\tif (source === null) return null;\n\ttry {\n\t\treturn JSON.parse(source) as Record<string, unknown>;\n\t} catch {\n\t\treturn null;\n\t}\n}\n","/**\n * `wp-vite watch` — one process that watches both passes of a dual-pass build.\n *\n * The dual-pass setup (`vite build` for classic scripts, `vite build --mode\n * modules` for Script Modules) has no single watch command: two `--watch`\n * processes fight over `dist/` because each pass empties the out dir on every\n * rebuild, and task runners (`turbo`, `vp run -r --parallel`) want exactly one\n * long-lived process per package.\n *\n * This command:\n * 1. cleans the out dir once, itself;\n * 2. spawns `<bin> build --watch --no-emptyOutDir --no-clearScreen`;\n * 3. spawns the same command with `--mode modules` when the package has a\n * module pass (see `detectModulePass`);\n * 4. prefixes every child line with `[script] ` / `[modules] `;\n * 5. forwards SIGINT/SIGTERM to both children;\n * 6. resolves non-zero as soon as either child dies unexpectedly.\n *\n * The one-shot counterpart is `build()` in `./build`; the machinery both share\n * lives in `./runner`.\n */\nimport type { ChildProcess } from 'node:child_process';\nimport {\n\tDEFAULT_WATCH_ARGS,\n\tdescribeExit,\n\tforwardSignals,\n\tpassArgs,\n\tprepareRun,\n\tspawnPass,\n\ttype PassName,\n\ttype RunnerOptions,\n\ttype RunnerSignal,\n} from './runner';\n\n/**\n * The shared surface both commands expose, so a consumer can reach the\n * helpers from either subpath. The spawning/sequencing plumbing in `./runner`\n * stays internal.\n */\nexport {\n\tBIN_CANDIDATES,\n\tDEFAULT_BUILD_ARGS,\n\tDEFAULT_WATCH_ARGS,\n\tcleanOutDir,\n\tcreateLinePrefixer,\n\tdetectModulePass,\n\tparseCliArgs,\n\tresolveViteBin,\n} from './runner';\nexport type {\n\tDetectModulePassOptions,\n\tLinePrefixer,\n\tModulePassDetection,\n\tOutputSink,\n\tParsedCliArgs,\n\tPassName,\n\tResolvedBin,\n\tRunnerName,\n\tRunnerOptions,\n\tRunnerSignal,\n} from './runner';\n\n/** Options for `watch()`. Identical to `build()`'s — see `RunnerOptions`. */\nexport type WatchOptions = RunnerOptions;\n\n/**\n * Run the unified watcher. Resolves with the process exit code: `0` for a\n * clean shutdown (SIGINT/SIGTERM), non-zero when a pass died unexpectedly.\n */\nexport async function watch(options: WatchOptions = {}): Promise<number> {\n\tconst { cwd, bin, modulesMode, passes, stdout, stderr } = await prepareRun(options, 'watch');\n\n\tconst children: ChildProcess[] = [];\n\tlet shuttingDown = false;\n\tlet exitCode = 0;\n\n\tconst shutdown = (signal: RunnerSignal) => {\n\t\tshuttingDown = true;\n\t\tfor (const child of children) {\n\t\t\tif (child.exitCode === null && child.signalCode === null) child.kill(signal);\n\t\t}\n\t};\n\n\tconst disposeSignals =\n\t\toptions.handleSignals === false\n\t\t\t? () => {}\n\t\t\t: forwardSignals((signal) => {\n\t\t\t\t\tif (shuttingDown) return;\n\t\t\t\t\texitCode = 0;\n\t\t\t\t\tshutdown(signal);\n\t\t\t\t});\n\n\tconst spawned = passes.map((pass: PassName) =>\n\t\tspawnPass({\n\t\t\tpass,\n\t\t\trunner: 'watch',\n\t\t\tbin,\n\t\t\tcwd,\n\t\t\targv: passArgs(\n\t\t\t\toptions.buildArgs ?? DEFAULT_WATCH_ARGS,\n\t\t\t\tpass,\n\t\t\t\tmodulesMode,\n\t\t\t\toptions.args ?? [],\n\t\t\t),\n\t\t\tenv: options.env,\n\t\t\tstdout,\n\t\t\tstderr,\n\t\t}),\n\t);\n\tchildren.push(...spawned.map(({ child }) => child));\n\n\tlet running = spawned.length;\n\ttry {\n\t\tawait Promise.all(\n\t\t\tspawned.map(async ({ pass, result }) => {\n\t\t\t\tconst passResult = await result;\n\t\t\t\trunning -= 1;\n\t\t\t\tif (shuttingDown) return;\n\t\t\t\t// A watcher that stops on its own is always unexpected while a\n\t\t\t\t// sibling is still running — even with exit code 0.\n\t\t\t\tconst unexpected =\n\t\t\t\t\tpassResult.error != null ||\n\t\t\t\t\tpassResult.code === null ||\n\t\t\t\t\tpassResult.code !== 0 ||\n\t\t\t\t\trunning > 0;\n\t\t\t\tif (!unexpected) return;\n\t\t\t\texitCode = passResult.code && passResult.code !== 0 ? passResult.code : 1;\n\t\t\t\tstderr.write(\n\t\t\t\t\t`[wp-vite] the ${pass} pass exited unexpectedly ` +\n\t\t\t\t\t\t`(${describeExit(passResult.code, passResult.signal)}) — stopping\\n`,\n\t\t\t\t);\n\t\t\t\tshutdown('SIGTERM');\n\t\t\t}),\n\t\t);\n\t\treturn exitCode;\n\t} finally {\n\t\tdisposeSignals();\n\t}\n}\n"]}
|