Hey,

my advice would be to use a post-process step instead of trying to making it go 
through the closure compiler. Not only will that produce headaches but the 
generated CLJS->JS also does not match the expected structure for UMD exports.

You'd need to tag the functions you want to have available by name ala

(defn ^:export js-indent-mode []...)

and then refer to them on the exports. Note that you need to refer to the 
munged names (eg. _ instead of -).

I do not know how to do this in cljsbuild but could show you an example in 
shadow-build if interested. Anyways all you'd need is to pipe the  compiled 
output into the below script (at the marker). No externs needed for this case.

(function (root, factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define([], factory);
    } else if (typeof module === 'object' && module.exports) {
        // Node. Does not work with strict CommonJS, but
        // only CommonJS-like environments that support module.exports,
        // like Node.
        module.exports = factory();
    } else {
        // Browser globals (root is window)
        root.returnExports = factory();
  }
}(this, function () {

    // CLJS-COMPILED-OUTPUT-HERE
        
    return {indentMode: parinfer.api_js.js_indent_mode,
            indentModeChange: parinfer.api_js.js_indent_mode_change,
            parenMode: parinfer.api_js.js_paren_mode};
}));


HTH,
/thomas

On Sunday, November 22, 2015 at 8:42:53 AM UTC+1, Shaun LeBron wrote:
> I'm trying to export a JavaScript API from my ClojureScript library using a 
> UMD pattern, given the following export function:
> https://github.com/shaunlebron/parinfer/blob/7131d10ee21a6674279577b76743f623d4b2c3c9/parinfer-lib/src/parinfer/api_js.cljs#L64-L70
> 
> After compiling in advanced mode, and running Node, 
> `require("./parinfer.js")` just returns {}.  Adding the `:target :nodejs` 
> option doesn't help.
> 
> I'm thinking it has something to do with google closure renaming my `module` 
> symbol despite having the externs to prevent it.  Anyway to prevent this?

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to