#Astro bun binary after v4->v5 upgrade shows type-error

1 messages · Page 1 of 1 (latest)

pearl ridge
#

I had this beautiful single binary of my Astro SSR site running, but after upgrading to Astro V5 I get attached error.

Here's where this gets interesting. Astro isn't internalizing this dependency, so the dev-server and even running the local server with bun works fine.

But as soon as I compile to a binary it transpiles this replace variable in a wrong way.

// node_modules/html-escaper/esm/index.js
36257 | var replace = "", ca, esca, pe = (m) => esca[m], escape2 = (es) => replace.call(es, ca, pe);

The actual esm/index.js file looks like this

const {replace} = '';

They're fetching the string replace prototype in a creative way, sure. But translating the replace function into "" is wrong and causing this error.

This is hard to reproduce outside of my entire site's code base. But I'm trying...

#

Astro bun binary after v4->v5 upgrade shows type-error

pearl ridge
#

More information:

  1. I tried bundling the astro server bundle manually (without compile) and that fails in the same way.
  2. I tried reproducing this in a clean bun project, without luck. In there, the bundle is correctly translating to var { replace } = "";
  3. I tried copying parts of the astro server bundle over there, but that works fine too.
  4. I tried bundling my simple repro program in the astro project. That came out fine.
  5. If I bundle the actual chunks from Astro, it works as intended. But if I bundle the dist/server/entry.mjs it messes it up. Unsure why yet.

I'm totally stumped here! This has to be related to Astro v5 using Vite v6. But I don't know how