Skip to content

fix(evlog): replace require() with dynamic import() for workers compat#228

Merged
HugoRCD merged 3 commits intoHugoRCD:mainfrom
shubh73:fix/replace-require-with-dynamic-import
Mar 24, 2026
Merged

fix(evlog): replace require() with dynamic import() for workers compat#228
HugoRCD merged 3 commits intoHugoRCD:mainfrom
shubh73:fix/replace-require-with-dynamic-import

Conversation

@shubh73
Copy link
Contributor

@shubh73 shubh73 commented Mar 22, 2026

📚 Description

_config.ts uses require('nitropack/runtime') and require('nitro/runtime-config') inside try-catch, but rolldown injects a top-level createRequire(import.meta.url) polyfill into the shared _http chunk that runs at module evaluation time, crashing workers:

Screenshot 2026-03-23 at 12 52 22 AM

Before / After

import { createRequire } from "node:module";
var __require = /* @__PURE__ */ createRequire(import.meta.url); // ← crashes cf workers

After  patched _http chunk:
async function getRuntimeConfig() {
  try {
    const { useRuntimeConfig } = await import("nitropack/runtime"); // ← no polyfill needed
    return useRuntimeConfig();
  } catch {}
  // ...
}

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@vercel
Copy link

vercel bot commented Mar 22, 2026

@shubh73 is attempting to deploy a commit to the HRCD Projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added the bug Something isn't working label Mar 22, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 22, 2026

Thank you for following the naming conventions! 🙏

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 22, 2026

npm i https://pkg.pr.new/evlog@228
npm i https://pkg.pr.new/@evlog/nuxthub@228

commit: 7b74869

@HugoRCD HugoRCD merged commit 4385dbc into HugoRCD:main Mar 24, 2026
10 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants