Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Details for externs option flag #21

Closed
viebel opened this issue Sep 8, 2016 · 5 comments
Closed

Details for externs option flag #21

viebel opened this issue Sep 8, 2016 · 5 comments

Comments

@viebel
Copy link

viebel commented Sep 8, 2016

What is the format of the externs option flag?

I've tried a couple but nothing worked:

var the_flags = {
  externs: ['cljs.user.foo = function(){};'],
  compilationLevel: "ADVANCED", 
  jsCode: [{src: 'var a = cljs.user.foo();console.log(a);'}]
};
var the_out = compile(the_flags);
console.info(the_out); 
var the_flags = {
  externs: [{src:'cljs.user.foo = function(){};'}],
  compilationLevel: "ADVANCED",
  jsCode: [{src: 'var a = cljs.user.foo();console.log(a);'}]
};
var the_out = compile(the_flags);
console.info(the_out); 

In any case, the compiledCode is:

 "var a=cljs.b.a();console.log(a);"
@viebel
Copy link
Author

viebel commented Sep 13, 2016

Anyone could help here?

@viebel
Copy link
Author

viebel commented Sep 13, 2016

maybe @samthor ?

@samthor
Copy link
Contributor

samthor commented Sep 13, 2016

Please set warningLevel: 'VERBOSE' and you'll get more output to see what might be going wrong.

The latter is correct re: src, as per the README. The issue is that Closure doesn't know what cljs.user is. So you can try-

var cljs;
cljs.user = {};
cljs.user.foo = function(){};

@samthor
Copy link
Contributor

samthor commented Sep 13, 2016

I'll also add that this is not a Closure Compiler in JS specific issue, so I'm going to close this. Externs are a complex part of Closure. For more information check out the official tutorial or the wiki.

@samthor samthor closed this as completed Sep 13, 2016
@thelgevold
Copy link

I think you have to declare the root variable in the extern as well.

Something like this, perhaps:

externs: ['var cljs; cljs.user.foo = function(){};']

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants