Skip to content

Cleaning namespace for cljc files #404

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

Conversation

dotemacs
Copy link
Contributor

NOTE: Still WIP, pushing early to discuss. The CI will break the build, as I didn't touch all the affected tests.

Previously it would create a namespace with a double require, from this:

(ns clean-ns.cljc-ns
  (:require [vlad.core :as vlad :refer [attr chain join present Validation]]
            #? (:cljs [goog.date.Interval :as Interval])
            [clojure.string :as string]
            [cemerick.url :as url]))

to this:

(ns clean-ns.cljc-ns
  #?@
   (:clj
    [(:require
      [cemerick.url :as url]
      [clojure.string :as string]
      [vlad.core :as vlad :refer [attr chain join present Validation]])]
    :cljs
    [(:require
      [cemerick.url :as url]
      [clojure.string :as string]
      [goog.date.Interval :as Interval]
      [vlad.core :as vlad :refer [attr chain join present Validation]])]))

Now it creates:

(ns clean-ns.cljc-ns
  (:require
  [vlad.core :as vlad :refer [attr chain join present Validation]]
  [cemerick.url :as url]
  [clojure.string :as string]
  #?(:cljs [goog.date.Interval :as interval])))

This is related to: #266

NOTE: I'll update the below after feedback.

  • The commits are consistent with our contribution guidelines
  • You've added tests (if possible) to cover your change(s)
  • All tests are passing (run lein do clean, test)
  • Code inlining with mranderson works and tests pass with inlined code (run ./build.sh install -- takes a long time)
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the readme (if adding/changing user-visible functionality)

Sorry, something went wrong.

Previously it would create a namespace with a double require, from
this:

```clojure
(ns clean-ns.cljc-ns
  (:require [vlad.core :as vlad :refer [attr chain join present Validation]]
            #? (:cljs [goog.date.Interval :as Interval])
            [clojure.string :as string]
            [cemerick.url :as url]))
```
to this:

```clojure
(ns clean-ns.cljc-ns
  #?@
   (:clj
    [(:require
      [cemerick.url :as url]
      [clojure.string :as string]
      [vlad.core :as vlad :refer [attr chain join present Validation]])]
    :cljs
    [(:require
      [cemerick.url :as url]
      [clojure.string :as string]
      [goog.date.Interval :as Interval]
      [vlad.core :as vlad :refer [attr chain join present Validation]])]))
```
Now it creates:

```clojure
(ns clean-ns.cljc-ns
  (:require
  [vlad.core :as vlad :refer [attr chain join present Validation]]
  [cemerick.url :as url]
  [clojure.string :as string]
  #?(:cljs [goog.date.Interval :as interval])))
```
@vemv
Copy link
Member

vemv commented Feb 29, 2024

Feel free to re-take these efforts at any point

@vemv vemv closed this Feb 29, 2024
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

Successfully merging this pull request may close these issues.

None yet

2 participants