Skip to content

Conversation

@SuperchupuDev
Copy link
Contributor

@SuperchupuDev SuperchupuDev commented Jun 27, 2025

Note

Since node 12 support was restored, this is getting marked as draft indefinitely until it is decided to drop node 14. As such the text below is obsolete

Since the creation of #116, fdir started using AbortController in 2f6145e. AbortController was unflagged in node 15.6.0. This would have broken users, but it looks like absolutely no one actually used versions older than that, since I've seen no reports complaining and it's been a whole month. (Someone did mention it after I asked them but apparently they just updated their node version and moved on).

According to @thecodrr's comment it can be deduced that the minimum version set in the engines field should be tested in CI. Testing on node 14 was dropped in 3c608bd (a year and a half ago!). And node 16 is already being tested in CI.

I could set the field to >=15.6.0, but I don't think it would be a good idea considering it's not a good practice to set the minimum version to an odd numbered release. So I propose setting it to >=16.0.0, just like the original comment from #116 suggested. This wouldn't break anyone that wasn't already broken by the 6.4.5 release (which, as I've said before, is either no one or extremely few people, considering neither fdir or tinyglobby got any reports of it happening).

Doing this is also good for a few more reasons. It can allow the package to use a few syntax features such as optional chaining which can make code smaller and more readable while doing the same thing. Also it can make fdir use the node: protocol where possible which is a good practice the node team has been wanting people to use. This is why the PR makes use of those features.

A few days ago I opened a pinned issue in tinyglobby mentioning the possibility of the same happening there. It got two positive reactions and no negative comments, so it seems the reception wouldn't be negative SuperchupuDev/tinyglobby#134

Be mindful that if this is merged, #147 would probably need to be updated (by changing the target and removing removeNodeProtocol from the tsdown config). Just mentioning this so that both aren't merged at the same time.

closes #116

@thecodrr
Copy link
Owner

This is really good.

const SLASHES_REGEX = /[\\/]/g;
export function convertSlashes(path: string, separator: PathSeparator) {
return path.replace(SLASHES_REGEX, separator);
return path.replaceAll(SLASHES_REGEX, separator);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit of using replaceAll over replace when using RegExp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it requires the regex to have the g flag and otherwise throws. useful so that 1) the intentions of replacing more than one entry are clear without needing to look at the regex that could be defined somewhere else 2) it makes forgetting the flag throw an error

Copy link
Contributor

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd much rather we check if AbortController is available and use it only when it is than introduce a breaking change. This change will prevent some libraries from using fdir and I don't think that's a good trade-off as the slightly more modern syntax doesn't have any real benefit compared to the cost of users not being able to use the library. E.g. 75lb/file-set#7 (comment)

@SuperchupuDev
Copy link
Contributor Author

SuperchupuDev commented Jul 1, 2025

i don't think AbortController can be avoided considering it's being used during the crawling process regardless of the options. if we checked for support and avoided using it then it would reintroduce dangerous bugs that caused infinite loops. remember that the breaking change was already done in 6.4.5. this pr doesn't break anything and only makes the node versions that work clear. the javascript features used here work on node versions that support AbortController

@benmccann
Copy link
Contributor

let's at least set engines to >=14.17.0 then so that we can polyfill AbortController. we lose that ability if setting it to Node 16

@thecodrr
Copy link
Owner

thecodrr commented Jul 2, 2025

@SuperchupuDev @benmccann let's put this on hold.

I have removed AbortController in favor of a custom alternative here: #153

@SuperchupuDev
Copy link
Contributor Author

marking as draft until you decide to drop node 14 👍

@SuperchupuDev SuperchupuDev marked this pull request as draft July 4, 2025 05:57
@SuperchupuDev SuperchupuDev changed the title chore: set engines field chore: require node >=16 Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set engines in package.json

3 participants