@base44-preview/vite-plugin 1.0.36-pr.122.b6b8bb5 → 1.0.36-pr.122.e4e2114
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;AAkFnC,wBAAgB,mBAAmB,IAAI,MAAM,CA0B5C"}
|
|
@@ -28,8 +28,8 @@ const RESOLVED = "\0base44:runtime";
|
|
|
28
28
|
// a bare "failed to resolve import". Both need bindings on the deployed script
|
|
29
29
|
// that full-stack uploads do not carry yet, so neither can work by resolving a
|
|
30
30
|
// module here — see the PR description.
|
|
31
|
-
const ACTORS_REASON = "Actors
|
|
32
|
-
const PRIVATE_DATA_SOURCES_REASON = "Private data sources
|
|
31
|
+
const ACTORS_REASON = "Actors are defined in the app's actors directory, not imported into a route.";
|
|
32
|
+
const PRIVATE_DATA_SOURCES_REASON = "Private data sources are not wired into server routes.";
|
|
33
33
|
function unsupportedReason(id) {
|
|
34
34
|
if (id === "base44:runtime/actors")
|
|
35
35
|
return ACTORS_REASON;
|
|
@@ -39,8 +39,17 @@ function unsupportedReason(id) {
|
|
|
39
39
|
return null;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* `cloudflare:workers` stays external — workerd provides it, and Nitro's
|
|
43
|
+
* cloudflare preset already treats `cloudflare:*` that way.
|
|
44
|
+
*
|
|
45
|
+
* There is deliberately no separate dev body. Nitro's `cloudflareDev` preset
|
|
46
|
+
* (aliased for `cloudflare-module`, which is what these apps build with) sets
|
|
47
|
+
* `devServer.runner: "miniflare"`, so dev runs in workerd too and the same
|
|
48
|
+
* import resolves there. A `process.env` fallback would buy nothing and cost a
|
|
49
|
+
* dev/prod behaviour split — the shape that makes background work silently
|
|
50
|
+
* vanish locally while working in production. If someone overrides the runner
|
|
51
|
+
* away from workerd, this fails loudly at resolution rather than quietly
|
|
52
|
+
* serving a different value.
|
|
44
53
|
*
|
|
45
54
|
* `waitUntil` is WRAPPED rather than re-exported: ours returns the promise so it
|
|
46
55
|
* composes (`infra/base44-userapp-bundler/src/runtime/index.ts` in apper),
|
|
@@ -48,7 +57,7 @@ function unsupportedReason(id) {
|
|
|
48
57
|
* work in a backend function and silently yield `undefined` here — one specifier
|
|
49
58
|
* with two behaviours is the exact failure this module exists to prevent.
|
|
50
59
|
*/
|
|
51
|
-
const
|
|
60
|
+
const RUNTIME_MODULE = `
|
|
52
61
|
import { env, waitUntil as cfWaitUntil } from "cloudflare:workers";
|
|
53
62
|
|
|
54
63
|
export function waitUntil(promise) {
|
|
@@ -63,60 +72,28 @@ export const secrets = {
|
|
|
63
72
|
},
|
|
64
73
|
};
|
|
65
74
|
`;
|
|
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
75
|
export function base44RuntimePlugin() {
|
|
92
|
-
let isDev = false;
|
|
93
76
|
return {
|
|
94
77
|
name: "base44-runtime",
|
|
95
78
|
// Ahead of Vite's own resolution so the bare `base44:` specifier is never
|
|
96
79
|
// mistaken for a URL protocol.
|
|
97
80
|
enforce: "pre",
|
|
98
|
-
configResolved(config) {
|
|
99
|
-
isDev = config.command === "serve";
|
|
100
|
-
},
|
|
101
81
|
resolveId(id) {
|
|
102
82
|
const reason = unsupportedReason(id);
|
|
103
83
|
if (reason) {
|
|
104
|
-
this.error(`"${id}" is not available in
|
|
84
|
+
this.error(`"${id}" is not available in server routes. ${reason}`);
|
|
105
85
|
}
|
|
106
86
|
if (id !== SPECIFIER)
|
|
107
87
|
return null;
|
|
108
88
|
// `cloudflare:workers` has no browser equivalent, so a client-side import
|
|
109
89
|
// would bundle a module that cannot run. Fail with the reason instead.
|
|
110
90
|
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/.`);
|
|
91
|
+
this.error(`"${SPECIFIER}" is server-only. Move this import into a server route.`);
|
|
113
92
|
}
|
|
114
93
|
return RESOLVED;
|
|
115
94
|
},
|
|
116
95
|
load(id) {
|
|
117
|
-
|
|
118
|
-
return null;
|
|
119
|
-
return isDev ? DEV_BODY : WORKER_BODY;
|
|
96
|
+
return id === RESOLVED ? RUNTIME_MODULE : null;
|
|
120
97
|
},
|
|
121
98
|
};
|
|
122
99
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base44-runtime-plugin.js","sourceRoot":"","sources":["../src/base44-runtime-plugin.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;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ACD,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
|
@@ -33,9 +33,9 @@ const RESOLVED = "\0base44:runtime";
|
|
|
33
33
|
// that full-stack uploads do not carry yet, so neither can work by resolving a
|
|
34
34
|
// module here — see the PR description.
|
|
35
35
|
const ACTORS_REASON =
|
|
36
|
-
"Actors
|
|
36
|
+
"Actors are defined in the app's actors directory, not imported into a route.";
|
|
37
37
|
const PRIVATE_DATA_SOURCES_REASON =
|
|
38
|
-
"Private data sources
|
|
38
|
+
"Private data sources are not wired into server routes.";
|
|
39
39
|
|
|
40
40
|
function unsupportedReason(id: string): string | null {
|
|
41
41
|
if (id === "base44:runtime/actors") return ACTORS_REASON;
|
|
@@ -46,8 +46,17 @@ function unsupportedReason(id: string): string | null {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
49
|
+
* `cloudflare:workers` stays external — workerd provides it, and Nitro's
|
|
50
|
+
* cloudflare preset already treats `cloudflare:*` that way.
|
|
51
|
+
*
|
|
52
|
+
* There is deliberately no separate dev body. Nitro's `cloudflareDev` preset
|
|
53
|
+
* (aliased for `cloudflare-module`, which is what these apps build with) sets
|
|
54
|
+
* `devServer.runner: "miniflare"`, so dev runs in workerd too and the same
|
|
55
|
+
* import resolves there. A `process.env` fallback would buy nothing and cost a
|
|
56
|
+
* dev/prod behaviour split — the shape that makes background work silently
|
|
57
|
+
* vanish locally while working in production. If someone overrides the runner
|
|
58
|
+
* away from workerd, this fails loudly at resolution rather than quietly
|
|
59
|
+
* serving a different value.
|
|
51
60
|
*
|
|
52
61
|
* `waitUntil` is WRAPPED rather than re-exported: ours returns the promise so it
|
|
53
62
|
* composes (`infra/base44-userapp-bundler/src/runtime/index.ts` in apper),
|
|
@@ -55,7 +64,7 @@ function unsupportedReason(id: string): string | null {
|
|
|
55
64
|
* work in a backend function and silently yield `undefined` here — one specifier
|
|
56
65
|
* with two behaviours is the exact failure this module exists to prevent.
|
|
57
66
|
*/
|
|
58
|
-
const
|
|
67
|
+
const RUNTIME_MODULE = `
|
|
59
68
|
import { env, waitUntil as cfWaitUntil } from "cloudflare:workers";
|
|
60
69
|
|
|
61
70
|
export function waitUntil(promise) {
|
|
@@ -71,68 +80,30 @@ export const secrets = {
|
|
|
71
80
|
};
|
|
72
81
|
`;
|
|
73
82
|
|
|
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
83
|
export function base44RuntimePlugin(): Plugin {
|
|
101
|
-
let isDev = false;
|
|
102
|
-
|
|
103
84
|
return {
|
|
104
85
|
name: "base44-runtime",
|
|
105
86
|
// Ahead of Vite's own resolution so the bare `base44:` specifier is never
|
|
106
87
|
// mistaken for a URL protocol.
|
|
107
88
|
enforce: "pre",
|
|
108
89
|
|
|
109
|
-
configResolved(config) {
|
|
110
|
-
isDev = config.command === "serve";
|
|
111
|
-
},
|
|
112
|
-
|
|
113
90
|
resolveId(id) {
|
|
114
91
|
const reason = unsupportedReason(id);
|
|
115
92
|
if (reason) {
|
|
116
|
-
this.error(
|
|
117
|
-
`"${id}" is not available in full-stack server routes. ${reason}`
|
|
118
|
-
);
|
|
93
|
+
this.error(`"${id}" is not available in server routes. ${reason}`);
|
|
119
94
|
}
|
|
120
95
|
if (id !== SPECIFIER) return null;
|
|
121
96
|
|
|
122
97
|
// `cloudflare:workers` has no browser equivalent, so a client-side import
|
|
123
98
|
// would bundle a module that cannot run. Fail with the reason instead.
|
|
124
99
|
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
|
-
);
|
|
100
|
+
this.error(`"${SPECIFIER}" is server-only. Move this import into a server route.`);
|
|
129
101
|
}
|
|
130
102
|
return RESOLVED;
|
|
131
103
|
},
|
|
132
104
|
|
|
133
105
|
load(id) {
|
|
134
|
-
|
|
135
|
-
return isDev ? DEV_BODY : WORKER_BODY;
|
|
106
|
+
return id === RESOLVED ? RUNTIME_MODULE : null;
|
|
136
107
|
},
|
|
137
108
|
};
|
|
138
109
|
}
|