oblador/esbuild-server

Fallback to reading the entire file when filehandle.createReadStream() isn't available

cuongvo opened this issue · 5 comments

filehandle.createReadStream has only been available since NodeJS v16.11.0. Users not yet on a version this recent will be prevented from using this package due to us not gracefully falling back to another implementation.

See:

esbuild-server/src/index.ts

Lines 188 to 189 in c262010

// @ts-ignore – for some reason the types doesn't include this one
const readStream = file.createReadStream({ autoClose: true });

Hmm, even node 16 is in maintenance mode now, and 18 is in active LTS. Not sure it makes sense to support old versions of node for a relatively new library that is intended for development. Any reason you cannot upgrade to node 16 or newer?

We're on 14.x, and it's not a trivial upgrade due to our scale. I think supporting non-EOL releases makes sense (14.x, 16.x, 18.x, 19.x) when backwards compatibility is relatively straight forward (as is in this case -- if createReadStream doesn't exist on the FileHandle, use fs.createReadStream).

Edit: If this is something you're OK with, I'm happy to send in the PR for 14.x support.

Sure, that would be great!

@cuongvo Still up for that PR?

Closing due to lack of response