zen-fs / core

A filesystem, anywhere
https://zen-fs.github.io/core/
MIT License
103 stars 14 forks source link

Why is Node v22 needed? #88

Closed ExpandOcean closed 2 months ago

ExpandOcean commented 2 months ago

Hello, the engine requires Node.js version 22 or higher. Is there a specific feature that needs this? The current default LTS version of Node.js is 20.

james-pre commented 2 months ago

@ExpandOcean,

Thanks for the question.

As mentioned in the 0.14.0 release notes, the change to need Node v22 is for Promise.withResolvers. If you polyfill Promise.withResolvers you should be able to use a lower Node version.

I think it may be a good idea to add the polyfill in ZenFS since it is trivial and would save this headache. Especially since the engine field of the NPM package wouldn't need to be 22 then.

Just to show how easy the polyfill is:

Promise.withResolvers ??= function<T>(): PromiseWithResolvers<T> {
    let resolve, reject;
    const promise = new Promise((_resolve, _reject) => {
        resolve = _resolve;
        reject = _reject;
    });
    return { promise, resolve, reject };
}
ExpandOcean commented 2 months ago

Thanks for your reply and the new release! I like this library and want to use it in an existing project but there will be a conflict if Node>20, the latest release should solve my problem. Thanks!