ClojureScript

add :externs and :use-only-custom-externs options

Details

  • Type: Task Task
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

One bit I'm not sure of is whether :use-only-custom-externs on nodejs should include "cljs/nodejs_externs.js". In the current patch, it doesn't. You would have to specify it manually.

:use-only-custom-externs is also untested.

I've attached a small test.
external.js defines external.fn(str) (which is just toUpperCase).
test.cljs defines test.main which calls external.fn.
test.html sources external.js and test.js (the advanced-compiled test.cljs) and calls external.fn directly and then via test.main.
externs.js gives an empty definition of external.fn.

Without the patch, (my) advanced-compiled test.js renames external.fn to external.K. When compiled with :externs (./bin/cljsc test.cljs '{:optimizations :advanced :output-to "test.js" :externs ["externs.js"]}'), external.fn is left alone.

Closure reference: https://code.google.com/closure/compiler/docs/api-tutorial3.html#mixed

  1. external.js
    12/Sep/11 11:20 PM
    0.1 kB
    John Li
  2. externs.diff
    12/Sep/11 11:19 PM
    2 kB
    John Li
  3. externs.js
    12/Sep/11 11:20 PM
    0.0 kB
    John Li
  4. test.cljs
    12/Sep/11 11:19 PM
    0.1 kB
    John Li
  5. test.html
    12/Sep/11 11:19 PM
    0.3 kB
    John Li

Activity

Hide
John Li added a comment -

Adding rest of the test files.

Show
John Li added a comment - Adding rest of the test files.
Hide
Brenton Ashworth added a comment -

A patch for this was submitted under a different issue: CLJS-10.

I have applied that patch to the externs branch.

Please test your code with those changes to ensure that this works for you or to discover if more work needs to be done. If you run into problems, comment on that issue or on the Clojure dev mailing list.

Thanks for the patch and sorry for the confusion.

Show
Brenton Ashworth added a comment - A patch for this was submitted under a different issue: CLJS-10. I have applied that patch to the externs branch. Please test your code with those changes to ensure that this works for you or to discover if more work needs to be done. If you run into problems, comment on that issue or on the Clojure dev mailing list. Thanks for the patch and sorry for the confusion.
Hide
Brenton Ashworth added a comment -

Duplicate issue.

Show
Brenton Ashworth added a comment - Duplicate issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: