@decocms/tanstack 7.71.4 → 7.71.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/tanstack",
3
- "version": "7.71.4",
3
+ "version": "7.71.6",
4
4
  "type": "module",
5
5
  "description": "Deco framework binding for TanStack Start + Cloudflare Workers",
6
6
  "repository": {
@@ -27,9 +27,9 @@
27
27
  "lint:unused": "knip"
28
28
  },
29
29
  "dependencies": {
30
- "@decocms/blocks": "7.71.4",
31
- "@decocms/blocks-admin": "7.71.4",
32
- "@decocms/blocks-cli": "7.71.4",
30
+ "@decocms/blocks": "7.71.6",
31
+ "@decocms/blocks-admin": "7.71.6",
32
+ "@decocms/blocks-cli": "7.71.6",
33
33
  "@deco-cx/warp-node": "^0.3.16",
34
34
  "fast-json-patch": "^3.1.0",
35
35
  "ws": "^8.18.0"
@@ -247,9 +247,25 @@ export function decoVitePlugin({ fastDeploy = "auto" } = {}) {
247
247
  // of who loaded it — it would try to JSON.parse that JS and fail the
248
248
  // build ("Failed to parse JSON file").
249
249
  if (options?.ssr && importer && id.endsWith("meta.gen.json")) {
250
- const file = path.isAbsolute(id) ? id : path.resolve(path.dirname(importer), id);
251
- if (existsSync(file)) return metaGenSsrId(file);
252
- // Absent (pre-generate-schema) — let Vite report it normally.
250
+ if (id.startsWith(".") || path.isAbsolute(id)) {
251
+ const file = path.resolve(path.dirname(importer), id);
252
+ if (existsSync(file)) return metaGenSsrId(file);
253
+ // Absent (pre-generate-schema) — let Vite report it normally.
254
+ return undefined;
255
+ }
256
+ // Alias / bare specifier (`~/.deco/meta.gen.json`, tsconfig paths…):
257
+ // let the rest of the pipeline resolve it, then wrap — otherwise it
258
+ // falls through to vite:json and loses the JSON.parse optimization.
259
+ if (typeof this?.resolve === "function") {
260
+ return this.resolve(id, importer, { ...options, skipSelf: true }).then(
261
+ (r) =>
262
+ r && !r.external && r.id.endsWith("meta.gen.json") && existsSync(r.id)
263
+ ? metaGenSsrId(r.id)
264
+ : undefined,
265
+ // A resolver in the chain threw — let Vite's normal resolution report it.
266
+ () => undefined,
267
+ );
268
+ }
253
269
  }
254
270
  // Server builds keep the real modules.
255
271
  if (options?.ssr) return undefined;
@@ -175,6 +175,51 @@ describe("decoVitePlugin meta.gen.json on SSR (regression: vite:json double-pars
175
175
  }
176
176
  });
177
177
 
178
+ it("wraps aliased imports after the rest of the pipeline resolves them", async () => {
179
+ const p = getPlugin();
180
+ const file = path.join(dir, ".deco", "meta.gen.json");
181
+ const seen = [];
182
+ const ctx = {
183
+ resolve: async (spec, imp, opts) => {
184
+ seen.push([spec, opts.skipSelf]);
185
+ return { id: file };
186
+ },
187
+ };
188
+ const id = await p.resolveId.call(
189
+ ctx,
190
+ "~/.deco/meta.gen.json",
191
+ path.join(dir, "src", "setup.ts"),
192
+ {
193
+ ssr: true,
194
+ },
195
+ );
196
+ expect(id.endsWith(".json")).toBe(false);
197
+ expect(seen).toEqual([["~/.deco/meta.gen.json", true]]);
198
+ expect(p.load.call({}, id, { ssr: true })).toContain("JSON.parse(");
199
+ });
200
+
201
+ it("leaves an aliased import alone when it doesn't resolve to an existing file", async () => {
202
+ const p = getPlugin();
203
+ const ctx = { resolve: async () => null };
204
+ const id = await p.resolveId.call(ctx, "~/missing/meta.gen.json", path.join(dir, "x.ts"), {
205
+ ssr: true,
206
+ });
207
+ expect(id).toBeUndefined();
208
+ });
209
+
210
+ it("falls through when a resolver in the chain throws for the alias", async () => {
211
+ const p = getPlugin();
212
+ const ctx = {
213
+ resolve: async () => {
214
+ throw new Error("exports map error");
215
+ },
216
+ };
217
+ const id = await p.resolveId.call(ctx, "~/x/meta.gen.json", path.join(dir, "x.ts"), {
218
+ ssr: true,
219
+ });
220
+ expect(id).toBeUndefined();
221
+ });
222
+
178
223
  it("falls through to Vite when meta.gen.json does not exist yet", () => {
179
224
  const p = getPlugin();
180
225
  const importer = path.join(dir, "src", "setup.ts");