GithubHelp home page GithubHelp logo

pjeby / hot-reload Goto Github PK

View Code? Open in Web Editor NEW
499.0 499.0 23.0 13 KB

Automatically reload Obsidian plugins in development when their files are changed

License: ISC License

JavaScript 100.00%
hot-module-replacement obsidian-md obsidian-plugin

hot-reload's People

Contributors

mnaoumov avatar pjeby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hot-reload's Issues

Plugin fails to unload every second reload (when main is updated)

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)

The plugin doesn’t seem to work

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?

License

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?

Add setting to perform a full reload of the obsidian window on refresh

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!

FIX | `require('fs')` (so, this plugin) breaks on latest Node version

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"

Add hotkeys for reloading plugins manually?

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! 🙂

Not detecting change when copying files into vault

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.

Add setting to disable reload Notice

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.

Browser Window fail on reload?

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.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.