Skip to content

Conversation

@xenova
Copy link
Collaborator

@xenova xenova commented Jun 2, 2025

Closes #1332

  • Uses node: prefixes for built-in libraries, ensuring standardization across node, bun, and deno runtimes
  • Disable browser cache by default in Deno runtime (because the web cache API is available, but our URLs are not valid because we are using relative file paths due to the filesystem access we have)

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@xenova
Copy link
Collaborator Author

xenova commented Jun 19, 2025

For posterity, I was working on improving cloudflare worker integration, but I wasn't able to get it working. Here are things I learned (mainly for future me):

  1. You can use conditional exports that cloudflare workers will use specifically:
  "exports": {
    ...
    "worker": {
      "types": "./types/transformers.d.ts",
      "default": "./dist/transformers.js"
    },
    ...
  },
  1. Cloudflare workers don't support relative URLs (e.g., new URL('.') is invalid)
  2. Cloudflare workers don't support .node addon binaries (Node Addon binaries in Cloudflare Workers? cloudflare/workerd#1905 (comment)). This is unlikely to change in future.
  3. Cloudflare workers disable wasm code generation ([🐛 Bug]: WebAssembly.instantiate(): Wasm code generation disallowed by embedder cloudflare/next-on-pages#704) - this is a security consideration and is unlikely to change in future.
  4. You can detect cloudflare worker environment simply with typeof globalThis.Cloudflare !== 'undefined'

@xenova xenova merged commit a5847c9 into main Jun 19, 2025
4 checks passed
@xenova xenova deleted the deno-bun-improvements branch June 19, 2025 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: Cannot read properties of undefined (reading 'create')

3 participants