alchemy 2.0.0-beta.49 → 2.0.0-beta.50
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.
- package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/LocalWorkerProvider.js +22 -21
- package/lib/Cloudflare/Workers/LocalWorkerProvider.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerAsyncBindings.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerAsyncBindings.js +5 -3
- package/lib/Cloudflare/Workers/WorkerAsyncBindings.js.map +1 -1
- package/lib/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/Cloudflare/Workers/LocalWorkerProvider.ts +35 -27
- package/src/Cloudflare/Workers/WorkerAsyncBindings.ts +7 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alchemy",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.50",
|
|
4
4
|
"homepage": "https://alchemy.run",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Sam Goodwin <sam@alchemy.run>",
|
|
@@ -294,9 +294,9 @@
|
|
|
294
294
|
"@distilled.cloud/aws": "^0.22.4",
|
|
295
295
|
"@distilled.cloud/axiom": "^0.22.4",
|
|
296
296
|
"@distilled.cloud/cloudflare": "^0.22.4",
|
|
297
|
-
"@distilled.cloud/cloudflare-rolldown-plugin": "0.10.
|
|
298
|
-
"@distilled.cloud/cloudflare-runtime": "0.10.
|
|
299
|
-
"@distilled.cloud/cloudflare-vite-plugin": "0.10.
|
|
297
|
+
"@distilled.cloud/cloudflare-rolldown-plugin": "0.10.2",
|
|
298
|
+
"@distilled.cloud/cloudflare-runtime": "0.10.2",
|
|
299
|
+
"@distilled.cloud/cloudflare-vite-plugin": "0.10.2",
|
|
300
300
|
"@distilled.cloud/core": "^0.22.4",
|
|
301
301
|
"@distilled.cloud/neon": "^0.22.4",
|
|
302
302
|
"@distilled.cloud/planetscale": "^0.22.4",
|
|
@@ -286,6 +286,7 @@ export const LocalWorkerProvider = () =>
|
|
|
286
286
|
workerBindings,
|
|
287
287
|
durableObjectNamespaces,
|
|
288
288
|
hyperdrives,
|
|
289
|
+
env: props.env,
|
|
289
290
|
bundleOptions: {
|
|
290
291
|
id,
|
|
291
292
|
main: props.main!,
|
|
@@ -307,7 +308,7 @@ export const LocalWorkerProvider = () =>
|
|
|
307
308
|
|
|
308
309
|
type WorkerConfig = Effect.Success<ReturnType<typeof buildConfig>>;
|
|
309
310
|
|
|
310
|
-
const
|
|
311
|
+
const runWorker = Effect.fnUntraced(function* (worker: WorkerConfig) {
|
|
311
312
|
let start = Date.now();
|
|
312
313
|
let status: "start" | "update" = "start";
|
|
313
314
|
const proxy = yield* maybeStartProxy(worker.id, worker.dev);
|
|
@@ -357,7 +358,36 @@ export const LocalWorkerProvider = () =>
|
|
|
357
358
|
Stream.runDrain,
|
|
358
359
|
Effect.forkScoped,
|
|
359
360
|
);
|
|
360
|
-
return proxy.url
|
|
361
|
+
return proxy.url;
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
const runVite = Effect.fnUntraced(function* (
|
|
365
|
+
worker: WorkerConfig,
|
|
366
|
+
rootDir: string | undefined,
|
|
367
|
+
) {
|
|
368
|
+
const proxy = yield* maybeStartProxy(worker.id, worker.dev);
|
|
369
|
+
yield* proxy.unset().pipe(Effect.forkChild);
|
|
370
|
+
const devServer = yield* Vite.viteDev(
|
|
371
|
+
rootDir,
|
|
372
|
+
worker.env ?? {},
|
|
373
|
+
{
|
|
374
|
+
compatibilityDate: worker.compatibility.date,
|
|
375
|
+
compatibilityFlags: worker.compatibility.flags,
|
|
376
|
+
worker: {
|
|
377
|
+
name: worker.name,
|
|
378
|
+
bindings: worker.workerBindings,
|
|
379
|
+
durableObjectNamespaces: toRuntimeDurableObjectNamespaces(
|
|
380
|
+
worker.durableObjectNamespaces,
|
|
381
|
+
),
|
|
382
|
+
hyperdrives: worker.hyperdrives,
|
|
383
|
+
assets: toRuntimeAssets(worker.assets),
|
|
384
|
+
},
|
|
385
|
+
context,
|
|
386
|
+
},
|
|
387
|
+
{ port: 0 },
|
|
388
|
+
);
|
|
389
|
+
yield* proxy.set(new URL(devServer.resolvedUrls!.local[0]));
|
|
390
|
+
return proxy.url;
|
|
361
391
|
});
|
|
362
392
|
|
|
363
393
|
const rootScope = yield* Effect.scope;
|
|
@@ -383,31 +413,9 @@ export const LocalWorkerProvider = () =>
|
|
|
383
413
|
}) {
|
|
384
414
|
const { props, bindings } = options;
|
|
385
415
|
const config = yield* buildConfig(options);
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
props.vite.rootDir,
|
|
390
|
-
props.env ?? {},
|
|
391
|
-
{
|
|
392
|
-
compatibilityDate: config.compatibility.date,
|
|
393
|
-
compatibilityFlags: config.compatibility.flags,
|
|
394
|
-
worker: {
|
|
395
|
-
name: config.name,
|
|
396
|
-
bindings: config.workerBindings,
|
|
397
|
-
durableObjectNamespaces: toRuntimeDurableObjectNamespaces(
|
|
398
|
-
config.durableObjectNamespaces,
|
|
399
|
-
),
|
|
400
|
-
hyperdrives: config.hyperdrives,
|
|
401
|
-
assets: toRuntimeAssets(config.assets),
|
|
402
|
-
},
|
|
403
|
-
context,
|
|
404
|
-
},
|
|
405
|
-
config.dev,
|
|
406
|
-
);
|
|
407
|
-
url = devServer.resolvedUrls!.local[0];
|
|
408
|
-
} else {
|
|
409
|
-
url = yield* runServer(config);
|
|
410
|
-
}
|
|
416
|
+
const url = yield* (
|
|
417
|
+
props.vite ? runVite(config, props.vite.rootDir) : runWorker(config)
|
|
418
|
+
).pipe(Effect.map((url) => url.toString()));
|
|
411
419
|
return {
|
|
412
420
|
workerId: config.name,
|
|
413
421
|
workerName: config.name,
|
|
@@ -41,9 +41,13 @@ export const bindWorkerAsyncBindings = Effect.fnUntraced(function* (
|
|
|
41
41
|
// Bindings can be passed as a plain resource value, an Effect that
|
|
42
42
|
// yields a resource, or an effect-class (e.g. a `Cloudflare.Worker`
|
|
43
43
|
// class). Resolve the yieldable forms before deriving binding metadata.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
// Avoid yielding outputs as this requires `RuntimeContext`;
|
|
45
|
+
// allow the engine to resolve them instead.
|
|
46
|
+
const binding = (
|
|
47
|
+
isYieldableEffectLike(bindingEff) && !Output.isOutput(bindingEff)
|
|
48
|
+
? yield* bindingEff as Effect.Effect<unknown>
|
|
49
|
+
: bindingEff
|
|
50
|
+
) as WorkerBindingResource;
|
|
47
51
|
|
|
48
52
|
const bindingMeta: InputProps<WorkerBinding> | undefined =
|
|
49
53
|
yield* asEffect(toBinding(bindingName, binding));
|