@base44-preview/vite-plugin 1.0.36-pr.122.b6b8bb5 → 1.0.36-pr.122.cc41b41
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;AA4EnC,wBAAgB,mBAAmB,IAAI,MAAM,CA0B5C"}
|
|
@@ -24,23 +24,27 @@ const SPECIFIER = "base44:runtime";
|
|
|
24
24
|
// Rollup convention: a resolved virtual id starts with NUL so no other plugin
|
|
25
25
|
// (and no filesystem lookup) tries to claim it.
|
|
26
26
|
const RESOLVED = "\0base44:runtime";
|
|
27
|
-
// Reserved so a
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
const ACTORS_REASON = "Actors need Durable Object bindings and migrations on the deployed script, which full-stack apps do not have yet.";
|
|
32
|
-
const PRIVATE_DATA_SOURCES_REASON = "Private data sources need Hyperdrive/VPC bindings and the activation handshake on the deployed script, which full-stack apps do not have yet.";
|
|
27
|
+
// Reserved so a route importing it fails with an explanation instead of a bare
|
|
28
|
+
// "failed to resolve import". Actors are never imported — they live in the app's
|
|
29
|
+
// actors directory, in server routes exactly as in backend functions.
|
|
30
|
+
const ACTORS_REASON = "Actors are defined in the app's actors directory, not imported into a route.";
|
|
33
31
|
function unsupportedReason(id) {
|
|
34
32
|
if (id === "base44:runtime/actors")
|
|
35
33
|
return ACTORS_REASON;
|
|
36
|
-
if (id === "base44:private-data-sources" || id.startsWith("base44:private-data-sources/")) {
|
|
37
|
-
return PRIVATE_DATA_SOURCES_REASON;
|
|
38
|
-
}
|
|
39
34
|
return null;
|
|
40
35
|
}
|
|
41
36
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
37
|
+
* `cloudflare:workers` stays external — workerd provides it, and Nitro's
|
|
38
|
+
* cloudflare preset already treats `cloudflare:*` that way.
|
|
39
|
+
*
|
|
40
|
+
* There is deliberately no separate dev body. Nitro's `cloudflareDev` preset
|
|
41
|
+
* (aliased for `cloudflare-module`, which is what these apps build with) sets
|
|
42
|
+
* `devServer.runner: "miniflare"`, so dev runs in workerd too and the same
|
|
43
|
+
* import resolves there. A `process.env` fallback would buy nothing and cost a
|
|
44
|
+
* dev/prod behaviour split — the shape that makes background work silently
|
|
45
|
+
* vanish locally while working in production. If someone overrides the runner
|
|
46
|
+
* away from workerd, this fails loudly at resolution rather than quietly
|
|
47
|
+
* serving a different value.
|
|
44
48
|
*
|
|
45
49
|
* `waitUntil` is WRAPPED rather than re-exported: ours returns the promise so it
|
|
46
50
|
* composes (`infra/base44-userapp-bundler/src/runtime/index.ts` in apper),
|
|
@@ -48,7 +52,7 @@ function unsupportedReason(id) {
|
|
|
48
52
|
* work in a backend function and silently yield `undefined` here — one specifier
|
|
49
53
|
* with two behaviours is the exact failure this module exists to prevent.
|
|
50
54
|
*/
|
|
51
|
-
const
|
|
55
|
+
const RUNTIME_MODULE = `
|
|
52
56
|
import { env, waitUntil as cfWaitUntil } from "cloudflare:workers";
|
|
53
57
|
|
|
54
58
|
export function waitUntil(promise) {
|
|
@@ -63,60 +67,28 @@ export const secrets = {
|
|
|
63
67
|
},
|
|
64
68
|
};
|
|
65
69
|
`;
|
|
66
|
-
/**
|
|
67
|
-
* Dev body. `vite dev` may run the server environment outside workerd, where
|
|
68
|
-
* `cloudflare:workers` does not exist, so dev reads the same values from
|
|
69
|
-
* `process.env` — which Nitro populates from the local binding set.
|
|
70
|
-
*
|
|
71
|
-
* `waitUntil` here deliberately keeps the promise alive and lets a rejection
|
|
72
|
-
* surface rather than swallowing it. A no-op would make background work vanish
|
|
73
|
-
* in dev while working in production, which is the single nastiest shape this
|
|
74
|
-
* shim can take.
|
|
75
|
-
*/
|
|
76
|
-
const DEV_BODY = `
|
|
77
|
-
export function waitUntil(promise) {
|
|
78
|
-
Promise.resolve(promise).catch((error) => {
|
|
79
|
-
console.error("[base44] waitUntil promise rejected:", error);
|
|
80
|
-
});
|
|
81
|
-
return promise;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export const secrets = {
|
|
85
|
-
get(name) {
|
|
86
|
-
const value = process.env[name];
|
|
87
|
-
return typeof value === "string" ? value : undefined;
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
`;
|
|
91
70
|
export function base44RuntimePlugin() {
|
|
92
|
-
let isDev = false;
|
|
93
71
|
return {
|
|
94
72
|
name: "base44-runtime",
|
|
95
73
|
// Ahead of Vite's own resolution so the bare `base44:` specifier is never
|
|
96
74
|
// mistaken for a URL protocol.
|
|
97
75
|
enforce: "pre",
|
|
98
|
-
configResolved(config) {
|
|
99
|
-
isDev = config.command === "serve";
|
|
100
|
-
},
|
|
101
76
|
resolveId(id) {
|
|
102
77
|
const reason = unsupportedReason(id);
|
|
103
78
|
if (reason) {
|
|
104
|
-
this.error(`"${id}" is not available in
|
|
79
|
+
this.error(`"${id}" is not available in server routes. ${reason}`);
|
|
105
80
|
}
|
|
106
81
|
if (id !== SPECIFIER)
|
|
107
82
|
return null;
|
|
108
83
|
// `cloudflare:workers` has no browser equivalent, so a client-side import
|
|
109
84
|
// would bundle a module that cannot run. Fail with the reason instead.
|
|
110
85
|
if (this.environment?.name === "client") {
|
|
111
|
-
this.error(`"${SPECIFIER}" is server-only
|
|
112
|
-
`exist in the browser. Move this import into a server route under src/server/.`);
|
|
86
|
+
this.error(`"${SPECIFIER}" is server-only. Move this import into a server route.`);
|
|
113
87
|
}
|
|
114
88
|
return RESOLVED;
|
|
115
89
|
},
|
|
116
90
|
load(id) {
|
|
117
|
-
|
|
118
|
-
return null;
|
|
119
|
-
return isDev ? DEV_BODY : WORKER_BODY;
|
|
91
|
+
return id === RESOLVED ? RUNTIME_MODULE : null;
|
|
120
92
|
},
|
|
121
93
|
};
|
|
122
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base44-runtime-plugin.js","sourceRoot":"","sources":["../src/base44-runtime-plugin.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,SAAS,GAAG,gBAAgB,CAAC;AACnC,8EAA8E;AAC9E,gDAAgD;AAChD,MAAM,QAAQ,GAAG,kBAAkB,CAAC;AAEpC
|
|
1
|
+
{"version":3,"file":"base44-runtime-plugin.js","sourceRoot":"","sources":["../src/base44-runtime-plugin.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,SAAS,GAAG,gBAAgB,CAAC;AACnC,8EAA8E;AAC9E,gDAAgD;AAChD,MAAM,QAAQ,GAAG,kBAAkB,CAAC;AAEpC,+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;;;;;;;;;;;;;;CActB,CAAC;AAEF,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,0EAA0E;QAC1E,+BAA+B;QAC/B,OAAO,EAAE,KAAK;QAEd,SAAS,CAAC,EAAE;YACV,MAAM,MAAM,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC;YACrC,IAAI,MAAM,EAAE,CAAC;gBACX,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,wCAAwC,MAAM,EAAE,CAAC,CAAC;YACrE,CAAC;YACD,IAAI,EAAE,KAAK,SAAS;gBAAE,OAAO,IAAI,CAAC;YAElC,0EAA0E;YAC1E,uEAAuE;YACvE,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACxC,IAAI,CAAC,KAAK,CAAC,IAAI,SAAS,yDAAyD,CAAC,CAAC;YACrF,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,IAAI,CAAC,EAAE;YACL,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC;QACjD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -28,26 +28,29 @@ const SPECIFIER = "base44:runtime";
|
|
|
28
28
|
// (and no filesystem lookup) tries to claim it.
|
|
29
29
|
const RESOLVED = "\0base44:runtime";
|
|
30
30
|
|
|
31
|
-
// Reserved so a
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
// module here — see the PR description.
|
|
31
|
+
// Reserved so a route importing it fails with an explanation instead of a bare
|
|
32
|
+
// "failed to resolve import". Actors are never imported — they live in the app's
|
|
33
|
+
// actors directory, in server routes exactly as in backend functions.
|
|
35
34
|
const ACTORS_REASON =
|
|
36
|
-
"Actors
|
|
37
|
-
const PRIVATE_DATA_SOURCES_REASON =
|
|
38
|
-
"Private data sources need Hyperdrive/VPC bindings and the activation handshake on the deployed script, which full-stack apps do not have yet.";
|
|
35
|
+
"Actors are defined in the app's actors directory, not imported into a route.";
|
|
39
36
|
|
|
40
37
|
function unsupportedReason(id: string): string | null {
|
|
41
38
|
if (id === "base44:runtime/actors") return ACTORS_REASON;
|
|
42
|
-
if (id === "base44:private-data-sources" || id.startsWith("base44:private-data-sources/")) {
|
|
43
|
-
return PRIVATE_DATA_SOURCES_REASON;
|
|
44
|
-
}
|
|
45
39
|
return null;
|
|
46
40
|
}
|
|
47
41
|
|
|
48
42
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
43
|
+
* `cloudflare:workers` stays external — workerd provides it, and Nitro's
|
|
44
|
+
* cloudflare preset already treats `cloudflare:*` that way.
|
|
45
|
+
*
|
|
46
|
+
* There is deliberately no separate dev body. Nitro's `cloudflareDev` preset
|
|
47
|
+
* (aliased for `cloudflare-module`, which is what these apps build with) sets
|
|
48
|
+
* `devServer.runner: "miniflare"`, so dev runs in workerd too and the same
|
|
49
|
+
* import resolves there. A `process.env` fallback would buy nothing and cost a
|
|
50
|
+
* dev/prod behaviour split — the shape that makes background work silently
|
|
51
|
+
* vanish locally while working in production. If someone overrides the runner
|
|
52
|
+
* away from workerd, this fails loudly at resolution rather than quietly
|
|
53
|
+
* serving a different value.
|
|
51
54
|
*
|
|
52
55
|
* `waitUntil` is WRAPPED rather than re-exported: ours returns the promise so it
|
|
53
56
|
* composes (`infra/base44-userapp-bundler/src/runtime/index.ts` in apper),
|
|
@@ -55,7 +58,7 @@ function unsupportedReason(id: string): string | null {
|
|
|
55
58
|
* work in a backend function and silently yield `undefined` here — one specifier
|
|
56
59
|
* with two behaviours is the exact failure this module exists to prevent.
|
|
57
60
|
*/
|
|
58
|
-
const
|
|
61
|
+
const RUNTIME_MODULE = `
|
|
59
62
|
import { env, waitUntil as cfWaitUntil } from "cloudflare:workers";
|
|
60
63
|
|
|
61
64
|
export function waitUntil(promise) {
|
|
@@ -71,68 +74,30 @@ export const secrets = {
|
|
|
71
74
|
};
|
|
72
75
|
`;
|
|
73
76
|
|
|
74
|
-
/**
|
|
75
|
-
* Dev body. `vite dev` may run the server environment outside workerd, where
|
|
76
|
-
* `cloudflare:workers` does not exist, so dev reads the same values from
|
|
77
|
-
* `process.env` — which Nitro populates from the local binding set.
|
|
78
|
-
*
|
|
79
|
-
* `waitUntil` here deliberately keeps the promise alive and lets a rejection
|
|
80
|
-
* surface rather than swallowing it. A no-op would make background work vanish
|
|
81
|
-
* in dev while working in production, which is the single nastiest shape this
|
|
82
|
-
* shim can take.
|
|
83
|
-
*/
|
|
84
|
-
const DEV_BODY = `
|
|
85
|
-
export function waitUntil(promise) {
|
|
86
|
-
Promise.resolve(promise).catch((error) => {
|
|
87
|
-
console.error("[base44] waitUntil promise rejected:", error);
|
|
88
|
-
});
|
|
89
|
-
return promise;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export const secrets = {
|
|
93
|
-
get(name) {
|
|
94
|
-
const value = process.env[name];
|
|
95
|
-
return typeof value === "string" ? value : undefined;
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
`;
|
|
99
|
-
|
|
100
77
|
export function base44RuntimePlugin(): Plugin {
|
|
101
|
-
let isDev = false;
|
|
102
|
-
|
|
103
78
|
return {
|
|
104
79
|
name: "base44-runtime",
|
|
105
80
|
// Ahead of Vite's own resolution so the bare `base44:` specifier is never
|
|
106
81
|
// mistaken for a URL protocol.
|
|
107
82
|
enforce: "pre",
|
|
108
83
|
|
|
109
|
-
configResolved(config) {
|
|
110
|
-
isDev = config.command === "serve";
|
|
111
|
-
},
|
|
112
|
-
|
|
113
84
|
resolveId(id) {
|
|
114
85
|
const reason = unsupportedReason(id);
|
|
115
86
|
if (reason) {
|
|
116
|
-
this.error(
|
|
117
|
-
`"${id}" is not available in full-stack server routes. ${reason}`
|
|
118
|
-
);
|
|
87
|
+
this.error(`"${id}" is not available in server routes. ${reason}`);
|
|
119
88
|
}
|
|
120
89
|
if (id !== SPECIFIER) return null;
|
|
121
90
|
|
|
122
91
|
// `cloudflare:workers` has no browser equivalent, so a client-side import
|
|
123
92
|
// would bundle a module that cannot run. Fail with the reason instead.
|
|
124
93
|
if (this.environment?.name === "client") {
|
|
125
|
-
this.error(
|
|
126
|
-
`"${SPECIFIER}" is server-only — it reads Worker bindings, which do not ` +
|
|
127
|
-
`exist in the browser. Move this import into a server route under src/server/.`
|
|
128
|
-
);
|
|
94
|
+
this.error(`"${SPECIFIER}" is server-only. Move this import into a server route.`);
|
|
129
95
|
}
|
|
130
96
|
return RESOLVED;
|
|
131
97
|
},
|
|
132
98
|
|
|
133
99
|
load(id) {
|
|
134
|
-
|
|
135
|
-
return isDev ? DEV_BODY : WORKER_BODY;
|
|
100
|
+
return id === RESOLVED ? RUNTIME_MODULE : null;
|
|
136
101
|
},
|
|
137
102
|
};
|
|
138
103
|
}
|