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

Can I keep cljsjs requires when using "clean ns" ? #275

Closed
mikavilpas opened this issue Dec 16, 2015 · 7 comments
Closed

Can I keep cljsjs requires when using "clean ns" ? #275

mikavilpas opened this issue Dec 16, 2015 · 7 comments

Comments

@mikavilpas
Copy link

Hi, cljsjs provides, as you might know, javascript native packages wrapped with support for clojurescript and the Google closure compiler. The way to use these is to (:require [cljsjs.js-yaml]) which does not add a real namespace (to my understanding) but only requires the native js. Requiring external libraries/functions this way is pretty easy, as they are accessible from js/jsyaml.safeLoad for example.

Clean ns does not understand these requires and deletes them since they are not used (and I don't blame it, they are special). Is there a way I could clean my ns form and keep these special requires around?

@expez
Copy link
Member

expez commented Dec 17, 2015

Is there a way I could clean my ns form and keep these special requires around?

No, but now that you've taught me about these, I might teach clean-ns about them too :)

Do all of these start with the prefix cljsjs? If so I could just tell clean-ns to never prune libspecs with that prefix.

@mikavilpas
Copy link
Author

Secret goal achieved, thanks :)

cljsjs is unfortunately not the only way to have external dependencies loaded. A project may use its own externs file which specifies to the closure compiler what things exist in the native js libraries too.

For starters cljsjs would be a great start I think!

A suggestion: is it possible to have metadata for the requires? I'm thinking of a special metadata key that would cause clean-ns to keep the require vector.

@mikavilpas
Copy link
Author

Oops, in the last message I meant not pruning anything from cljsjs would be a great start. Just noticed it's not very clear in the message.

@expez
Copy link
Member

expez commented Dec 17, 2015

A suggestion: is it possible to have metadata for the requires? I'm thinking of a special metadata key that would cause clean-ns to keep the require vector.

Yeah, but it kind of sucks that source code has to be changed just to please a refactoring tool.

My guess is that just ignoring cljsjs dependencies will be a pretty good first step. Teaching refactor-nrepl how to read boot.clj and project.clj files to learn about externs in general seems quite difficult :/

@mikavilpas
Copy link
Author

Thanks for taking the time to do this! I'll get to using it soon I think.
👍
14.1.2016 12.46 ip. "Lars Andersen" notifications@github.com kirjoitti:

Closed #275 #275
via clojure-emacs/refactor-nrepl@603dbb4
clojure-emacs/refactor-nrepl@603dbb4
.


Reply to this email directly or view it on GitHub
#275 (comment)
.

@mikavilpas
Copy link
Author

Well, I tested it in practice and it seems to work correctly. Thanks again! ❤️

@expez
Copy link
Member

expez commented Jan 16, 2016

Thanks for giving it a spin! 👍

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

No branches or pull requests

2 participants