|
672 | 672 | :name name
|
673 | 673 | :path (ns->relpath name)
|
674 | 674 | :source js-source
|
675 |
| - :cache (get-in env/*compiler* |
676 |
| - [::ana/namespaces name])}] |
677 |
| - (when (:verbose opts) |
678 |
| - (debug-prn js-source)) |
679 |
| - (let [res (try |
680 |
| - {:ns ns :value (*eval-fn* evalm)} |
681 |
| - (catch :default cause |
682 |
| - (wrap-error (ana/error aenv "ERROR" cause))))] |
683 |
| - (cb res)))))))))) |
| 675 | + :cache (get-in env/*compiler* [::ana/namespaces name])} |
| 676 | + complete (fn [res] |
| 677 | + (if (:error res) |
| 678 | + (cb res) |
| 679 | + (do |
| 680 | + (when (:verbose opts) |
| 681 | + (debug-prn js-source)) |
| 682 | + (let [res (try |
| 683 | + {:ns ns :value (*eval-fn* evalm)} |
| 684 | + (catch :default cause |
| 685 | + (wrap-error (ana/error aenv "ERROR" cause))))] |
| 686 | + (cb res)))))] |
| 687 | + (if-let [f (:cache-source opts)] |
| 688 | + (f evalm complete) |
| 689 | + (complete {:value nil})))))))))) |
684 | 690 | (:*cljs-ns* bound-vars))))
|
685 | 691 |
|
686 | 692 | (defn eval-str
|
|
698 | 704 | opts (map)
|
699 | 705 | compilation options.
|
700 | 706 |
|
701 |
| - :eval - eval function to invoke, see *eval-fn* |
702 |
| - :load - library resolution function, see *load-fn* |
703 |
| - :source-map - set to true to generate inline source map information |
| 707 | + :eval - eval function to invoke, see *eval-fn* |
| 708 | + :load - library resolution function, see *load-fn* |
| 709 | + :source-map - set to true to generate inline source map information |
| 710 | + :cache-source - optional, a function to run side-effects with the |
| 711 | + compilation result prior to actual evalution. This function |
| 712 | + takes two arguments, the first is the eval map, the source |
| 713 | + will be under :source. The second argument is a callback of |
| 714 | + one argument. If an error occurs an :error key should be |
| 715 | + supplied. |
704 | 716 |
|
705 | 717 | cb (function)
|
706 | 718 | callback, will be invoked with a map. If succesful the map will contain
|
|
0 commit comments