Skip to content

emdash@0.37.0 fails to build on Windows: createRequire() with a driveless file URL in @emdash-cms/registry-verification@0.3.0 #2978

Description

@Gohan-mada

Description

emdash@0.37.0 cannot be built on Windows. The build fails before it starts, with an error that blames the Astro config:

[astro] Unable to load your Astro config
The argument 'filename' must be a file URL object, file URL string, or absolute path string.
Received 'file:///emdash-registry-verification.js'

The Astro config is not at fault. The root cause is in @emdash-cms/registry-verification@0.3.0, which emdash@0.37.0 inlines into its bundle. dist/index.js line 8 contains the rolldown CJS-interop shim:

var __require = /* @__PURE__ */ createRequire("file:///emdash-registry-verification.js");

That file URL has no drive letter. On macOS and Linux it resolves to the absolute path /emdash-registry-verification.js and createRequire() accepts it. On Windows there is no such thing as a driveless absolute path, so fileURLToPath() rejects it and createRequire() throws.

The call sits at module scope, so merely importing the package throws. In a normal EmDash site the import chain is astro.config@emdash-cms/plugin-formsemdash → the inlined registry-verification, which is why it surfaces as a config-loading failure.

emdash@0.36.0 is unaffected: grep 'createRequire("file:///' node_modules/emdash/dist/*.mjs returns nothing there. This is a regression introduced in 0.37.0.

Steps to reproduce

Minimal — no EmDash site needed. On Windows:

node -e "require('module').createRequire('file:///emdash-registry-verification.js')"

Throws. With a drive letter it works:

node -e "require('module').createRequire('file:///C:/x/emdash-registry-verification.js')"

Confirmed in the published tarball:

npm pack @emdash-cms/registry-verification@0.3.0
tar xzf emdash-cms-registry-verification-0.3.0.tgz
grep -n 'createRequire(' package/dist/index.js
8:var __require = /* @__PURE__ */ createRequire("file:///emdash-registry-verification.js");

__require itself is only used twice, inside lazily-evaluated CommonJS wrappers — line 2832 (require("crypto")) and line 5059 (require("util")) — but the createRequire() call that builds it is evaluated eagerly at module scope, so the lazy wrappers do not protect it.

In a real site:

  1. On Windows, take an EmDash site on Cloudflare (Astro 7, @emdash-cms/cloudflare, @emdash-cms/plugin-forms).
  2. Upgrade emdash and @emdash-cms/cloudflare to 0.37.0, and @emdash-cms/plugin-forms to 0.2.6.
  3. npm install && npm run build
  4. The build fails with the error above. Downgrading to 0.36.0 / 0.2.5 restores a working build.

Suggested fix

dist/index.js is ESM (it opens with import { createRequire } from "node:module"), so import.meta.url is available and is the portable idiom:

var __require = /* @__PURE__ */ createRequire(import.meta.url);

Alternatively, configure the rolldown shim so it is given the real module URL rather than a synthetic file:///<name>.js placeholder.

Environment

  • emdash version: 0.37.0 (0.36.0 works)
  • @emdash-cms/cloudflare: 0.37.0
  • @emdash-cms/plugin-forms: 0.2.6
  • @emdash-cms/registry-verification: 0.3.0 (transitive, inlined into emdash)
  • Astro: 7.2.3
  • Node.js: v24.15.0
  • Runtime: Cloudflare Workers (build host is Windows)
  • OS: Windows 11

Screenshots

Not applicable — this is a build-time failure, not an interface issue.

Logs / error output

> astro build

[astro] Unable to load your Astro config

The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received 'file:///emdash-registry-verification.js'
  Location:
    node_modules/emdash/dist/api-Dz6rgoa3.mjs:3789:33
  Stack trace:
    at createRequire (node:internal/modules/cjs/loader:2039:13)
    at ModuleJob.run (node:internal/modules/esm/module_job:437:25)
    at async ModuleRunner.directRequest (node_modules/vite/dist/node/module-runner.js:1231:18)
    at async eval (node_modules/@emdash-cms/plugin-forms/src/index.ts:7:31)
    at async ModuleRunner.directRequest (node_modules/vite/dist/node/module-runner.js:1268:59)

The surrounding lines of the bundled chunk show which package it came from:

//#region ../registry-verification/dist/index.js
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __require = /* @__PURE__ */ createRequire("file:///emdash-registry-verification.js");

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions