Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use native realpath if available to unwrap symlinks #217

Merged
merged 2 commits into from
Apr 8, 2020

Conversation

SimenB
Copy link
Contributor

@SimenB SimenB commented Apr 7, 2020

As discussed in jestjs/jest#9776

Docs: https://nodejs.org/api/fs.html#fs_fs_realpath_native_path_options_callback

didn't bother with process.bindings as we really shouldn't use those

@SimenB
Copy link
Contributor Author

SimenB commented Apr 7, 2020

As an aside, it might make sense to make maybeUnwrapSymlink pluggable like readFile, isFile and isDirectory is already. Those 3 allow you to avoid the real fs if necessary, but the realpath call does not. I can open up a separate issue for that?

@ljharb
Copy link
Member

ljharb commented Apr 7, 2020

A separate issue (or even a PR) sounds good.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Assuming tests pass, and aren't much slower :-)

@SimenB
Copy link
Contributor Author

SimenB commented Apr 7, 2020

On my machine npmt test seems a tiny bit faster, not sure how much of a benchmark that is, though. probably not at all 😀

Master:

  Time (mean ± σ):      6.358 s ±  0.548 s    [User: 7.007 s, System: 0.792 s]
  Range (min … max):    5.776 s …  7.328 s    10 runs

This branch

  Time (mean ± σ):      6.243 s ±  0.390 s    [User: 6.979 s, System: 0.751 s]
  Range (min … max):    5.929 s …  6.992 s    10 runs

@ljharb
Copy link
Member

ljharb commented Apr 7, 2020

when all the optionals are done, we can compare the "total time" on the travis builds :-p

@ljharb
Copy link
Member

ljharb commented Apr 8, 2020

Looks like travis took 3:34:08 (214.13 min) on master, and 2:33:30 (153.5 min) on the PR, across 176 jobs, so that's about 28% faster, or about 1min 13s vs 52s - seems like an improvement to me!

Appveyor needed a few reruns, so we'll see how that shakes out.

@ljharb ljharb force-pushed the native-realpath branch 3 times, most recently from f8001b6 to 535ec22 Compare April 8, 2020 06:23
@ljharb ljharb merged commit 535ec22 into browserify:master Apr 8, 2020
@SimenB SimenB deleted the native-realpath branch April 8, 2020 07:24
@SimenB
Copy link
Contributor Author

SimenB commented Apr 8, 2020

@ljharb one thing - using the native realpath might cause issues, see nodejs/node#7175

From what I gather require uses the native realpath (although I haven't verified by looking at source code) so I still think it's safe (or even correct) to change, but a heads up seems warranted in any case

@ljharb
Copy link
Member

ljharb commented Apr 8, 2020

It looks like perhaps using https://www.npmjs.com/package/fs.realpath would handle those issues, when using the native realpath?

ljharb pushed a commit that referenced this pull request Apr 15, 2020
ljharb added a commit that referenced this pull request Apr 15, 2020
 - [New] `core`: `fs/promises` is a core module again in node 14+ (f6473e2)
 - [patch] `sync`/`async`: use native `realpath` if available to unwrap symlinks (#217)
ljharb added a commit that referenced this pull request Oct 21, 2020
Changes since v2.0.0-next.1:

 - [Breaking] remove `core`/`isCore` in favor of `is-core-module` package
 - [Fix] drop the "require" condition, since that causes an "experimental" warning to be printed (#209)

Including all changes in v1.15.1 - v1.18.1:

v1.18.1

 - [Fix] `core`: remove console warning on require, since the main entry point requires it
 - [Refactor] avoid using extensions in require paths
 - [meta] update auto-generated `core.json`
 - [meta] add `eclint` and `.editorconfig`
 - [Dev Deps] update `eslint`
 - [Dev Deps] add `aud` in `posttest`

v1.18.0

 - [New] extract `isCore` implementation to `is-core-module`
 - [New] add new core modules that will be in node v15
 - [readme] soft-deprecate `resolve.isCore`
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`

v1.17.0

 - [New] `sync`/`async`: add `realpath`/`realpathSync` options (#218)
 - [Dev Deps] update `tape`

v1.16.1

 - [patch] when a non-node `fs` is broken and lacks `realpath`/`realpathSync`, do not crash (#220)

v1.16.0

 - [New] `core`: `fs/promises` is a core module again in node 14+ (f6473e2)
 - [patch] `sync`/`async`: use native `realpath` if available to unwrap symlinks (#217)

v1.15.1

 - [Fix] correct behavior when requiring `.` with same name (#212)
 - [Dev Deps] update `@ljharb/eslint-config`
 - [Tests] allow node 5 on windows to fail due to npm registry bug
ljharb added a commit to ljharb/resolve that referenced this pull request Feb 11, 2021
Changes since v2.0.0-next.2:

 - [New] add `readPackage` and `readPackageSync` (browserify#236)
 - [Fix] throw an error for an invalid explicit `main` with a missing `./index.js` file (browserify#234)
 - [meta] create SECURITY.md
 - [Deps] update `is-core-module`
 - [Dev Deps] update `eslint`, `@ljharb/eslitn-config`, `array.prototype.map`, `aud`, `tape`

Including all changes in v1.15.1 - v1.19.0:

v1.19.0

 - [New] `sync`/`async`: add 'includeCoreModules' option (browserify#233)
 - [readme] Add possible error types (browserify#232)
 - [Deps] update `is-core-module`
 - [Dev Deps] update `aud`, `eslint`
 - [meta] add Automatic Rebase and Require Allow Edits workflows
 - [Tests] comment out node 15 in appveyor; it’s not available yet
 - [Tests] add node 15 to appveyor, fix "latest npm" logic
 - [Tests] migrate tests to Github Actions

v1.18.1

 - [Fix] `core`: remove console warning on require, since the main entry point requires it
 - [Refactor] avoid using extensions in require paths
 - [meta] update auto-generated `core.json`
 - [meta] add `eclint` and `.editorconfig`
 - [Dev Deps] update `eslint`
 - [Dev Deps] add `aud` in `posttest`

v1.18.0

 - [New] extract `isCore` implementation to `is-core-module`
 - [New] add new core modules that will be in node v15
 - [readme] soft-deprecate `resolve.isCore`
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`

v1.17.0

 - [New] `sync`/`async`: add `realpath`/`realpathSync` options (browserify#218)
 - [Dev Deps] update `tape`

v1.16.1

 - [patch] when a non-node `fs` is broken and lacks `realpath`/`realpathSync`, do not crash (browserify#220)

v1.16.0

 - [New] `core`: `fs/promises` is a core module again in node 14+ (f6473e2)
 - [patch] `sync`/`async`: use native `realpath` if available to unwrap symlinks (browserify#217)

v1.15.1

 - [Fix] correct behavior when requiring `.` with same name (browserify#212)
 - [Dev Deps] update `@ljharb/eslint-config`
 - [Tests] allow node 5 on windows to fail due to npm registry bug
ljharb added a commit that referenced this pull request Feb 11, 2021
Changes since v2.0.0-next.2:

 - [New] add `readPackage` and `readPackageSync` (#236)
 - [Fix] throw an error for an invalid explicit `main` with a missing `./index.js` file (#234)
 - [meta] create SECURITY.md
 - [meta] do not publish github action workflow files
 - [Deps] update `is-core-module`
 - [Dev Deps] update `eslint`, `@ljharb/eslitn-config`, `array.prototype.map`, `aud`, `tape`

Including all changes in v1.15.1 - v1.19.0:

v1.19.0

 - [New] `sync`/`async`: add 'includeCoreModules' option (#233)
 - [readme] Add possible error types (#232)
 - [Deps] update `is-core-module`
 - [Dev Deps] update `aud`, `eslint`
 - [meta] add Automatic Rebase and Require Allow Edits workflows
 - [Tests] comment out node 15 in appveyor; it’s not available yet
 - [Tests] add node 15 to appveyor, fix "latest npm" logic
 - [Tests] migrate tests to Github Actions

v1.18.1

 - [Fix] `core`: remove console warning on require, since the main entry point requires it
 - [Refactor] avoid using extensions in require paths
 - [meta] update auto-generated `core.json`
 - [meta] add `eclint` and `.editorconfig`
 - [Dev Deps] update `eslint`
 - [Dev Deps] add `aud` in `posttest`

v1.18.0

 - [New] extract `isCore` implementation to `is-core-module`
 - [New] add new core modules that will be in node v15
 - [readme] soft-deprecate `resolve.isCore`
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`

v1.17.0

 - [New] `sync`/`async`: add `realpath`/`realpathSync` options (#218)
 - [Dev Deps] update `tape`

v1.16.1

 - [patch] when a non-node `fs` is broken and lacks `realpath`/`realpathSync`, do not crash (#220)

v1.16.0

 - [New] `core`: `fs/promises` is a core module again in node 14+ (f6473e2)
 - [patch] `sync`/`async`: use native `realpath` if available to unwrap symlinks (#217)

v1.15.1

 - [Fix] correct behavior when requiring `.` with same name (#212)
 - [Dev Deps] update `@ljharb/eslint-config`
 - [Tests] allow node 5 on windows to fail due to npm registry bug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants