pjeby / hot-reload Goto Github PK
View Code? Open in Web Editor NEWAutomatically reload Obsidian plugins in development when their files are changed
License: ISC License
Automatically reload Obsidian plugins in development when their files are changed
License: ISC License
Hi there,
This issues just started happening. Can't be sure if I've caused it. But maybe you can help.
Plugin failure: tag-buddy TypeError: Cannot read properties of undefined (reading 'e')
at app.js:1:1148287
at e.unload (app.js:1:1147899)
at e. (app.js:1:2027133)
at app.js:1:237258
at Object.next (app.js:1:237363)
at app.js:1:236279
at new Promise ()
at v (app.js:1:236024)
at e.unloadPlugin (app.js:1:2027038)
at e. (app.js:1:2030070)
at app.js:1:237258
at Object.next (app.js:1:237363)
at app.js:1:236279
at new Promise ()
at v (app.js:1:236024)
at e.disablePlugin (app.js:1:2029944)
at HotReload.reload (plugin:hot-reload:95:23)
at eval (plugin:hot-reload:84:79)
I downloaded hot-reload and sample-plugin, and then modified the code of main.ts of sample-plugin. I still need to manually open and close sample-plugin for the changes to take effect. Do I need to configure anything else?
Hey @pjeby thanks for such an amazing plugin. I am using for my obsidian-svelte-plugin template and obsidian-dataview also uses it. It just crossed my mind that hot-reload doesn't have a license yet, do you mind adding one to prevent a misunderstandings in the future?
I have two sample plugins in a plugin directory and it seems to only hotreload the first one?
I have been using the hot reload plugin for some time now during development for my team's Obsidian plugin.
I have started to notice some issues, especially as the project grows primarily due to stale JS code that continues to run after the plugin gets reloaded. This seems to be worsened as it seems that the unload function within the plugin is not ran during the hot reloading process, meaning my websocket connections will grow n times with the number of reloads, and so will my dom elements that aren't cleared as a part of the loading process.
There may be something I could do better on my side, but a really simple fix for me is running window.location.reload(), performing a full reload of obsidian instead of reloading the singular plugin.
It may be worthwhile to add a setting to do this for the larger plugins in the space that may be able to benefit from this, I'll even do it myself depending on what the maintainers of this repo think!
After upgrading to latest node
version (v20.16.0), I started seeing the below error in the console and noticed that hot reload wasn't working anymore (changes to other plugins' main.js
files didn't work). I'm not sure what change in node
made this happen, but adding window.
before require("fs")
fixed it for me. Leaving the this and the reference in case this is helpful for anyone else. As I'm unsure if this is a shared issue, I'll abstain from making a fork and PR for now.
Error: [hot-reload] Attempting to load NodeJS package: "fs"
Hi,
this idea just came to mind. I often need to reload my plugin even if I haven't changed its source code. For example, I might change my plugin's settings file's content manually (outside Obsidian) and then would like to reload the plugin to test that the plugin loads the updated settings file without errors.
Currently I'm using Obsidian's Reload app without saving command, but that's a bit of an overkill when only needing to reload a plugin, as often any current file views go to different scroll positions etc. It would be more convenient to have a hotkey for reloading a specific community plugin.
Thank you for considering this! 🙂
Add .hotreload file in .obsidian/plugins
directory, instead of .obsidian/plugins/your-plugin
I am using iCloud to sync my vault across devices and I was finding that certain files in the node_modules
directory were not able to sync so I needed an alternative to working directly on my plugin inside the vault.
What I do now is, every time I build the repo (which lives externally to the vault), I then have a script copy over the main.js
, manifest.json
, and styles.css
to the [VAULT]/.obsidian/plugins/[PLUGIN NAME]
directory.
My script does update the filesand if I stop and restart Obsidian I get the new version but for some reason the change is not detected. I tried adding a touch "${filename}"
but this didn't change the outcome.
It seems that .obsidian
folder is hard-coded in this plugin
Hello,
It would be nice if this plugin exposed a setting which allowed you to disable the Notice that is sent on reload. This notice covers the right drawer and makes development on plugins with ItemView a bit painful.
I'm probably doing something wrong.
I have a modal in my window. Launched from my settings. When the plugin reloads after changes, and I try to launch the modal again I get:
remote.js:273 Uncaught Error: Could not call remote method 'show'. Check that the method signature is correct. Underlying error: TypeError: Object has been destroyedUnderlying stack: TypeError: Object has been destroyed
at [my local folder]\Obsidian\resources\app.asar\node_modules\@electron\remote\dist\src\main\server.js:465:71
at IpcMainImpl.<anonymous> ([my local folder]\Obsidian\resources\app.asar\node_modules\@electron\remote\dist\src\main\server.js:323:27)
at IpcMainImpl.emit (node:events:513:28)
at WebContents.<anonymous> (node:electron/js2c/browser_init:2:89772)
at WebContents.emit (node:events:513:28)
at [my local folder]\Obsidian\resources\app.asar\node_modules\@electron\remote\dist\src\main\server.js:468:25
at IpcMainImpl.<anonymous> ([my local folder]\Obsidian\resources\app.asar\node_modules\@electron\remote\dist\src\main\server.js:323:27)
at IpcMainImpl.emit (node:events:513:28)
at WebContents.<anonymous> (node:electron/js2c/browser_init:2:89772)
at WebContents.emit (node:events:513:28)
I instantiate with:
const window = new BrowserWindow({ show: false,{ show: false,[...]});
In the on close method I end with:
window.destroy();
What should I be doing to reload correctly? (Incidentally: if I force a reload with Ctrl-R in the console window, it works fine.)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.