@base44-preview/vite-plugin 1.0.44-pr.132.56d48fe → 1.0.44-pr.132.5c3c2d8
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,CA+C5C"}
|
|
@@ -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,42 @@ 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
|
+
return `${virtual}${IMPORTER_QUERY}${encodeURIComponent(importer.split("?")[0])}`;
|
|
95
103
|
},
|
|
96
104
|
load(id) {
|
|
97
|
-
if (!id.startsWith(
|
|
105
|
+
if (!id.startsWith("\0"))
|
|
98
106
|
return null;
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
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
|
+
// The dev server decodes the URL once before we see it, which can leave a
|
|
112
|
+
// bare `%` from the path (`100%25` → `100%`); escape it back before decoding.
|
|
113
|
+
const from = importer
|
|
114
|
+
? ` Imported from ${decodeURIComponent(importer.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"))}.`
|
|
115
|
+
: "";
|
|
116
|
+
if (reason)
|
|
117
|
+
this.error(`"${specifier}" is not available in server routes. ${reason}${from}`);
|
|
105
118
|
// `cloudflare:workers` has no browser equivalent, so a client-side import
|
|
106
119
|
// would bundle a module that cannot run. Fail with the reason instead.
|
|
107
120
|
if (this.environment?.name === "client") {
|
|
108
|
-
this.error(`"${SPECIFIER}" is server-only. Move this import into a server route
|
|
121
|
+
this.error(`"${SPECIFIER}" is server-only. Move this import into a server route.${from}`);
|
|
109
122
|
}
|
|
110
123
|
return RUNTIME_MODULE;
|
|
111
124
|
},
|
|
@@ -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;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,IAAI,CAAC,KAAK,CAAC,IAAI,SAAS,wCAAwC,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,40 @@ 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
|
+
return `${virtual}${IMPORTER_QUERY}${encodeURIComponent(importer.split("?")[0]!)}`;
|
|
102
110
|
},
|
|
103
111
|
|
|
104
112
|
load(id) {
|
|
105
|
-
if (!id.startsWith(
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
+
// The dev server decodes the URL once before we see it, which can leave a
|
|
118
|
+
// bare `%` from the path (`100%25` → `100%`); escape it back before decoding.
|
|
119
|
+
const from = importer
|
|
120
|
+
? ` Imported from ${decodeURIComponent(importer.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"))}.`
|
|
121
|
+
: "";
|
|
122
|
+
|
|
123
|
+
if (reason) this.error(`"${specifier}" is not available in server routes. ${reason}${from}`);
|
|
111
124
|
|
|
112
125
|
// `cloudflare:workers` has no browser equivalent, so a client-side import
|
|
113
126
|
// would bundle a module that cannot run. Fail with the reason instead.
|
|
114
127
|
if (this.environment?.name === "client") {
|
|
115
|
-
this.error(`"${SPECIFIER}" is server-only. Move this import into a server route
|
|
128
|
+
this.error(`"${SPECIFIER}" is server-only. Move this import into a server route.${from}`);
|
|
116
129
|
}
|
|
117
130
|
return RUNTIME_MODULE;
|
|
118
131
|
},
|