@base44-preview/vite-plugin 1.0.44-pr.132.56d48fe → 1.0.44-pr.132.b7d2146

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.
@@ -1 +1 @@
1
- {"version":3,"file":"base44-runtime-plugin.d.ts","sourceRoot":"","sources":["../src/base44-runtime-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAsFnC,wBAAgB,mBAAmB,IAAI,MAAM,CAiC5C"}
1
+ {"version":3,"file":"base44-runtime-plugin.d.ts","sourceRoot":"","sources":["../src/base44-runtime-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAqFnC,wBAAgB,mBAAmB,IAAI,MAAM,CA2C5C"}
@@ -23,9 +23,6 @@
23
23
  * public import. Without that wrapper (including local dev), TCP fails closed.
24
24
  */
25
25
  const SPECIFIER = "base44:runtime";
26
- // Rollup convention: a resolved virtual id starts with NUL so no other plugin
27
- // (and no filesystem lookup) tries to claim it.
28
- const RESOLVED = "\0base44:runtime";
29
26
  // Reserved so a route importing it fails with an explanation instead of a bare
30
27
  // "failed to resolve import". Actors are never imported — they live in the app's
31
28
  // actors directory, in server routes exactly as in backend functions.
@@ -77,6 +74,7 @@ export const staticEgress = Object.freeze({
77
74
  },
78
75
  });
79
76
  `;
77
+ const IMPORTER_QUERY = "?importer=";
80
78
  export function base44RuntimePlugin() {
81
79
  return {
82
80
  name: "base44-runtime",
@@ -85,27 +83,38 @@ export function base44RuntimePlugin() {
85
83
  enforce: "pre",
86
84
  // Errors are raised in `load`, never `resolveId`: Vite's dep scanner resolves
87
85
  // the raw source of server routes and server-fn handlers in the client
88
- // environment, before TanStack strips them, and treats a virtual id as
89
- // external without loading it. A throw at resolution fails the scan and
90
- // Vite skips pre-bundling.
91
- resolveId(id) {
92
- if (id === SPECIFIER || unsupportedReason(id))
93
- return `\0${id}`;
94
- return null;
86
+ // environment, before TanStack strips them, and a throw there fails the scan
87
+ // so Vite skips pre-bundling. This relies on the scanner externalizing
88
+ // resolved virtual ids rather than loading them (true of the esbuild scan in
89
+ // Vite 7 and the Rolldown scan in Vite 8); re-check it on a bundler change.
90
+ resolveId(id, importer) {
91
+ if (id !== SPECIFIER && !unsupportedReason(id))
92
+ return null;
93
+ // Rollup convention: a NUL-prefixed id is virtual, so no other plugin
94
+ // (and no filesystem lookup) tries to claim it.
95
+ const virtual = `\0${id}`;
96
+ // A module that only exists to fail carries its importer in its id, so the
97
+ // error names that exact file. Server environments share one instance.
98
+ const fails = id !== SPECIFIER || this.environment?.name === "client";
99
+ if (!fails || !importer)
100
+ return virtual;
101
+ // Drop the importer's own query (e.g. TanStack's `?tsr-split=component`).
102
+ return `${virtual}${IMPORTER_QUERY}${encodeURIComponent(importer.split("?")[0])}`;
95
103
  },
96
104
  load(id) {
97
- if (!id.startsWith(RESOLVED))
105
+ if (!id.startsWith("\0"))
98
106
  return null;
99
- const reason = unsupportedReason(id.slice(1));
100
- if (reason) {
101
- this.error(`"${id.slice(1)}" is not available in server routes. ${reason}`);
102
- }
103
- if (id !== RESOLVED)
107
+ const [specifier = "", importer] = id.slice(1).split(IMPORTER_QUERY);
108
+ const reason = unsupportedReason(specifier);
109
+ if (specifier !== SPECIFIER && !reason)
104
110
  return null;
111
+ const from = importer ? ` Imported from ${decodeURIComponent(importer)}.` : "";
112
+ if (reason)
113
+ this.error(`"${specifier}" is not available in server routes. ${reason}${from}`);
105
114
  // `cloudflare:workers` has no browser equivalent, so a client-side import
106
115
  // would bundle a module that cannot run. Fail with the reason instead.
107
116
  if (this.environment?.name === "client") {
108
- this.error(`"${SPECIFIER}" is server-only. Move this import into a server route.`);
117
+ this.error(`"${SPECIFIER}" is server-only. Move this import into a server route.${from}`);
109
118
  }
110
119
  return RUNTIME_MODULE;
111
120
  },
@@ -1 +1 @@
1
- {"version":3,"file":"base44-runtime-plugin.js","sourceR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",
3
+ "version": "1.0.44-pr.132.b7d2146",
4
4
  "description": "The Vite plugin for base44 based applications",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,9 +26,6 @@ import type { Plugin } from "vite";
26
26
  */
27
27
 
28
28
  const SPECIFIER = "base44:runtime";
29
- // Rollup convention: a resolved virtual id starts with NUL so no other plugin
30
- // (and no filesystem lookup) tries to claim it.
31
- const RESOLVED = "\0base44:runtime";
32
29
 
33
30
  // Reserved so a route importing it fails with an explanation instead of a bare
34
31
  // "failed to resolve import". Actors are never imported — they live in the app's
@@ -84,6 +81,8 @@ export const staticEgress = Object.freeze({
84
81
  });
85
82
  `;
86
83
 
84
+ const IMPORTER_QUERY = "?importer=";
85
+
87
86
  export function base44RuntimePlugin(): Plugin {
88
87
  return {
89
88
  name: "base44-runtime",
@@ -93,26 +92,36 @@ export function base44RuntimePlugin(): Plugin {
93
92
 
94
93
  // Errors are raised in `load`, never `resolveId`: Vite's dep scanner resolves
95
94
  // the raw source of server routes and server-fn handlers in the client
96
- // environment, before TanStack strips them, and treats a virtual id as
97
- // external without loading it. A throw at resolution fails the scan and
98
- // Vite skips pre-bundling.
99
- resolveId(id) {
100
- if (id === SPECIFIER || unsupportedReason(id)) return `\0${id}`;
101
- return null;
95
+ // environment, before TanStack strips them, and a throw there fails the scan
96
+ // so Vite skips pre-bundling. This relies on the scanner externalizing
97
+ // resolved virtual ids rather than loading them (true of the esbuild scan in
98
+ // Vite 7 and the Rolldown scan in Vite 8); re-check it on a bundler change.
99
+ resolveId(id, importer) {
100
+ if (id !== SPECIFIER && !unsupportedReason(id)) return null;
101
+ // Rollup convention: a NUL-prefixed id is virtual, so no other plugin
102
+ // (and no filesystem lookup) tries to claim it.
103
+ const virtual = `\0${id}`;
104
+ // A module that only exists to fail carries its importer in its id, so the
105
+ // error names that exact file. Server environments share one instance.
106
+ const fails = id !== SPECIFIER || this.environment?.name === "client";
107
+ if (!fails || !importer) return virtual;
108
+ // Drop the importer's own query (e.g. TanStack's `?tsr-split=component`).
109
+ return `${virtual}${IMPORTER_QUERY}${encodeURIComponent(importer.split("?")[0]!)}`;
102
110
  },
103
111
 
104
112
  load(id) {
105
- if (!id.startsWith(RESOLVED)) return null;
106
- const reason = unsupportedReason(id.slice(1));
107
- if (reason) {
108
- this.error(`"${id.slice(1)}" is not available in server routes. ${reason}`);
109
- }
110
- if (id !== RESOLVED) return null;
113
+ if (!id.startsWith("\0")) return null;
114
+ const [specifier = "", importer] = id.slice(1).split(IMPORTER_QUERY);
115
+ const reason = unsupportedReason(specifier);
116
+ if (specifier !== SPECIFIER && !reason) return null;
117
+ const from = importer ? ` Imported from ${decodeURIComponent(importer)}.` : "";
118
+
119
+ if (reason) this.error(`"${specifier}" is not available in server routes. ${reason}${from}`);
111
120
 
112
121
  // `cloudflare:workers` has no browser equivalent, so a client-side import
113
122
  // would bundle a module that cannot run. Fail with the reason instead.
114
123
  if (this.environment?.name === "client") {
115
- this.error(`"${SPECIFIER}" is server-only. Move this import into a server route.`);
124
+ this.error(`"${SPECIFIER}" is server-only. Move this import into a server route.${from}`);
116
125
  }
117
126
  return RUNTIME_MODULE;
118
127
  },