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

Add back support to reinstall linked dependencies on change #2088

Open
FredKSchott opened this issue Dec 22, 2020 · 15 comments
Open

Add back support to reinstall linked dependencies on change #2088

FredKSchott opened this issue Dec 22, 2020 · 15 comments
Labels
3.1 bug Something isn't working

Comments

@FredKSchott
Copy link
Owner

Original Discussion: #429
/cc @joaotavora

Regression:

commit 610fb9d28452bf24758387a00fe81a4ed103e503
diff --git a/packages/snowpack/src/commands/dev.ts b/packages/snowpack/src/commands/dev.ts
--- a/packages/snowpack/src/commands/dev.ts
+++ b/packages/snowpack/src/commands/dev.ts
@@ -954,3 +880,3 @@
   function onDepWatchEvent() {
-    reinstallDependencies().then(() => hmrEngine.broadcastMessage({type: 'reload'}));
+    hmrEngine.broadcastMessage({type: 'reload'});
   }
@FredKSchott FredKSchott added bug Something isn't working 3.1 labels Dec 22, 2020
@joaotavora
Copy link

I'm working on a fix right now :-) Having fun, but I won't be suprised if you beat me to it, since they'll be my first ever lines of OSS javascript/typescript.

@FredKSchott
Copy link
Owner Author

Nice! Let me know how I can help. That commit should include the old implementation of reinstallDependencies(), which may need to change a bit since it's so old now, but should have enough to point you in the right direction. Appreciate the help!

@joaotavora
Copy link

I'm making progress, indeed. I'll let you know if I am blocked. First I'll try to get back that function you mention and get this working the way it presumably used to.

After that is done, I was thinking of being a little more ambitious and installing only the dependency that we know has changed, since I think reinstallDependencies installs all of them. In theory it should be possible to know which one we need to update by correlating the argument to onDepWatchEvent which is the file/directory that changed with some other global structure.

joaotavora added a commit to joaotavora/snowpack that referenced this issue Dec 23, 2020
…ies on change

* snowpack/src/commands/dev.ts (installDependencies): import it.
(onDepWatchEvent): Use it.

* snowpack/src/commands/install.ts (InstallRunResult): export it.

* snowpack/src/sources/local.ts (InstallRunResult): import it.
(installDependencies): export it.
@joaotavora
Copy link

After much rummaging around in the code, I've settled for exporting and re-using an function in sources/local instead of bringing back the defunct reinstallDependencies(). I thus touch very few lines, which is always a good idea in my book. Maybe/probably this misses some important detail but it works. Getting late now, going to bed.

@joaotavora
Copy link

@FredKSchott what's the status on this? Do you think the fix I'm proposing will get merged in the near future, or do you have something else in mind? I think something more elaborate and/or efficient is clearly possible, but at least merging my fix seems to bring back the previous behavior.

@FredKSchott
Copy link
Owner Author

Sorry for the delay on this, I've been on holiday and then immediately went heads down into getting v3.0 out the door. Should have more time to take a look at this in the next couple of days. I can also help you rebase your PR, given that a few things had to move around for v3.0 since you started on it.

joaotavora added a commit to joaotavora/snowpack that referenced this issue Jan 13, 2021
…ies on change

* snowpack/src/commands/dev.ts (installDependencies): import it.
(onDepWatchEvent): Call it.

* snowpack/src/sources/local-install.ts (InstallRunResult): export it.

* snowpack/src/sources/local.ts (InstallRunResult): import it.
(installDependencies): export it and give it a type.
@joaotavora
Copy link

I can also help you rebase your PR, given that a few things had to move around for v3.0 since you started on it.

I think I just did that, rebase on top of main with a few changes (I think the stuff you moved around makes things slightly clearer).

It's working fine, as far as I can tell, though on upgrading Snowpack to main I had to npm i --legacy-peer-deps because of some dependency breakage that I didn't understand. It doesn't seem to affect anything, though

@joaotavora
Copy link

joaotavora commented Jan 13, 2021

By the way, I found and fixed another bug. When making the FS watcher for linked deps, better consider config.exclude (which is node_modules and stuff), otherwise it's really easy to blow past the default limit for FS-watching handles. Put it in the same PR: a0f4b17

@gaberogan
Copy link

gaberogan commented Jan 24, 2021

Is there currently a workaround for this?
edit: this appears to work
npx snowpack dev --reload

@melissamcewen melissamcewen added this to Needs Triage in Triage Mar 11, 2021
@melissamcewen melissamcewen moved this from Needs Triage to Ready to Implement in Triage Mar 16, 2021
@andrew-c-tran
Copy link

Any word on this? it appears to have been ready for quite some time now

@joaotavora
Copy link

According to #2091 (comment), this is supposed to be fixed now (with another change, not my PR).

I wouldn't know, I haven't used Snowpack for some time :-/.

But maybe this can be closed?

@donmccurdy
Copy link

I'm finding that not only are changes in linked dependencies not detected, but Snowpack can't build (at all) with any linked dependencies involved. Have tried clearing the cache and using --reload. Continue to get errors like:

 Error: Unexpected: Unscanned package import "<my-package>" couldn't be built/resolved.

This one is pretty important to my development workflow, anything we can do to help?

@RodrigoHamuy
Copy link

Any updates on this? I also can't use linked packages on latest Snowpack.

@joaotavora
Copy link

See my comment #2088 (comment). It's supposed to be fixed !

@RodrigoHamuy
Copy link

Thanks @joaotavora . I am using snowpack version 3.8.2 and the issue is still present so I don't think is fixed yet.

@FredKSchott FredKSchott removed this from Ready to Implement in Triage Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.1 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants