obsidian-wielder icon indicating copy to clipboard operation
obsidian-wielder copied to clipboard

[Bug] Wielder Causing Issues with Templater's Startup Template

Open iamrecursion opened this issue 2 years ago • 2 comments

The plugin templater has the ability to set a "startup template" that runs when Obsidian is started. However, when wielder is enabled, the startup template fails to run with a vast error. Prior to the template running (as it happens onLayoutReady), Wielder prints the following error:

Uncaught (in promise) TypeError: import_sci.default.init is not a function
    at initialize (plugin:wielder:85392:29)
    at ObsidianClojure.eval (plugin:wielder:85553:21)
    at Generator.next (<anonymous>)
    at fulfilled (plugin:wielder:36:24)

After that, the startup template runs and results in a very big error that mentions certain wielder properties. The error is massive, and hence is attached as a error.txt.

From a basic scan of the error, it looks like it may be related to my startup template's use of obsidian-requirejs that isn't playing nicely with it.

I hadn't restarted Obsidian in a while and hence only just saw this!

iamrecursion avatar Jun 25 '22 22:06 iamrecursion

Hm, interesting. Haven't seen this before so thanks for reporting it.

Yeah, my first hunch is that because obsidian-requirejs defines a bunch of global things with very common names, something somewhere gets used when it shouldn't. Quick look at the source reveals this:

    //@ts-ignore
    window.requirejs = requirejs;
    //@ts-ignore
    window.define = define;

I'm not sure why it would clash with anything we're doing in Wielder, but probably the final bundle has to be generated somewhat differently to fix this, as it doesn't seem well enough isolated.

I'll take a deeper look when I have time.

victorb avatar Jun 27 '22 09:06 victorb

Makes sense! Thanks for the update!

iamrecursion avatar Jun 27 '22 20:06 iamrecursion