Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable DCE by avoiding ^:export for cljs use. #191

Closed
rauhs opened this issue Dec 3, 2016 · 0 comments
Closed

Enable DCE by avoiding ^:export for cljs use. #191

rauhs opened this issue Dec 3, 2016 · 0 comments

Comments

@rauhs
Copy link
Contributor

rauhs commented Dec 3, 2016

The ^:export declaration are only necessary for the javascript build of datascript. But this eliminates any dead code elimination by the Google Closure compiler which would be nice for people not using certain features. For instance, I don't use FilteredDB.

By making the javascript build a little more involved, we could remove those export declaration for cljs use. cljsee can be used to process the datascript files:

(cljsee.parse/process-source-code
  ;; The first tag will be output if it's in the features list:
 "#?(
  :js   (def ^:export datom? db/datom?)
  :cljs (def datom? db/datom?)
 )"
 #{:cljs :js})

This could allow even more fine grained code generation. Not sure if the trouble is worth it though.

A good enough solution would be to just change the code in datascript.core to:

(goog-define datascript-export-js-api true)

(def datom db/datom)
(when ^boolean datascript-export-js-api
  (goog/exportSymbol "datom" datom))

And allow cljs-only folks to define datascript-export-js-api to false.

Thoughts?

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

No branches or pull requests

1 participant