Skip to content

talwrii/plugin-repl-imports

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plugin REPL imports

Import and use NPM modules in Plugin REPL

Plugin REPL is a plugin for the note taking app Obsidian that allows rapid automation of Obsidian from within Obsidian itself. It is also useful for very fast iteration when creating plugins.

This is a "companion repository" if you want to use imported JavaScript library from npm.

Using

  1. Check out this repository into your vault git clone git@github.com:talwrii/plugin-repl-imports.git
  2. Add the npm modules you want to install to imports.txt
  3. Open a terminal in the checked out repository.
  4. Run npm install
  5. Run npm run run
  6. Run module = replRequire("modulename") in Obsidian with plugin repl. This is like the require function in node JavaScript

A technical explanation

You do not need to understand this to use this tool, but if you are interested this is an explanation of how this works.

Obsidian is based on Electron, a tool for creating desktop apps in JavaScript. Electron is based on node js which can import modules with require using the CommonJS module system. This means that some modules (including builtin modules can be accessed with require). However, where Obsidian looks for modules is fixed, cannot be added to and is readonly.

To get around this plugins are built with the JavaScript "bundler" esbuild this embeds a copy of all the code that you import into one big js file - similar to the approach that web pages use, but with the exception that some modules are still imported using require such as obsidian modules.

This repository uses the same approch.

Attribution and prior work

This approach is based on how plugins are built for Obsidian, code is directly taken from the MIT-licensed sample plugin repository for Obsidian.

About

Repository used to provide imports to Plugin REPL for Obsidian

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors