Skip to content

Conversation

@phated
Copy link
Member

@phated phated commented May 31, 2025

The Node.js core team is cruel and moves things to their internal/ package and then marks them as deprecated. We can work around this using some crazy JS techniques (seen below).

When logging the new fs.Stats created by this technique, they look the same as new fs.Stats() and no deprecation warning is shown.

Closes #356

@phated phated requested a review from yocontra May 31, 2025 23:32
@phated phated force-pushed the phated/hide-fs-stats-construction branch 2 times, most recently from 2e939dc to a4f208c Compare June 1, 2025 00:16
@phated phated mentioned this pull request Jun 1, 2025
@phated phated force-pushed the phated/hide-fs-stats-construction branch from a4f208c to bbfde55 Compare June 1, 2025 00:31
@phated phated merged commit 3ed0c3f into master Jun 1, 2025
26 checks passed
@phated phated deleted the phated/hide-fs-stats-construction branch June 1, 2025 02:24
@robertknight
Copy link

While reviewing a dependency update for Gulp I looked into the context of the fs.Stats change. It is explained in nodejs/node#51681 (comment), found via nodejs/node#51879. This comment highlights that a possible future change may break the code here again:

If we manage to remove it from the public API we can just do Stats extends StatsBase here (which is a breaking change by disallowing construct calls without new/Function.prototype.call

@Razunter
Copy link

Razunter commented Jun 4, 2025

This change broke Deno compatibility:

error: Uncaught TypeError: Class constructor Stats cannot be invoked without 'new'
    at newStats (... /node_modules/.deno/[email protected]/node_modules/vinyl-fs/lib/dest/prepare.js:13:34)
```

@phated
Copy link
Member Author

phated commented Jun 4, 2025

@Razunter

  1. Gulp doesn't support Deno. You can see in our CI matrix that we only support Node.
  2. Seems like a broken compatibility layer in Deno. You should report it to them.

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.

[DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.

5 participants