What I’m trying to do
Hey, I’d like to write a plugin which allows more integration with the system. On desktop, this requires me to load a native nodejs module. I’ll tackle mobile another time. I would like to be able to import a .node
extension.
Things I have tried
I’ve been working on some clever esbuild trickery to import the file via a custom loader, but have not managed to do so, as I cannot determine the path to the file.
if (this.app.vault.adapter instanceof FileSystemAdapter) {
basePath = this.app.vault.adapter.getBasePath();
} else {
throw new Error('Cannot determine base path.');
}
// relative path
relativePath = `${this.app.vault.configDir}/plugins/linked-data-vocabularies/${fileName}`;
this snippet by @kometenstaub shows how to get the plugin’s directory relative to the root of the vault, but I cannot determine the vault itself. Line 2 fails with getBasePath()
is not a function.
Some suggestions would be very much appreciated.