Skip to content

Use throwIfNoEntry for default isFile and isDirectory #255

Closed

Description

@markjm

Similar to webpack/enhanced-resolve#316

Performance of skipping error generation is significant (mini-benchmark present in above issue) and the API is backward compatible.

Since this project doesnt use graceful-fs, this change should be available to make right now. I do somewhat worry about usage of monkeypatched graceful-fs, though, as that seems to fall into a weird grey area of deciding semver.

Activity

  1. ljharb commented on Nov 1, 2021

    @ljharb
    Member

    I'm not sure I understand what you're proposing.

    We use fs, not graceful-fs, and it definitely seems very strange to add an option node doesn't support just in case someone is using graceful-fs to patch the builtin.

    edit: maybe i misread. this is something node does support? which node versions support it? what happens differently with the option in a node version that doesn't support it?

  2. markjm commented on Nov 1, 2021

    @markjm
    Author

    Sorry I should clarify:

    throwIfNoEntry is a node supported option that is much more performant than letting statSync throw and immediately catch it (https://nodejs.org/api/fs.html#fsstatsyncpath-options). For that reason, I believe we should use that option here. The option is a no-op in older versions of node, so long as you just keep the try/catch block the same. I will create a PR to showcase the change.

    My only concern with doing this change is that if a consumer is using a monkeypatched graceful-fs, they may run into issues with this change. Since this package does not specify graceful as a dependency, I dont think it is really a "breaking change", but its worth understanding that it may still break some people using a semi-common patch.

  3. ljharb commented on Nov 1, 2021

    @ljharb
    Member

    It is none of our concern what someone does with graceful-fs; that's not a supported use case since it involves monkeypatching.

    A PR would be great.

  4. markjm commented on Nov 1, 2021

    @markjm
    Author

    @ljharb I have linked the change here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions