@base44-preview/vite-plugin 1.0.44-pr.132.49617f5 → 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,33 +74,53 @@ 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
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
const [specifier = "", importer] = id.slice(1).split(IMPORTER_QUERY);
|
|
108
|
+
const reason = unsupportedReason(specifier);
|
|
109
|
+
if (specifier !== SPECIFIER && !reason)
|
|
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}`);
|
|
98
118
|
// `cloudflare:workers` has no browser equivalent, so a client-side import
|
|
99
119
|
// would bundle a module that cannot run. Fail with the reason instead.
|
|
100
120
|
if (this.environment?.name === "client") {
|
|
101
|
-
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}`);
|
|
102
122
|
}
|
|
103
|
-
return
|
|
104
|
-
},
|
|
105
|
-
load(id) {
|
|
106
|
-
return id === RESOLVED ? RUNTIME_MODULE : null;
|
|
123
|
+
return RUNTIME_MODULE;
|
|
107
124
|
},
|
|
108
125
|
};
|
|
109
126
|
}
|
|
@@ -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,g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K,CAAC,CAAC,GAAG;gBAC1F,CAAC,CAAC,EAAE,CAAC;YAEP,IAAI,MAAM;gBAAE,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",
|
|
@@ -91,28 +90,44 @@ export function base44RuntimePlugin(): Plugin {
|
|
|
91
90
|
// mistaken for a URL protocol.
|
|
92
91
|
enforce: "pre",
|
|
93
92
|
|
|
94
|
-
resolveId
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
+
// 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
|
+
: "";
|
|
100
122
|
|
|
101
|
-
|
|
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 };
|
|
123
|
+
if (reason) this.error(`"${specifier}" is not available in server routes. ${reason}${from}`);
|
|
105
124
|
|
|
106
125
|
// `cloudflare:workers` has no browser equivalent, so a client-side import
|
|
107
126
|
// would bundle a module that cannot run. Fail with the reason instead.
|
|
108
127
|
if (this.environment?.name === "client") {
|
|
109
|
-
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}`);
|
|
110
129
|
}
|
|
111
|
-
return
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
load(id) {
|
|
115
|
-
return id === RESOLVED ? RUNTIME_MODULE : null;
|
|
130
|
+
return RUNTIME_MODULE;
|
|
116
131
|
},
|
|
117
132
|
};
|
|
118
133
|
}
|