Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

cloudflare: root entry eagerly imports `wrangler`, so `d1`/`r2`/`kvCache` cannot load without a Wrangler install

Closed Beginner friendly
#4,232 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@emdashbot is already working on this.

Since Oct 17, 2026.

  • #4234 by @emdashbot — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
cloud

Research direction

Start with dist/index.mjs, where the issue identifies the eager Wrangler import and its use in sandbox(). Reproduce the reported d1/r2/kvCache import with Wrangler absent, then check whether the root entry can load without it. Done means those descriptors are importable without Wrangler while the optional sandbox behavior remains available.

Written by the indexing model from the issue text.

Description

area/cloudflare bot:bug bot:needs-attention

Summary

@emdash-cms/cloudflare's root entry eagerly imports wrangler at module load:

// dist/index.mjs, line 1
import { unstable_readConfig } from "wrangler";

The only use is inside sandbox():

function sandbox() {
  const environment = process.env.CLOUDFLARE_ENV;
  if (!unstable_readConfig(environment ? { env: environment } : {}, { hideWarnings: true })
        .worker_loaders?.some((loader) => loader.binding === "LOADER")) {
    console.warn("[emdash] Sandboxed plugins are disabled because wrangler.jsonc has no LOADER Worker Loader binding. ...");
    return;
  }
  return "@emdash-cms/cloudflare/sandbox";
}

So a project that never calls sandbox() — and therefore never needs a Wrangler
config at all — still cannot import d1 / r2 / kvCache unless the wrangler
package is installed.

Impact

Deploying through a non-Wrangler tool (Alchemy's Cloudflare.Website.Astro, in
our case) means no wrangler.jsonc and no reason to install wrangler. Importing
the config helpers then fails at config-load time:

ERR_MODULE_NOT_FOUND: Cannot find package 'wrangler' imported from
  node_modules/@emdash-cms/cloudflare/dist/index.mjs

Nothing in that path calls sandbox(); the failure is purely the eager import.

Reproduce

// astro.config.mjs
import { d1, r2, kvCache } from "@emdash-cms/cloudflare";

with wrangler absent from the dependency tree (e.g. autoInstallPeers: false,
or a pnpm workspace where the peer is not otherwise pulled in).

Note the peer declaration alone is not the issue — the package is declared as a
required peer, so pnpm installs it. The problem is that a deploy-tool-specific
dependency is reachable from the root entry at all: any resolution that does not
install the peer makes the whole config unloadable.

Suggested fix

Make the Wrangler access lazy, so the root entry is usable without wrangler:

async function sandbox() {
  const { unstable_readConfig } = await import("wrangler");
  ...
}

(sandbox() is already async-shaped/optional in practice — it returns a module
path or undefined.) Alternatively move sandbox() behind its own subpath
(e.g. @emdash-cms/cloudflare/sandbox-config) so importing the descriptors does
not pull Wrangler in. Making wrangler an optional peer would match either
change.

Environment

emdash / @emdash-cms/cloudflare 1.2.0
astro 7.3.5
deploy Alchemy Cloudflare.Website.Astro (no Wrangler config)

This looks adjacent to #3639 (Cloudflare config only read from Wrangler files)
and #2841 (Wrangler config not auto-discovered), but is narrower: it is not about
reading a Wrangler config, it is about the package being unimportable when
Wrangler is absent.

Dominant language
TypeScript
Stars
13.4k
Forks
1.3k
Avg merge
1d 18h
Merged PRs (30d)
571

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from emdash-cms/emdash

All issues in emdash-cms/emdash

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.