Reload package from disk without reloading editor


Hi, I’m looking for a way to reload a certain package from disk without actually reloading the entire editor (through the dev tools).

Tried something like this, but didn’t work:



This is a duplicate of multiple previous discussions:

The short answer is that reloading using View > Reload is the fastest way to reliably load a changed package from disk. If you’re making style-only changes the dev-live-reload package will reload some things automatically, but it sounds like you’re making code changes.

Additionally, when you launch tests interactively, they are loaded in a new context that takes into account the new code. So unit testing your code can make things go faster too.

We like to unify similar discussions under one topic so that people don’t have to read a bunch of different threads to get the whole story. Please continue the discussion in one of the previous topics. I’ll be closing this topic as duplicate.


I read all of the other discussions but what I am looking for is a programatically approach for doing this. Especially with very heavy packages, reloading the entire editor can take 10s at a time.

When specifically is atom reading files from disk? Is it doing that only on startup?


The reload handling code starts here:

To be honest, I haven’t needed to know when things are loaded from disk. I do know that there are caching mechanisms in place though so that things are only loaded and parsed once.


Okay thank you for that. I’ll look into it :slight_smile:


Just a small update. We managed to get hot code reload working with atom packages written in clojurescript, so no more window reloading - yayyy!

I updated the ajom template to include the changes. If you like clojurescript, check it out. You won’t regret it :wink:


Why is it specific to clojurescript?


I developed package like that.

Please take this for your reference :grin:


@cakecatz interesting timing, I also just submitted a PR with something like your reload code to Atom:

Basically, it would clear the require.cache for a package once it gets unloaded.

Also, I took a look at your reload to see how you were doing it and I would advise you to change this line:

As is, you’ll also end-up clearing the cache for every package that starts with the same name as your package (ie. if I work on minimap, your code will clear the cache for every plugin as they are all using a minimap- prefix)


Wow, It’s good timing :open_mouth:
I hope that PR will be merged.

And thanks for your advise.
I fixed code for clearing the cache like yours.

closed #11

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.