@ttsc/unplugin 0.30.2 → 0.30.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/lib/bun.js +3 -16
- package/lib/bun.js.map +1 -1
- package/lib/bun.mjs +3 -16
- package/lib/bun.mjs.map +1 -1
- package/lib/core/esbuild.d.cts +4 -0
- package/lib/core/esbuild.d.mts +4 -0
- package/lib/core/esbuild.d.ts +4 -0
- package/lib/core/esbuild.js +110 -0
- package/lib/core/esbuild.js.map +1 -0
- package/lib/core/esbuild.mjs +108 -0
- package/lib/core/esbuild.mjs.map +1 -0
- package/lib/core/index.js +49 -89
- package/lib/core/index.js.map +1 -1
- package/lib/core/index.mjs +50 -90
- package/lib/core/index.mjs.map +1 -1
- package/lib/core/transform.d.cts +5 -3
- package/lib/core/transform.d.mts +5 -3
- package/lib/core/transform.d.ts +5 -3
- package/lib/core/transform.js +25 -25
- package/lib/core/transform.js.map +1 -1
- package/lib/core/transform.mjs +25 -25
- package/lib/core/transform.mjs.map +1 -1
- package/lib/core/viteServe.d.cts +16 -38
- package/lib/core/viteServe.d.mts +16 -38
- package/lib/core/viteServe.d.ts +16 -38
- package/lib/core/viteServe.js +234 -98
- package/lib/core/viteServe.js.map +1 -1
- package/lib/core/viteServe.mjs +235 -98
- package/lib/core/viteServe.mjs.map +1 -1
- package/package.json +4 -3
- package/src/bun.ts +2 -17
- package/src/core/esbuild.ts +127 -0
- package/src/core/index.ts +51 -100
- package/src/core/transform.ts +30 -28
- package/src/core/viteServe.ts +275 -164
package/lib/core/viteServe.mjs
CHANGED
|
@@ -1,135 +1,272 @@
|
|
|
1
|
+
import { watch } from 'chokidar';
|
|
1
2
|
import fs from 'node:fs';
|
|
2
3
|
import path from 'node:path';
|
|
3
|
-
import { validateGraphInputObservation, pathIdentityKey } from './transform.mjs';
|
|
4
|
+
import { captureWatchInputBaseline, validateGraphInputObservation, watchInputEvidenceMatchesBaseline, pathIdentityKey } from './transform.mjs';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
-
* milliseconds.
|
|
7
|
+
* One filesystem subscription per unique input, shared by all served modules.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* server
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* Vite resolves transform-context addWatchFile as a runtime import, including
|
|
10
|
+
* type-only .server files and non-module plugin assets. Use a separate watcher
|
|
11
|
+
* for compiler inputs, including node_modules, which Vite's watcher ignores.
|
|
12
|
+
* Ordinary files use events after their initial subscription is observed.
|
|
13
|
+
* Missing spellings and directory predicates keep a shared predicate poll.
|
|
14
|
+
* Linked files also share topology checks by directory because retargeting a
|
|
15
|
+
* junction need not emit events on its previously watched descendants.
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
-
/** Create an empty missing-input watch for one plugin instance. */
|
|
18
|
-
function createViteServeMissingInputWatch() {
|
|
17
|
+
function createViteServeInputWatch() {
|
|
19
18
|
const entries = new Map();
|
|
20
|
-
|
|
19
|
+
const importerInputs = new Map();
|
|
20
|
+
const pending = new Set();
|
|
21
|
+
const links = new Map();
|
|
21
22
|
let server;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
let watcher;
|
|
24
|
+
let poller;
|
|
25
|
+
let flushTimer;
|
|
26
|
+
let failed = false;
|
|
27
|
+
const remove = (entry) => {
|
|
28
|
+
entries.delete(entry.file);
|
|
29
|
+
watcher?.unwatch(entry.file);
|
|
30
|
+
for (const file of entry.links) {
|
|
31
|
+
const link = links.get(file);
|
|
32
|
+
link?.inputs.delete(entry);
|
|
33
|
+
if (link?.inputs.size === 0)
|
|
34
|
+
links.delete(file);
|
|
25
35
|
}
|
|
26
|
-
clearInterval(poller);
|
|
27
|
-
poller = undefined;
|
|
28
36
|
};
|
|
29
|
-
const
|
|
37
|
+
const check = (selected) => {
|
|
30
38
|
const importers = new Set();
|
|
31
|
-
for (const
|
|
32
|
-
if (
|
|
39
|
+
for (const entry of selected) {
|
|
40
|
+
if (entries.get(entry.file) !== entry)
|
|
33
41
|
continue;
|
|
42
|
+
let baseline;
|
|
43
|
+
for (const [key, condition] of entry.conditions) {
|
|
44
|
+
const state = condition.evidence?.state;
|
|
45
|
+
let changed;
|
|
46
|
+
if (state?.codec === "predicates") {
|
|
47
|
+
changed =
|
|
48
|
+
validateGraphInputObservation(entry.file, state.observation)
|
|
49
|
+
.length !== 0;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
baseline ??= captureWatchInputBaseline(entry.file);
|
|
53
|
+
changed =
|
|
54
|
+
baseline === undefined ||
|
|
55
|
+
(condition.evidence?.state !== undefined
|
|
56
|
+
? !watchInputEvidenceMatchesBaseline(condition.evidence, baseline)
|
|
57
|
+
: JSON.stringify(condition.baseline) !==
|
|
58
|
+
JSON.stringify(baseline));
|
|
59
|
+
}
|
|
60
|
+
if (!changed)
|
|
61
|
+
continue;
|
|
62
|
+
for (const importer of condition.importers)
|
|
63
|
+
importers.add(importer);
|
|
64
|
+
entry.conditions.delete(key);
|
|
34
65
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
importers.add(importer);
|
|
66
|
+
if (entry.conditions.size === 0) {
|
|
67
|
+
remove(entry);
|
|
38
68
|
}
|
|
39
69
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
70
|
+
if (server !== undefined && importers.size !== 0) {
|
|
71
|
+
invalidateImporters(server, importers);
|
|
72
|
+
sendFullReload(server);
|
|
43
73
|
}
|
|
44
|
-
|
|
45
|
-
|
|
74
|
+
};
|
|
75
|
+
const enqueue = (file, observed) => {
|
|
76
|
+
const absolute = path.resolve(file);
|
|
77
|
+
const direct = entries.get(absolute);
|
|
78
|
+
if (direct !== undefined && observed)
|
|
79
|
+
direct.observed = true;
|
|
80
|
+
for (const candidate of [absolute, path.dirname(absolute)]) {
|
|
81
|
+
const entry = entries.get(candidate);
|
|
82
|
+
if (entry !== undefined)
|
|
83
|
+
pending.add(entry);
|
|
84
|
+
}
|
|
85
|
+
if (pending.size === 0 || flushTimer !== undefined)
|
|
86
|
+
return;
|
|
87
|
+
flushTimer = setTimeout(() => {
|
|
88
|
+
flushTimer = undefined;
|
|
89
|
+
const selected = [...pending];
|
|
90
|
+
pending.clear();
|
|
91
|
+
check(selected);
|
|
92
|
+
}, 0);
|
|
93
|
+
flushTimer.unref();
|
|
94
|
+
};
|
|
95
|
+
const ensureWatcher = () => {
|
|
96
|
+
if (watcher !== undefined)
|
|
97
|
+
return watcher;
|
|
98
|
+
// Chokidar's persistent:false backend omits its native error listener on
|
|
99
|
+
// Windows. Keep the owned subscription alive until dispose() closes it.
|
|
100
|
+
const active = watch([], { depth: 0, ignoreInitial: false });
|
|
101
|
+
watcher = active;
|
|
102
|
+
// Initial add events compare compiler-time evidence too: an edit between
|
|
103
|
+
// compilation and asynchronous watcher setup must not be missed.
|
|
104
|
+
active.on("all", (event, file) => {
|
|
105
|
+
if (watcher === active)
|
|
106
|
+
enqueue(file, event === "add" || event === "addDir");
|
|
107
|
+
});
|
|
108
|
+
active.on("error", () => {
|
|
109
|
+
if (watcher === active)
|
|
110
|
+
failed = true;
|
|
111
|
+
});
|
|
112
|
+
poller = setInterval(() => {
|
|
113
|
+
const selected = new Set([...entries.values()].filter((entry) => failed || entry.poll || !entry.observed));
|
|
114
|
+
// Files reached through one linked directory share one topology check.
|
|
115
|
+
// Content edits remain event-driven; retargeting a junction does not
|
|
116
|
+
// reliably emit an event on its previously watched descendants.
|
|
117
|
+
for (const [file, link] of links) {
|
|
118
|
+
const target = realpath(file);
|
|
119
|
+
if (target !== link.target) {
|
|
120
|
+
link.target = target;
|
|
121
|
+
for (const entry of link.inputs) {
|
|
122
|
+
selected.add(entry);
|
|
123
|
+
entry.observed = false;
|
|
124
|
+
active.unwatch(entry.file);
|
|
125
|
+
active.add(entry.file);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
check(selected);
|
|
130
|
+
}, 500);
|
|
131
|
+
poller.unref();
|
|
132
|
+
return watcher;
|
|
46
133
|
};
|
|
47
134
|
return {
|
|
48
135
|
attach(next) {
|
|
49
136
|
server = next;
|
|
50
137
|
},
|
|
51
|
-
dispose() {
|
|
138
|
+
async dispose() {
|
|
52
139
|
entries.clear();
|
|
53
|
-
|
|
140
|
+
importerInputs.clear();
|
|
141
|
+
pending.clear();
|
|
142
|
+
links.clear();
|
|
143
|
+
if (poller !== undefined)
|
|
54
144
|
clearInterval(poller);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
serving() {
|
|
65
|
-
return server !== undefined;
|
|
145
|
+
if (flushTimer !== undefined)
|
|
146
|
+
clearTimeout(flushTimer);
|
|
147
|
+
poller = undefined;
|
|
148
|
+
flushTimer = undefined;
|
|
149
|
+
const closing = watcher;
|
|
150
|
+
watcher = undefined;
|
|
151
|
+
failed = false;
|
|
152
|
+
await closing?.close();
|
|
153
|
+
// Retain the attached server across overlapping Vite restart containers.
|
|
66
154
|
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const identity = viteServeMissingInputWatchKey(spelling, condition);
|
|
70
|
-
const existing = entries.get(identity);
|
|
71
|
-
if (existing !== undefined) {
|
|
72
|
-
existing.importers.add(path.resolve(importer));
|
|
155
|
+
replace(importer, inputs, failed = false) {
|
|
156
|
+
if (server === undefined)
|
|
73
157
|
return;
|
|
158
|
+
importer = path.resolve(importer);
|
|
159
|
+
const previous = importerInputs.get(importer) ?? new Map();
|
|
160
|
+
if (failed) {
|
|
161
|
+
// An exception can omit the dependency whose deletion caused it.
|
|
162
|
+
// Keep the last successful spellings until a successful delivery can
|
|
163
|
+
// replace them, observing their current failed state for recovery.
|
|
164
|
+
const reported = new Set(inputs.map((input) => path.resolve(input.file)));
|
|
165
|
+
inputs = [
|
|
166
|
+
...inputs,
|
|
167
|
+
...[...previous.keys()]
|
|
168
|
+
.filter((file) => !reported.has(file))
|
|
169
|
+
.map((file) => ({ file })),
|
|
170
|
+
];
|
|
74
171
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
172
|
+
const current = new Map();
|
|
173
|
+
const added = [];
|
|
174
|
+
for (const input of inputs) {
|
|
175
|
+
const file = path.resolve(input.file);
|
|
176
|
+
const evidence = input.evidence;
|
|
177
|
+
const key = JSON.stringify(evidence ?? null);
|
|
178
|
+
current.set(file, key);
|
|
179
|
+
let entry = entries.get(file);
|
|
180
|
+
if (entry === undefined) {
|
|
181
|
+
entry = {
|
|
182
|
+
file,
|
|
183
|
+
conditions: new Map(),
|
|
184
|
+
poll: false,
|
|
185
|
+
observed: false,
|
|
186
|
+
links: new Set(),
|
|
187
|
+
};
|
|
188
|
+
entries.set(file, entry);
|
|
189
|
+
added.push(file);
|
|
190
|
+
const directory = path.dirname(file);
|
|
191
|
+
const directoryTarget = realpath(directory);
|
|
192
|
+
const fileTarget = realpath(file);
|
|
193
|
+
const linked = [
|
|
194
|
+
...(directoryTarget !== undefined &&
|
|
195
|
+
!sameSpelling(directory, directoryTarget)
|
|
196
|
+
? [directory]
|
|
197
|
+
: []),
|
|
198
|
+
...(fileTarget !== undefined &&
|
|
199
|
+
directoryTarget !== undefined &&
|
|
200
|
+
!sameSpelling(fileTarget, path.join(directoryTarget, path.basename(file)))
|
|
201
|
+
? [file]
|
|
202
|
+
: []),
|
|
203
|
+
];
|
|
204
|
+
for (const linkedFile of linked) {
|
|
205
|
+
let link = links.get(linkedFile);
|
|
206
|
+
if (link === undefined) {
|
|
207
|
+
link = { target: realpath(linkedFile), inputs: new Set() };
|
|
208
|
+
links.set(linkedFile, link);
|
|
209
|
+
}
|
|
210
|
+
link.inputs.add(entry);
|
|
211
|
+
entry.links.add(linkedFile);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
let condition = entry.conditions.get(key);
|
|
215
|
+
if (condition === undefined) {
|
|
216
|
+
condition = {
|
|
217
|
+
evidence,
|
|
218
|
+
baseline: evidence?.state === undefined
|
|
219
|
+
? captureWatchInputBaseline(file)
|
|
220
|
+
: undefined,
|
|
221
|
+
importers: new Set(),
|
|
222
|
+
};
|
|
223
|
+
entry.conditions.set(key, condition);
|
|
224
|
+
}
|
|
225
|
+
condition.importers.add(importer);
|
|
226
|
+
const observation = evidence?.state?.codec === "predicates"
|
|
227
|
+
? evidence.state.observation
|
|
228
|
+
: undefined;
|
|
229
|
+
entry.poll ||=
|
|
230
|
+
evidence?.missing === true ||
|
|
231
|
+
evidence?.unavailable !== undefined ||
|
|
232
|
+
(observation !== undefined &&
|
|
233
|
+
observation.fileExists !== true &&
|
|
234
|
+
observation.stat !== "file" &&
|
|
235
|
+
observation.readFile?.ok !== true) ||
|
|
236
|
+
(evidence?.state === undefined &&
|
|
237
|
+
condition.baseline?.fileExists !== true);
|
|
84
238
|
}
|
|
239
|
+
for (const [file, key] of previous) {
|
|
240
|
+
if (current.get(file) === key)
|
|
241
|
+
continue;
|
|
242
|
+
const entry = entries.get(file);
|
|
243
|
+
const condition = entry?.conditions.get(key);
|
|
244
|
+
condition?.importers.delete(importer);
|
|
245
|
+
if (condition?.importers.size === 0)
|
|
246
|
+
entry?.conditions.delete(key);
|
|
247
|
+
if (entry?.conditions.size === 0 && !current.has(file)) {
|
|
248
|
+
remove(entry);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
importerInputs.set(importer, current);
|
|
252
|
+
if (added.length !== 0)
|
|
253
|
+
ensureWatcher().add(added);
|
|
85
254
|
},
|
|
86
255
|
};
|
|
87
256
|
}
|
|
88
|
-
|
|
89
|
-
function viteServeMissingInputWatchKey(input, condition) {
|
|
90
|
-
// Missing aliases can share a physical parent now and later retarget or
|
|
91
|
-
// diverge. Neither predicate may let one lexical spelling answer for another.
|
|
92
|
-
const predicate = typeof condition === "string"
|
|
93
|
-
? condition
|
|
94
|
-
: `predicates:${JSON.stringify([
|
|
95
|
-
condition.accessibleEntries === undefined
|
|
96
|
-
? null
|
|
97
|
-
: [
|
|
98
|
-
condition.accessibleEntries.directories,
|
|
99
|
-
condition.accessibleEntries.files,
|
|
100
|
-
],
|
|
101
|
-
condition.directoryExists ?? null,
|
|
102
|
-
condition.fileExists ?? null,
|
|
103
|
-
condition.readFile === undefined
|
|
104
|
-
? null
|
|
105
|
-
: condition.readFile.ok
|
|
106
|
-
? [true, condition.readFile.hash]
|
|
107
|
-
: [false],
|
|
108
|
-
condition.realpath === undefined
|
|
109
|
-
? null
|
|
110
|
-
: condition.realpath.ok
|
|
111
|
-
? [true, condition.realpath.path]
|
|
112
|
-
: [false],
|
|
113
|
-
condition.stat ?? null,
|
|
114
|
-
])}`;
|
|
115
|
-
return `${predicate}:${path.resolve(input)}`;
|
|
116
|
-
}
|
|
117
|
-
/** Whether one registered condition no longer describes its lexical path. */
|
|
118
|
-
function viteServeInputWatchConditionChanged(entry) {
|
|
119
|
-
if (typeof entry.condition !== "string") {
|
|
120
|
-
return (validateGraphInputObservation(entry.spelling, entry.condition).length !==
|
|
121
|
-
0);
|
|
122
|
-
}
|
|
257
|
+
function realpath(file) {
|
|
123
258
|
try {
|
|
124
|
-
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
return (entry.condition === "exists" || !fs.statSync(entry.spelling).isDirectory());
|
|
259
|
+
return fs.realpathSync.native(file);
|
|
128
260
|
}
|
|
129
261
|
catch {
|
|
130
|
-
return
|
|
262
|
+
return undefined;
|
|
131
263
|
}
|
|
132
264
|
}
|
|
265
|
+
function sameSpelling(left, right) {
|
|
266
|
+
return process.platform === "win32"
|
|
267
|
+
? left.toLowerCase() === right.toLowerCase()
|
|
268
|
+
: left === right;
|
|
269
|
+
}
|
|
133
270
|
/**
|
|
134
271
|
* Invalidate every module-graph node of the registered importers so the next
|
|
135
272
|
* request retransforms them. Importers keep their original absolute spelling so
|
|
@@ -214,5 +351,5 @@ function sendFullReload(server) {
|
|
|
214
351
|
}
|
|
215
352
|
}
|
|
216
353
|
|
|
217
|
-
export {
|
|
354
|
+
export { createViteServeInputWatch };
|
|
218
355
|
//# sourceMappingURL=viteServe.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viteServe.mjs","sources":["../../src/core/viteServe.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAMA;;;;;;;;;;AAUG;AACH,MAAM,2BAA2B,GAAG,GAAG;AA4FvC;SACgB,gCAAgC,GAAA;AAC9C,IAAA,MAAM,OAAO,GAAG,IAAI,GAAG,EAA8B;AACrD,IAAA,IAAI,MAAkC;AACtC,IAAA,IAAI,MAAqC;IAEzC,MAAM,kBAAkB,GAAG,MAAW;QACpC,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC,IAAI,MAAM,KAAK,SAAS,EAAE;YAC9C;QACF;QACA,aAAa,CAAC,MAAM,CAAC;QACrB,MAAM,GAAG,SAAS;AACpB,IAAA,CAAC;IACD,MAAM,IAAI,GAAG,MAAW;AACtB,QAAA,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU;QACnC,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE;AACvC,YAAA,IAAI,CAAC,mCAAmC,CAAC,KAAK,CAAC,EAAE;gBAC/C;YACF;AACA,YAAA,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;AACxB,YAAA,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE;AACtC,gBAAA,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC;YACzB;QACF;AACA,QAAA,kBAAkB,EAAE;QACpB,IAAI,MAAM,KAAK,SAAS,IAAI,SAAS,CAAC,IAAI,KAAK,CAAC,EAAE;YAChD;QACF;AACA,QAAA,mBAAmB,CAAC,MAAM,EAAE,SAAS,CAAC;QACtC,cAAc,CAAC,MAAM,C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AA,MAAM,CAAC,EAAE;AACT,QAAA,MAAM,CAAC,GAAG;AACV,QAAA,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG;AACjC,KAAA,EAAE;AACD,QAAA,IAAI,OAAO,EAAE,IAAI,KAAK,SAAS,EAAE;YAC/B;QACF;AACA,QAAA,IAAI;AACF,YAAA,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;YAChD;QACF;AAAE,QAAA,MAAM;;;QAGR;IACF;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttsc/unplugin",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.3",
|
|
4
4
|
"description": "Bundler adapters for ttsc plugins.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
@@ -196,10 +196,11 @@
|
|
|
196
196
|
"src"
|
|
197
197
|
],
|
|
198
198
|
"dependencies": {
|
|
199
|
+
"chokidar": "^4.0.3",
|
|
199
200
|
"unplugin": "^2.3.11"
|
|
200
201
|
},
|
|
201
202
|
"peerDependencies": {
|
|
202
|
-
"ttsc": "^0.30.
|
|
203
|
+
"ttsc": "^0.30.3"
|
|
203
204
|
},
|
|
204
205
|
"devDependencies": {
|
|
205
206
|
"@rollup/plugin-commonjs": "^29.0.2",
|
|
@@ -213,7 +214,7 @@
|
|
|
213
214
|
"tslib": "^2.8.1",
|
|
214
215
|
"typescript": "^7.0.2",
|
|
215
216
|
"vite": "^7.3.5",
|
|
216
|
-
"ttsc": "0.30.
|
|
217
|
+
"ttsc": "0.30.3"
|
|
217
218
|
},
|
|
218
219
|
"repository": {
|
|
219
220
|
"type": "git",
|
package/src/bun.ts
CHANGED
|
@@ -46,22 +46,6 @@ export type TtscBunOptions =
|
|
|
46
46
|
| TtscUnpluginOptions
|
|
47
47
|
| (() => TtscUnpluginOptions | undefined);
|
|
48
48
|
|
|
49
|
-
/**
|
|
50
|
-
* Transform hooks handed to the shared transform under Bun.
|
|
51
|
-
*
|
|
52
|
-
* The shared transform calls `addWatchFile` once per plugin-reported dependency
|
|
53
|
-
* so type-only inputs can enter a bundler's watch graph. Bun's bundler and
|
|
54
|
-
* runtime loaders expose no per-module dependency-registration channel, so the
|
|
55
|
-
* hook is an explicit no-op here: reported dependencies cannot participate in
|
|
56
|
-
* Bun invalidation, but a valid dependency list must never crash the loader by
|
|
57
|
-
* reaching a missing context method. Passing an empty object made
|
|
58
|
-
* `this.addWatchFile` `undefined`, so any plugin reporting dependencies threw
|
|
59
|
-
* `TypeError: this.addWatchFile is not a function`.
|
|
60
|
-
*/
|
|
61
|
-
const bunTransformHooks = {
|
|
62
|
-
addWatchFile(): void {},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
49
|
/** Resolve {@link TtscBunOptions} to a plain options object (or `undefined`). */
|
|
66
50
|
function resolveBunOptions(
|
|
67
51
|
options?: TtscBunOptions,
|
|
@@ -177,13 +161,14 @@ export default function bun(options?: TtscBunOptions): BunLikePlugin {
|
|
|
177
161
|
const loader = bunLoaderFor(args.path);
|
|
178
162
|
const transformOptions = getOptions();
|
|
179
163
|
const source = await fs.readFile(args.path, "utf8");
|
|
164
|
+
// Bun has no dependency subscription API. Omitting watch hooks also
|
|
165
|
+
// avoids deriving a filesystem watch graph that this host cannot use.
|
|
180
166
|
const result = await transformTtsc(
|
|
181
167
|
args.path,
|
|
182
168
|
source,
|
|
183
169
|
transformOptions,
|
|
184
170
|
undefined,
|
|
185
171
|
cache,
|
|
186
|
-
bunTransformHooks,
|
|
187
172
|
);
|
|
188
173
|
if (result !== undefined) {
|
|
189
174
|
return { contents: result.code, loader };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import type { UnpluginOptions } from "unplugin";
|
|
4
|
+
|
|
5
|
+
import type { ResolvedTtscUnpluginOptions } from "./options";
|
|
6
|
+
import { typescriptTransformSourcePattern } from "./sourceExtensions";
|
|
7
|
+
import {
|
|
8
|
+
type TtscWatchInput,
|
|
9
|
+
beginTtscTransformBuild,
|
|
10
|
+
createTtscTransformCache,
|
|
11
|
+
resetTtscTransformCache,
|
|
12
|
+
transformTtsc,
|
|
13
|
+
} from "./transform";
|
|
14
|
+
|
|
15
|
+
/** Preserve esbuild's distinct file and directory dependency channels. */
|
|
16
|
+
export function createEsbuildOptions(
|
|
17
|
+
options: ResolvedTtscUnpluginOptions,
|
|
18
|
+
includes: (file: string) => boolean,
|
|
19
|
+
): UnpluginOptions {
|
|
20
|
+
const cache = createTtscTransformCache();
|
|
21
|
+
const owners = new WeakSet<object>();
|
|
22
|
+
let lifecycles = 0;
|
|
23
|
+
return {
|
|
24
|
+
name: "ttsc-unplugin",
|
|
25
|
+
esbuild: {
|
|
26
|
+
setup(build) {
|
|
27
|
+
// Setup can fail validation without receiving onDispose. Acquire only
|
|
28
|
+
// at onStart, and retain a generation while another owner is active.
|
|
29
|
+
build.onStart(() => {
|
|
30
|
+
if (!owners.has(build)) {
|
|
31
|
+
owners.add(build);
|
|
32
|
+
lifecycles += 1;
|
|
33
|
+
}
|
|
34
|
+
beginTtscTransformBuild(cache);
|
|
35
|
+
});
|
|
36
|
+
build.onDispose(() => {
|
|
37
|
+
if (!owners.delete(build)) return;
|
|
38
|
+
lifecycles -= 1;
|
|
39
|
+
if (lifecycles === 0) resetTtscTransformCache(cache);
|
|
40
|
+
});
|
|
41
|
+
const previous = new Map<
|
|
42
|
+
string,
|
|
43
|
+
{ watchDirs: string[]; watchFiles: string[] }
|
|
44
|
+
>();
|
|
45
|
+
// There is no generic transform hook on this adapter. Its native
|
|
46
|
+
// loader owns registration, independent of unplugin's hook order.
|
|
47
|
+
build.onLoad(
|
|
48
|
+
{ filter: typescriptTransformSourcePattern, namespace: "file" },
|
|
49
|
+
async ({ path: file }) => {
|
|
50
|
+
if (!includes(file)) return;
|
|
51
|
+
const watchFiles = new Set<string>([file]);
|
|
52
|
+
const watchDirs = new Set<string>();
|
|
53
|
+
const register = (inputs: readonly TtscWatchInput[]) => {
|
|
54
|
+
for (const input of inputs) {
|
|
55
|
+
const observation =
|
|
56
|
+
input.evidence?.state?.codec === "predicates"
|
|
57
|
+
? input.evidence.state.observation
|
|
58
|
+
: undefined;
|
|
59
|
+
const directory =
|
|
60
|
+
observation?.directoryExists === true ||
|
|
61
|
+
observation?.stat === "directory" ||
|
|
62
|
+
observation?.accessibleEntries !== undefined;
|
|
63
|
+
const missingDirectory =
|
|
64
|
+
observation?.directoryExists === false &&
|
|
65
|
+
observation.fileExists !== true &&
|
|
66
|
+
observation.stat !== "file";
|
|
67
|
+
if (directory || missingDirectory) watchDirs.add(input.file);
|
|
68
|
+
if (!directory || observation?.fileExists !== undefined)
|
|
69
|
+
watchFiles.add(input.file);
|
|
70
|
+
// Failed envelopes carry no generation evidence. This rare
|
|
71
|
+
// path must still classify existing recovery directories.
|
|
72
|
+
if (input.evidence === undefined) {
|
|
73
|
+
try {
|
|
74
|
+
if (fs.statSync(input.file).isDirectory())
|
|
75
|
+
watchDirs.add(input.file);
|
|
76
|
+
} catch {
|
|
77
|
+
// Missing files are already tracked through watchFiles.
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
let contents: string;
|
|
83
|
+
let errors;
|
|
84
|
+
try {
|
|
85
|
+
const source = await fs.promises.readFile(file, "utf8");
|
|
86
|
+
const result = await transformTtsc(
|
|
87
|
+
file,
|
|
88
|
+
source,
|
|
89
|
+
options,
|
|
90
|
+
undefined,
|
|
91
|
+
cache,
|
|
92
|
+
{ addWatchFiles: register },
|
|
93
|
+
);
|
|
94
|
+
contents = result?.code ?? source;
|
|
95
|
+
} catch (error) {
|
|
96
|
+
for (const input of previous.get(file)?.watchFiles ?? [])
|
|
97
|
+
watchFiles.add(input);
|
|
98
|
+
for (const input of previous.get(file)?.watchDirs ?? [])
|
|
99
|
+
watchDirs.add(input);
|
|
100
|
+
// Returning errors with dependencies lets an initially failing
|
|
101
|
+
// build observe its repair; throwing discards those channels.
|
|
102
|
+
errors = [
|
|
103
|
+
{
|
|
104
|
+
text: error instanceof Error ? error.message : String(error),
|
|
105
|
+
detail: error,
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
contents = "";
|
|
109
|
+
}
|
|
110
|
+
const dependencies = {
|
|
111
|
+
watchFiles: [...watchFiles],
|
|
112
|
+
watchDirs: [...watchDirs],
|
|
113
|
+
};
|
|
114
|
+
previous.set(file, dependencies);
|
|
115
|
+
return {
|
|
116
|
+
contents,
|
|
117
|
+
errors,
|
|
118
|
+
loader: file.endsWith(".tsx") ? "tsx" : "ts",
|
|
119
|
+
resolveDir: path.dirname(file),
|
|
120
|
+
...dependencies,
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
);
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|