houdini 2.0.0-next.30 → 2.0.0-next.31

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/build/cmd/init.js CHANGED
@@ -472,7 +472,7 @@ async function packageJSON(targetPath, frameworkInfo) {
472
472
  }
473
473
  packageJSON2.devDependencies = {
474
474
  ...packageJSON2.devDependencies,
475
- houdini: "^2.0.0-next.30"
475
+ houdini: "^2.0.0-next.31"
476
476
  };
477
477
  if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
478
478
  packageJSON2.devDependencies = {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "2.0.0-next.30",
3
+ "version": "2.0.0-next.31",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",
@@ -18,6 +18,9 @@ import { type CompilerProxy } from '../lib/index.js';
18
18
  */
19
19
  export declare let compiler: CompilerProxy;
20
20
  export declare function document_hmr(ctx: VitePluginContext): VitePlugin;
21
- type BatchCallback = (filesWithContent: Record<string, string>, batchId: string) => void | Promise<void>;
22
- export declare function createDebounceHmr(debounceMs?: number): (ctx: HmrContext, callback: BatchCallback) => void;
21
+ type BatchCallback = (filesWithContent: Record<string, string>, deletedFiles: string[], batchId: string) => void | Promise<void>;
22
+ export declare function createDebounceHmr(debounceMs?: number): {
23
+ queueUpdate(ctx: HmrContext, callback: BatchCallback): void;
24
+ queueDelete(relativePath: string, callback: BatchCallback): void;
25
+ };
23
26
  export {};
package/build/vite/hmr.js CHANGED
@@ -33,12 +33,6 @@ function document_hmr(ctx) {
33
33
  // The legacy handleHotUpdate hook is only called for 'update', so new .gql files
34
34
  // (type === 'create') would be silently ignored without this hook.
35
35
  hotUpdate(opts) {
36
- if (opts.type === "delete") return;
37
- const ownWriteTime = ownWrites.get(opts.file);
38
- if (ownWriteTime !== void 0) {
39
- if (Date.now() - ownWriteTime < 500) return [];
40
- ownWrites.delete(opts.file);
41
- }
42
36
  const server = opts.server;
43
37
  const generatedDir = path.join(
44
38
  server.config.root,
@@ -47,7 +41,24 @@ function document_hmr(ctx) {
47
41
  if (opts.file.startsWith(generatedDir + "/") || opts.file === generatedDir) {
48
42
  return [];
49
43
  }
50
- return debounceHmr(opts, async (files, task_id) => {
44
+ if (opts.type === "delete") {
45
+ if (!opts.file.endsWith(".gql")) return;
46
+ const rootPrefix = server.config.root.endsWith("/") ? server.config.root : server.config.root + "/";
47
+ const relativePath = opts.file.substring(rootPrefix.length);
48
+ debounceHmr.queueDelete(relativePath, batchCallback);
49
+ return [];
50
+ }
51
+ const ownWriteTime = ownWrites.get(opts.file);
52
+ if (ownWriteTime !== void 0) {
53
+ if (Date.now() - ownWriteTime < 500) return [];
54
+ ownWrites.delete(opts.file);
55
+ }
56
+ return debounceHmr.queueUpdate(opts, batchCallback);
57
+ async function batchCallback(files, deletedFiles, task_id) {
58
+ if (deletedFiles.length > 0) {
59
+ const delClause = deletedFiles.map(() => "filepath = ?").join(" OR ");
60
+ ctx.db.run(`DELETE from raw_documents WHERE ${delClause}`, deletedFiles);
61
+ }
51
62
  const filepaths = [];
52
63
  const relativePaths = [];
53
64
  const rootPrefix = server.config.root.endsWith("/") ? server.config.root : server.config.root + "/";
@@ -82,6 +93,12 @@ function document_hmr(ctx) {
82
93
  }
83
94
  }
84
95
  if (filepaths.length === 0) {
96
+ if (deletedFiles.length > 0) {
97
+ console.log(
98
+ `\u{1F3A9} Detected ${deletedFiles.length} deleted ${deletedFiles.length === 1 ? "file" : "files"}, re-running compiler`
99
+ );
100
+ await compiler.run_pipeline({});
101
+ }
85
102
  return;
86
103
  }
87
104
  const fileCount = filepaths.length;
@@ -192,30 +209,34 @@ function document_hmr(ctx) {
192
209
  if (updated_modules.length > 0) {
193
210
  server.ws.send({ type: "full-reload" });
194
211
  }
195
- });
212
+ }
196
213
  }
197
214
  };
198
215
  }
199
216
  function createDebounceHmr(debounceMs = 50) {
200
217
  const updateQueue = /* @__PURE__ */ new Map();
218
+ const deleteQueue = /* @__PURE__ */ new Set();
201
219
  let updateTimer = null;
202
220
  let batchId = 0;
203
221
  let isProcessing = false;
204
222
  let pendingBatch = null;
205
- return function debounceHmr(ctx, callback) {
206
- if (!updateQueue.has(ctx.file)) {
207
- updateQueue.set(ctx.file, ctx.read);
208
- }
223
+ function scheduleFlush(callback) {
209
224
  if (updateTimer) {
210
225
  clearTimeout(updateTimer);
211
226
  }
212
227
  updateTimer = setTimeout(async () => {
213
228
  const filesToProcess = new Map(updateQueue);
229
+ const filesToDelete = new Set(deleteQueue);
214
230
  const currentBatchId = ++batchId;
215
231
  updateQueue.clear();
232
+ deleteQueue.clear();
216
233
  updateTimer = null;
217
234
  if (isProcessing) {
218
- pendingBatch = { files: filesToProcess, batchId: currentBatchId };
235
+ pendingBatch = {
236
+ files: filesToProcess,
237
+ deletedFiles: filesToDelete,
238
+ batchId: currentBatchId
239
+ };
219
240
  return;
220
241
  }
221
242
  isProcessing = true;
@@ -230,12 +251,16 @@ function createDebounceHmr(debounceMs = 50) {
230
251
  })
231
252
  );
232
253
  try {
233
- await callback(filesWithContent, currentBatchId.toString());
254
+ await callback(filesWithContent, [...filesToDelete], currentBatchId.toString());
234
255
  } catch (err) {
235
256
  console.error("[houdini] HMR pipeline error:", err);
236
257
  }
237
258
  while (pendingBatch) {
238
- const { files: nextFiles, batchId: nextBatchId } = pendingBatch;
259
+ const {
260
+ files: nextFiles,
261
+ deletedFiles: nextDeleted,
262
+ batchId: nextBatchId
263
+ } = pendingBatch;
239
264
  pendingBatch = null;
240
265
  const nextFilesWithContent = {};
241
266
  await Promise.all(
@@ -247,7 +272,11 @@ function createDebounceHmr(debounceMs = 50) {
247
272
  })
248
273
  );
249
274
  try {
250
- await callback(nextFilesWithContent, nextBatchId.toString());
275
+ await callback(
276
+ nextFilesWithContent,
277
+ [...nextDeleted],
278
+ nextBatchId.toString()
279
+ );
251
280
  } catch (err) {
252
281
  console.error("[houdini] HMR pipeline error:", err);
253
282
  }
@@ -256,6 +285,18 @@ function createDebounceHmr(debounceMs = 50) {
256
285
  isProcessing = false;
257
286
  }
258
287
  }, debounceMs);
288
+ }
289
+ return {
290
+ queueUpdate(ctx, callback) {
291
+ if (!updateQueue.has(ctx.file)) {
292
+ updateQueue.set(ctx.file, ctx.read);
293
+ }
294
+ scheduleFlush(callback);
295
+ },
296
+ queueDelete(relativePath, callback) {
297
+ deleteQueue.add(relativePath);
298
+ scheduleFlush(callback);
299
+ }
259
300
  };
260
301
  }
261
302
  export {
@@ -1,6 +1,47 @@
1
+ import { mkdirSync, writeFileSync } from "node:fs";
1
2
  import path from "node:path";
2
3
  import { codegen_setup } from "../lib/codegen.js";
3
4
  import * as fs from "../lib/fs.js";
5
+ const REACT_TSCONFIG_STUB = `{
6
+ "compilerOptions": {
7
+ "baseUrl": ".",
8
+ "paths": {
9
+ "$houdini": ["."],
10
+ "$houdini/*": ["./*"],
11
+ "~": ["../src"],
12
+ "~/*": ["../src/*"]
13
+ },
14
+ "rootDirs": ["..", "./types"],
15
+ "target": "ESNext",
16
+ "useDefineForClassFields": true,
17
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
18
+ "allowJs": true,
19
+ "skipLibCheck": true,
20
+ "esModuleInterop": false,
21
+ "allowSyntheticDefaultImports": true,
22
+ "strict": true,
23
+ "forceConsistentCasingInFileNames": true,
24
+ "module": "ESNext",
25
+ "moduleResolution": "Bundler",
26
+ "allowImportingTsExtensions": true,
27
+ "resolveJsonModule": true,
28
+ "isolatedModules": true,
29
+ "noEmit": true,
30
+ "jsx": "react-jsx"
31
+ },
32
+ "include": [
33
+ "ambient.d.ts",
34
+ "./types/**/$types.d.ts",
35
+ "../vite.config.ts",
36
+ "../src/**/*.js",
37
+ "../src/**/*.ts",
38
+ "../src/**/*.jsx",
39
+ "../src/**/*.tsx",
40
+ "../src/+app.d.ts"
41
+ ],
42
+ "exclude": ["../node_modules/**", "./[!ambient.d.ts]**"]
43
+ }
44
+ `;
4
45
  let compiler;
5
46
  let alreadyBuilt = false;
6
47
  function houdini(ctx) {
@@ -22,6 +63,14 @@ function houdini(ctx) {
22
63
  ctx.config.root_dir,
23
64
  ctx.config.config_file.runtimeDir ?? ".houdini"
24
65
  );
66
+ const tsconfigPath = path.join(runtimeDir, "tsconfig.json");
67
+ if (!fs.existsSync(tsconfigPath) && ctx.config.plugins.some((p) => p.name === "houdini-react")) {
68
+ try {
69
+ mkdirSync(runtimeDir, { recursive: true });
70
+ writeFileSync(tsconfigPath, REACT_TSCONFIG_STUB);
71
+ } catch {
72
+ }
73
+ }
25
74
  const houdiniAliases = {
26
75
  $houdini: runtimeDir,
27
76
  "$houdini/*": path.join(runtimeDir, "*"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "2.0.0-next.30",
3
+ "version": "2.0.0-next.31",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",
@@ -50,7 +50,7 @@
50
50
  "recast": "^0.23.11",
51
51
  "sql.js": "^1.14.1",
52
52
  "ws": "^8.21.0",
53
- "houdini-core": "^2.0.0-next.18"
53
+ "houdini-core": "^2.0.0-next.19"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "graphql": ">=16",