@decocms/tanstack 7.79.8 → 7.80.0

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 +34 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/tanstack",
3
- "version": "7.79.8",
3
+ "version": "7.80.0",
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.79.8",
31
- "@decocms/blocks-admin": "7.79.8",
32
- "@decocms/blocks-cli": "7.79.8",
30
+ "@decocms/blocks": "7.80.0",
31
+ "@decocms/blocks-admin": "7.80.0",
32
+ "@decocms/blocks-cli": "7.80.0",
33
33
  "@deco-cx/warp-node": "^0.3.16",
34
34
  "fast-json-patch": "^3.1.0",
35
35
  "ws": "^8.18.0"
@@ -42,7 +42,7 @@
42
42
  */
43
43
  import { exec, execFileSync } from "node:child_process";
44
44
  import { createHash } from "node:crypto";
45
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
45
+ import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
46
46
  import path from "node:path";
47
47
 
48
48
  /**
@@ -227,6 +227,27 @@ function isSeededDeployPipeline() {
227
227
  return v === "1" || v === "true";
228
228
  }
229
229
 
230
+ /**
231
+ * `deco.sectionPackages` from the site's package.json → the realpath of each
232
+ * package's src/ (Vite reports realpaths for symlinked `file:` deps). Mirrors
233
+ * blocks-cli's readSectionPackages, which owns the "package missing" error.
234
+ * ponytail: only the site's own node_modules, no hoisted-workspace lookup.
235
+ */
236
+ function readSectionPackageSrcDirs(cwd) {
237
+ try {
238
+ const { deco } = JSON.parse(readFileSync(path.join(cwd, "package.json"), "utf8"));
239
+ return Object.entries(deco?.sectionPackages ?? {}).flatMap(([namespace, name]) => {
240
+ try {
241
+ return [{ namespace, srcDir: realpathSync(path.join(cwd, "node_modules", name, "src")) }];
242
+ } catch {
243
+ return [];
244
+ }
245
+ });
246
+ } catch {
247
+ return [];
248
+ }
249
+ }
250
+
230
251
  /**
231
252
  * @param {object} [opts]
232
253
  * @param {boolean | "auto"} [opts.fastDeploy="auto"] Stub `blocks.gen` out of
@@ -276,6 +297,7 @@ function isSeededDeployPipeline() {
276
297
  * @returns {import("vite").PluginOption}
277
298
  */
278
299
  export function decoVitePlugin({ fastDeploy = "auto", metaAsset = false } = {}) {
300
+ const sectionPackages = readSectionPackageSrcDirs(process.cwd());
279
301
  // Resolved once: the pipeline's answer cannot change mid-build.
280
302
  const stubBlocks = fastDeploy === "auto" ? isSeededDeployPipeline() : fastDeploy === true;
281
303
  // Set from the `config` hook (which Vite always runs before `load`). The
@@ -752,7 +774,8 @@ export function decoVitePlugin({ fastDeploy = "auto", metaAsset = false } = {})
752
774
  const isSchemaSource = (file) => {
753
775
  const rel = path.relative(cwd, file);
754
776
  return (
755
- schemaWatchDirs.some((d) => rel.startsWith(d + path.sep)) &&
777
+ (schemaWatchDirs.some((d) => rel.startsWith(d + path.sep)) ||
778
+ sectionPackages.some((p) => file.startsWith(p.srcDir + path.sep))) &&
756
779
  (rel.endsWith(".tsx") || rel.endsWith(".ts"))
757
780
  );
758
781
  };
@@ -1105,7 +1128,15 @@ export function decoVitePlugin({ fastDeploy = "auto", metaAsset = false } = {})
1105
1128
  const map = {};
1106
1129
  for (const [fileName, chunk] of Object.entries(bundle)) {
1107
1130
  if (chunk.type === "chunk" && chunk.facadeModuleId) {
1108
- const match = chunk.facadeModuleId.match(/\/(sections\/.+\.tsx)$/);
1131
+ const id = chunk.facadeModuleId;
1132
+ const pkg = sectionPackages.find((p) =>
1133
+ id.startsWith(path.join(p.srcDir, "sections") + path.sep),
1134
+ );
1135
+ if (pkg) {
1136
+ map[`${pkg.namespace}/${path.relative(pkg.srcDir, id)}`] = fileName;
1137
+ continue;
1138
+ }
1139
+ const match = id.match(/\/(sections\/.+\.tsx)$/);
1109
1140
  if (match) {
1110
1141
  map["site/" + match[1]] = fileName;
1111
1142
  }