Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by

Generally useful, but specifically for appending clj.loader/set-loaded! calls to user files.

5 Answers

0 votes
by

Comment made by: thheller

In {{shadow-cljs}} I have 4 attributes per {{:module}} for this.

  • {{:prepend}} treated as text, eg. licence headers. Can contain JS but won't go through optimizations.
  • {{:prepend-js}} treated as JS code that will also go through closure optimizations
  • {{:append-js}}
  • {{:append}}

I think it is valuable to have all 4 and making the distinction between "text" and "JS". {{shadow.loader}} is implemented entirely through these attributes.

0 votes
by

Comment made by: dnolen

I'm having second thoughts about this one, since I don't think we need this for CLJS-2157, which is why I opened it originally.

0 votes
by

Comment made by: thheller

set-loaded! should only be called once per module, so it must be appended to the module itself not to individual files in the module.

By appending to individual files you will eventually call it more than once for modules that have multiple entries. AFAICT the call is not idempotent and may cause events to be emitted multiple times. At the very least it may call set-loaded! before the full module has actually been loaded. Since it immediately triggers the callbacks that may lead to bad results.

The config options are generally useful not just for the loader.

0 votes
by

Comment made by: dnolen

Thomas as far as I can tell ModuleManager.setLoaded is idempotent. I haven't run into any issues locally with testing. Feel free provide a failing case if you can but I couldn't find one myself.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-2156 (reported by dnolen)
...