saml-dev/obsidian-custom-js

Fails to import

njsplng opened this issue · 9 comments

When trying to load a script, throws this in the console:

CustomJS couldn't import js/hide.js
eval @ plugin:customjs:6259
fulfilled @ plugin:customjs:48
plugin:customjs:6260 
SyntaxError: js/hide.js:1:33 (at plugin:customjs:6147:15)
ParseError: Unexpected token
    at debuggableEval (plugin:customjs:6147:15)
    at CustomJS.eval (plugin:customjs:6254:29)
    at Generator.next (<anonymous>)
    at fulfilled (plugin:customjs:48:58)
eval @ plugin:customjs:6260
fulfilled @ plugin:customjs:48

It is not dependent on the script content, does that for anything. I am hosting my vault on iCloud though – maybe that could be an issue?

are you using an import statement in your code?

nope, even with the file having one line of
console.log(‘test’);, it wouldn’t import and run the file properly

Can you share your customjs class, the path to file (relative to the vault root), and what you have in your customjs settings?

Setting were default.

The path was pointing to js/hide.js

Not sure about the customjs class. What exactly do you need to trace this?

by "customjs class", I meant the class you wrote that you're trying to reuse. Aka the contents of js/hide.js

The import fails even for such simple code as console.log("test")

You need to write a class to use with customjs. copy and paste the example from the README and see if it works for you.

Works fine with the class – it seems like the issue was that I did not include it.

Yes the class is required for CustomJS.