Cross-Runtime Usage
Run Fileway on Bun, Deno, and Cloudflare Workers
Fileway universal packages (@fileway/core, @fileway/driver-s3, @fileway/driver-cloudinary) contain zero node:* imports and work on any JavaScript runtime. Only @fileway/driver-local requires Node.js (uses node:fs).
Bun
Bun has built-in Node.js compatibility and TypeScript support — run scripts directly:
# S3
S3_BUCKET=my-bucket AWS_ACCESS_KEY_ID=xxx AWS_SECRET_ACCESS_KEY=yyy \
bun run packages/driver-s3/test-upload.mjs
# Cloudinary
CLOUDINARY_CLOUD_NAME=my-cloud CLOUDINARY_API_KEY=xxx CLOUDINARY_API_SECRET=yyy \
bun run packages/driver-cloudinary/test-upload.mjs
# Local (works via Bun's Node API compat)
bun run packages/driver-local/test-upload.mjsRun vitest tests with Bun's test runner:
bun testDeno
Deno can import npm packages via npm: specifiers:
deno run --allow-read --allow-env --allow-net \
packages/driver-cloudinary/test-upload.mjsIf workspace resolution fails, use explicit npm paths:
deno run --allow-read --allow-env --allow-net \
npm:@fileway/driver-cloudinary packages/driver-cloudinary/test-upload.mjsdriver-local is not supported on Deno (no node:fs).
Cloudflare Workers
Vitest (unit tests)
@fileway/core and @fileway/driver-cloudinary already run tests under @edge-runtime/vm via vitest. Run:
pnpm --filter @fileway/core test
pnpm --filter @fileway/driver-cloudinary testWrangler (integration tests)
Create a minimal worker to test uploads locally:
npx wrangler init test-workerAdd @fileway/core and @fileway/driver-s3 as dependencies, then write:
import { FilewayClient } from "@fileway/core";
import { S3Driver } from "@fileway/driver-s3";
export default {
async fetch(req: Request): Promise<Response> {
const client = new FilewayClient({
driver: new S3Driver({
bucket: "my-bucket",
endpoint: "https://<account>.r2.cloudflarestorage.com",
region: "auto",
}),
});
const stream = req.body! as ReadableStream<Uint8Array>;
const result = await client.upload(stream, {
filename: "upload.txt",
path: "uploads",
});
return Response.json(result);
},
};Run locally:
npx wrangler devCompatibility Matrix
| Runtime | @fileway/core | driver-local | driver-s3 | driver-cloudinary |
|---|---|---|---|---|
| Node.js 18+ | ✓ | ✓ | ✓ | ✓ |
| Bun | ✓ | ✓ | ✓ | ✓ |
| Deno | ✓ | ✗ | ✓ | ✓ |
| Cloudflare Workers | ✓ | ✗ | ✓ | ✓ |
| Edge runtimes | ✓ | ✗ | ✓ | ✓ |