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

fix(plugin-compat): update fsevents patch to support virtual path #1671

Merged
merged 20 commits into from
Aug 18, 2020

Conversation

missing1984
Copy link
Contributor

@missing1984 missing1984 commented Aug 4, 2020

What's the problem this PR addresses?

Patch fsevents 2.x so it works with pnp virtual folders.

Close #1209

...

How did you fix it?

Find virtual paths for a given watch root and setup sub watchers accordingly.

...

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I have verified that all automated PR checks pass.

@missing1984 missing1984 changed the title update fsevents patch to support virtual path fix(plugin-compact) update fsevents patch to support virtual path Aug 4, 2020
+ let pnpApi;
+ try {
+ if (process.versions.pnp) {
+ pnpApi = require(`pnpapi`);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arcanis I am assuming calling require(pnpapi) many times won't have performance implication

@@ -2,20 +2,21 @@ diff --git a/fsevents.js b/fsevents.js
semver exclusivity ^1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the API fsevents 1.x exposed makes it quite challenging to watch multiple files so I only watch the path file instead.( same behavior as current patch)

@arcanis
Copy link
Member

arcanis commented Aug 8, 2020

I really want to look but the diff is difficult to read due to the GH interface not working super well for diffs 😞 I'll try to improve a bit our patch infra tomorrow to store the changes under JS syntax, and reapply your diff on top of it.

Copy link
Member

@arcanis arcanis left a comment

Choose a reason for hiding this comment

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

I have a branch with a few improvements to the fsevents patch infra, but I wanted to ask a few questions first

packages/plugin-compat/extra/fsevents/1.2.11.patch Outdated Show resolved Hide resolved
packages/plugin-compat/extra/fsevents/common.patch Outdated Show resolved Hide resolved
@arcanis
Copy link
Member

arcanis commented Aug 17, 2020

I think calling the watcher multiple times is problematic, as it will open multiple watchers on the same location. Since we already have reports that webpack sometimes open too many file descriptors, better be conservative here! I also would prefer to memoize as much work as possible, and to simultaneously avoid the extname call (which wouldn't work if the folder is called something like node.js or similar).

I've made a refactoring to instead compute an alias map . The advantage is that this map is shared between all calls, and it doesn't require much changes inside the fsevents files themselves. There's still room for perf improvements (I'm currently doing a crawl on all the options, which isn't ideal - a binary tree would be more efficient), but that should work without too much code.

Can you check whether it works for you? I've added a test for both FSEvents 1 & 2, but better be sure 😄

@arcanis arcanis force-pushed the mluo/fix-fsevents-virtual-path branch from a22fb54 to 4de6b1c Compare August 18, 2020 13:35
@merceyz merceyz changed the title fix(plugin-compact) update fsevents patch to support virtual path fix(plugin-compat): update fsevents patch to support virtual path Aug 18, 2020
@arcanis arcanis merged commit 3c0fa8c into yarnpkg:master Aug 18, 2020
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.

[Bug] Hot reloading broken when saving a file from a workspace that has peerDependencies listed
2 participants