@base44-preview/vite-plugin 1.0.44-pr.132.56d48fe → 1.0.44-pr.132.7682d55
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;
|
|
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,CA6C5C"}
|
|
@@ -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,40 @@ 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
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
+
// base64url has no `%`, so the id survives however many times the dev
|
|
103
|
+
// server decodes the request URL.
|
|
104
|
+
return `${virtual}${IMPORTER_QUERY}${Buffer.from(importer.split("?")[0]).toString("base64url")}`;
|
|
95
105
|
},
|
|
96
106
|
load(id) {
|
|
97
|
-
if (!id.startsWith(
|
|
107
|
+
if (!id.startsWith("\0"))
|
|
98
108
|
return null;
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
if (id !== RESOLVED)
|
|
109
|
+
const [specifier = "", importer] = id.slice(1).split(IMPORTER_QUERY);
|
|
110
|
+
const reason = unsupportedReason(specifier);
|
|
111
|
+
if (specifier !== SPECIFIER && !reason)
|
|
104
112
|
return null;
|
|
113
|
+
const from = importer ? ` Imported from ${Buffer.from(importer, "base64url").toString()}.` : "";
|
|
114
|
+
if (reason)
|
|
115
|
+
this.error(`"${specifier}" is not available in server routes. ${reason}${from}`);
|
|
105
116
|
// `cloudflare:workers` has no browser equivalent, so a client-side import
|
|
106
117
|
// would bundle a module that cannot run. Fail with the reason instead.
|
|
107
118
|
if (this.environment?.name === "client") {
|
|
108
|
-
this.error(`"${SPECIFIER}" is server-only. Move this import into a server route
|
|
119
|
+
this.error(`"${SPECIFIER}" is server-only. Move this import into a server route.${from}`);
|
|
109
120
|
}
|
|
110
121
|
return RUNTIME_MODULE;
|
|
111
122
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base44-runtime-plugin.js","sourceRoot":"","sources":["../src/base44-runtime-plugin.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,SAAS,GAAG,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"base44-runtime-plugin.js","sourceRoot":"","sources":["../src/base44-runtime-plugin.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,SAAS,GAAG,gBAAgB,CAAC;AAEnC,+EAA+E;AAC/E,iFAAiF;AACjF,sEAAsE;AACtE,MAAM,aAAa,GACjB,8EAA8E,CAAC;AAEjF,SAAS,iBAAiB,CAAC,EAAU;IACnC,IAAI,EAAE,KAAK,uBAAuB;QAAE,OAAO,aAAa,CAAC;IACzD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;CAsBtB,CAAC;AAEF,MAAM,cAAc,GAAG,YAAY,CAAC;AAEpC,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,0EAA0E;QAC1E,+BAA+B;QAC/B,OAAO,EAAE,KAAK;QAEd,8EAA8E;QAC9E,uEAAuE;QACvE,6EAA6E;QAC7E,uEAAuE;QACvE,6EAA6E;QAC7E,4EAA4E;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C,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC;YAE7F,0EAA0E;YAC1E,uEAAuE;YACvE,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACxC,IAAI,CAAC,KAAK,CAAC,IAAI,SAAS,0DAA0D,IAAI,EAAE,CAAC,CAAC;YAC5F,CAAC;YACD,OAAO,cAAc,CAAC;QACxB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -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,38 @@ 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
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
|
|
100
|
-
|
|
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
|
+
// base64url has no `%`, so the id survives however many times the dev
|
|
110
|
+
// server decodes the request URL.
|
|
111
|
+
return `${virtual}${IMPORTER_QUERY}${Buffer.from(importer.split("?")[0]!).toString("base64url")}`;
|
|
102
112
|
},
|
|
103
113
|
|
|
104
114
|
load(id) {
|
|
105
|
-
if (!id.startsWith(
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
115
|
+
if (!id.startsWith("\0")) return null;
|
|
116
|
+
const [specifier = "", importer] = id.slice(1).split(IMPORTER_QUERY);
|
|
117
|
+
const reason = unsupportedReason(specifier);
|
|
118
|
+
if (specifier !== SPECIFIER && !reason) return null;
|
|
119
|
+
const from = importer ? ` Imported from ${Buffer.from(importer, "base64url").toString()}.` : "";
|
|
120
|
+
|
|
121
|
+
if (reason) this.error(`"${specifier}" is not available in server routes. ${reason}${from}`);
|
|
111
122
|
|
|
112
123
|
// `cloudflare:workers` has no browser equivalent, so a client-side import
|
|
113
124
|
// would bundle a module that cannot run. Fail with the reason instead.
|
|
114
125
|
if (this.environment?.name === "client") {
|
|
115
|
-
this.error(`"${SPECIFIER}" is server-only. Move this import into a server route
|
|
126
|
+
this.error(`"${SPECIFIER}" is server-only. Move this import into a server route.${from}`);
|
|
116
127
|
}
|
|
117
128
|
return RUNTIME_MODULE;
|
|
118
129
|
},
|