randy3k / AutomaticPackageReloader

Automatically reload submodules while developing a Sublime Text package.
MIT License
38 stars 13 forks source link

Reload dependencies and their dependents. #20

Closed Thom1729 closed 6 years ago

Thom1729 commented 6 years ago

For #12.

When the plugin tries to reload a dependency, it will:

  1. Detect that the “package” is a dependency.
  2. imp.reload all of the loaded modules within the dependency.
  3. reload_package all of the packages that declare that dependency.

After this PR, when I save a file in my local copy of sublime_lib, AutomaticPackageReloader reloads sublime_lib and all packages that depend upon it.

This PR does require Package Control to be installed. We can work around that if necessary, at least to a limited extent.

randy3k commented 6 years ago

The whole point of this package is to get rid of imp.reload. Reloading just a dependency can be dangerous, we need to to make sure every module which uses the dependency will be reloaded. (I am not sure justing checking Package control dependencies are enough).

Thom1729 commented 6 years ago

I see what you mean about imp.reload; that wouldn't necessarily load things correctly. Instead, I'll just del the module and let reload_package sort it out.

“Every module which uses the dependency” should be a subset of modules in packages that declare the dependency. We'd be relying on package authors to declare dependencies correctly, but frankly if they don't then things are probably going to break anyway. Is there a better way to to it?

Under the current behavior, reloading a dependency will break packages that depend on it, so even if this approach isn't perfect I think it's a substantial improvement. If we can work out the corner cases, that would be even better.