@base44-preview/vite-plugin 1.0.44-pr.132.49617f5 → 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,CA+B5C"}
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,33 +74,49 @@ 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",
83
81
  // Ahead of Vite's own resolution so the bare `base44:` specifier is never
84
82
  // mistaken for a URL protocol.
85
83
  enforce: "pre",
86
- resolveId(id, _importer, options) {
87
- const reason = unsupportedReason(id);
88
- if (reason) {
89
- this.error(`"${id}" is not available in server routes. ${reason}`);
90
- }
91
- if (id !== SPECIFIER)
84
+ // Errors are raised in `load`, never `resolveId`: Vite's dep scanner resolves
85
+ // the raw source of server routes and server-fn handlers in the client
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])}`;
103
+ },
104
+ load(id) {
105
+ if (!id.startsWith("\0"))
92
106
  return null;
93
- // The dep scanner crawls raw source in the client environment, before
94
- // TanStack strips server routes and server-fn handlers out of the client
95
- // graph. Throwing here fails the scan and Vite skips pre-bundling.
96
- if (options?.scan)
97
- return { id, external: true };
107
+ const [specifier = "", importer] = id.slice(1).split(IMPORTER_QUERY);
108
+ const reason = unsupportedReason(specifier);
109
+ if (specifier !== SPECIFIER && !reason)
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}`);
98
114
  // `cloudflare:workers` has no browser equivalent, so a client-side import
99
115
  // would bundle a module that cannot run. Fail with the reason instead.
100
116
  if (this.environment?.name === "client") {
101
- 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}`);
102
118
  }
103
- return RESOLVED;
104
- },
105
- load(id) {
106
- return id === RESOLVED ? RUNTIME_MODULE : null;
119
+ return RUNTIME_MODULE;
107
120
  },
108
121
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
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",
@@ -91,28 +90,40 @@ export function base44RuntimePlugin(): Plugin {
91
90
  // mistaken for a URL protocol.
92
91
  enforce: "pre",
93
92
 
94
- resolveId(id, _importer, options) {
95
- const reason = unsupportedReason(id);
96
- if (reason) {
97
- this.error(`"${id}" is not available in server routes. ${reason}`);
98
- }
99
- if (id !== SPECIFIER) return null;
93
+ // Errors are raised in `load`, never `resolveId`: Vite's dep scanner resolves
94
+ // the raw source of server routes and server-fn handlers in the client
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]!)}`;
110
+ },
111
+
112
+ load(id) {
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)}.` : "";
100
118
 
101
- // The dep scanner crawls raw source in the client environment, before
102
- // TanStack strips server routes and server-fn handlers out of the client
103
- // graph. Throwing here fails the scan and Vite skips pre-bundling.
104
- if ((options as { scan?: boolean } | undefined)?.scan) return { id, external: true };
119
+ if (reason) this.error(`"${specifier}" is not available in server routes. ${reason}${from}`);
105
120
 
106
121
  // `cloudflare:workers` has no browser equivalent, so a client-side import
107
122
  // would bundle a module that cannot run. Fail with the reason instead.
108
123
  if (this.environment?.name === "client") {
109
- 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}`);
110
125
  }
111
- return RESOLVED;
112
- },
113
-
114
- load(id) {
115
- return id === RESOLVED ? RUNTIME_MODULE : null;
126
+ return RUNTIME_MODULE;
116
127
  },
117
128
  };
118
129
  }