@decocms/tanstack 7.4.0 → 7.5.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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/vite/plugin.js +21 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/tanstack",
3
- "version": "7.4.0",
3
+ "version": "7.5.1",
4
4
  "type": "module",
5
5
  "description": "Deco framework binding for TanStack Start + Cloudflare Workers",
6
6
  "repository": {
@@ -22,9 +22,9 @@
22
22
  "lint:unused": "knip"
23
23
  },
24
24
  "dependencies": {
25
- "@decocms/blocks": "7.4.0",
26
- "@decocms/blocks-admin": "7.4.0",
27
- "@decocms/blocks-cli": "7.4.0",
25
+ "@decocms/blocks": "7.5.1",
26
+ "@decocms/blocks-admin": "7.5.1",
27
+ "@decocms/blocks-cli": "7.5.1",
28
28
  "@deco-cx/warp-node": "^0.3.16",
29
29
  "fast-json-patch": "^3.1.0",
30
30
  "ws": "^8.18.0"
@@ -14,7 +14,7 @@
14
14
  * — V8's JSON parser is 2-10x faster than the JS parser for large data.
15
15
  *
16
16
  * meta.gen handling:
17
- * The admin schema bundle (`server/admin/meta.gen.json`) is server-only;
17
+ * The admin schema bundle (`.deco/meta.gen.json`) is server-only;
18
18
  * the client receives pre-resolved blocks via the SSR payload. Stubbing
19
19
  * it on the client cuts a typically-large module out of the browser bundle.
20
20
  * Match is done by substring on the import id, so any path style works.
@@ -209,7 +209,7 @@ export function decoVitePlugin() {
209
209
  // below) so we don't depend on the consumer's TS loader.
210
210
  const cwd = process.cwd();
211
211
  const blocksDir = path.resolve(cwd, ".deco/blocks");
212
- const outFile = path.resolve(cwd, "src/server/cms/blocks.gen.ts");
212
+ const outFile = path.resolve(cwd, ".deco/blocks.gen.ts");
213
213
  const jsonFile = outFile.replace(/\.ts$/, ".json");
214
214
 
215
215
  // Lazily load the block generator module (generateBlocks for the cold-start
@@ -224,6 +224,22 @@ export function decoVitePlugin() {
224
224
  tsImport("@decocms/blocks-cli/generate-blocks", import.meta.url),
225
225
  )
226
226
  .then((mod) => {
227
+ if (typeof mod.generateBlocks !== "function") {
228
+ // tsx 4.22.0–4.22.4 has a loader-hook state bug (fixed upstream
229
+ // in 4.22.5, "isolate hook state per async module.register()
230
+ // registration"): inside a Vite dev-server process, tsImport
231
+ // resolves correctly but returns an EMPTY module namespace —
232
+ // no rejection, no missing-module error. blocks-cli floors its
233
+ // tsx dependency at ^4.22.5, but a site's own lockfile can pin
234
+ // a broken copy that hoists above it. Fail with an actionable
235
+ // message instead of the bare "generateBlocks is not a
236
+ // function" this used to surface as.
237
+ throw new Error(
238
+ "tsImport(@decocms/blocks-cli/generate-blocks) returned an empty module namespace. " +
239
+ "This is the tsx 4.22.0–4.22.4 loader-hook bug — check `node -e \"console.log(require('tsx/package.json').version)\"` " +
240
+ "and upgrade tsx to >=4.22.5 (e.g. `bun update tsx` or pin a newer tsx in devDependencies).",
241
+ );
242
+ }
227
243
  genModule = mod;
228
244
  return mod;
229
245
  });
@@ -376,8 +392,10 @@ export function decoVitePlugin() {
376
392
  // --- meta.gen.json auto-regeneration ---
377
393
  // When section/loader/app source files change (types, JSDoc, Props),
378
394
  // re-run generate-schema.ts so meta.gen.json stays in sync during dev.
395
+ // No --out is passed to the generator below, so it writes to its own
396
+ // default (.deco/meta.gen.json) — this constant must track that default.
379
397
  const schemaWatchDirs = ["src"];
380
- const schemaOutFile = path.resolve(cwd, "src/server/admin/meta.gen.json");
398
+ const schemaOutFile = path.resolve(cwd, ".deco/meta.gen.json");
381
399
 
382
400
  // Resolve the site name once from vite define or env.
383
401
  const definedSite = server.config.define?.["process.env.DECO_SITE_NAME"];