Skip to content

Vite's unable to bundle this specific file. Checkout README

Notifications You must be signed in to change notification settings

rhymbit/astro-actions-bundle-bug

Repository files navigation

(Fixed) Cannot bundle Node.js built-in "node:async_hooks"

  • Using pnpm
  • Astro's version from package.json - "astro": "^4.8.2",
  • I'm using WSL2 on a Windows 11 PC
    ➜ uname -mprs
    Linux 5.15.146.1-microsoft-standard-WSL2 x86_64 x86_64

Fix

  • Add wrangler.toml to the root of the project
    compatibility_flags = ["nodejs_asl"]
  • Enable platformProxy and set the configPath to wrangler.toml in astro.config.mjs
      adapter: cloudflare({
      platformProxy: {
        enabled: true,
        configPath: "wrangler.toml",
      },
    }),
  • Add ssr: { noExternal: ['async_hooks'] } to astro.config.mjs
    vite: {
      ssr: {
        external: ["node:async_hooks"],
      },
    },
  • Check the astro.config.mjs file for the complete configuration

Error (Before Fix)

Just the Error part from the build step

24:37:24 [ERROR] [vite] x Build failed in 243ms
[commonjs--resolver] [plugin vite:resolve] Cannot bundle Node.js built-in "node:async_hooks" imported from "node_modules/.pnpm/astro@4.8.2_typescript@5.4.5/node_modules/astro/dist/actions/runtime/store.js". Consider disabling ssr.noExternal or remove the built-in dependency.
  Stack trace:
    at getRollupError (file:///home/rhymbit/code/astro-actions-bundle-bug/node_modules/.pnpm/rollup@4.17.2/node_modules/rollup/dist/es/shared/parseAst.js:394:41)
    at Object.error (file:///home/rhymbit/code/astro-actions-bundle-bug/node_modules/.pnpm/rollup@4.17.2/node_modules/rollup/dist/es/shared/node-entry.js:19593:20)
    at Object.handler (file:///home/rhymbit/code/astro-actions-bundle-bug/node_modules/.pnpm/vite@5.2.11/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:67676:19)
    at async PluginDriver.hookFirstAndGetPlugin (file:///home/rhymbit/code/astro-actions-bundle-bug/node_modules/.pnpm/rollup@4.17.2/node_modules/rollup/dist/es/shared/node-entry.js:19678:28)
    at async ModuleLoader.resolveId (file:///home/rhymbit/code/astro-actions-bundle-bug/node_modules/.pnpm/rollup@4.17.2/node_modules/rollup/dist/es/shared/node-entry.js:18762:15)
 ELIFECYCLE  Command failed with exit code 1.

About

Vite's unable to bundle this specific file. Checkout README

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published