Hello!
New user migrating from a mix of Js-Engine, templater hotkeys, and commander, here. This is really cool and has the potential to be the main driving engine behind automation in Obsidian!
There is one concern: do require function calls require a completely immediately declared string literal, eg:
ONLY this is allowed
const myImportedFunction = require('path/to/file');
and NOT a variable that points to a string literal:
//CONSTANTS.js
const FunctionFilePath = "path/to/file";
//main.ks
const CONSTANTS = require("path/to/CONSTANTS.js");
const myImportedFunction = require(CONSTANTS.FunctionFilePath);
I ask because my system is complex, with multiple centralized dependencies (utils folder), and Iām still in the process of finishing organizing my files, so dependencies will be moved around, breaking the files (features) that depend on the dependencies (utils).
Iām not an experienced javascript developer, so Iām not really sure if there was an original intended method for solving this with node.js. I didnāt see anything on the obsidian-codescript-tookit for this (obsidian-codescript-toolkit/docs/core-functions.md at main Ā· mnaoumov/obsidian-codescript-toolkit Ā· GitHub ; obsidian-codescript-toolkit/docs/dynamic-import.md at main Ā· mnaoumov/obsidian-codescript-toolkit Ā· GitHub ) and was wondering if there was a method to doing variable imports.
Doing something naively results in the warning āCould not statically analyze require call
require(basepathjs + āutils/IO/insert_text_under_header_in_note.jsā)ā (where the filepath is a constructed string). This isnāt the exact same case (being a interpreted string instead of just an imediate constant) but the idea is still similar: can we declare const variable filepaths for require?
This is the only thing stopping me from rapid development; I would love to hear some feedback!
Thanks!