Skip to content

Commit

Permalink
Fix #413: require + alias with hyphen in REPL mode
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Dec 16, 2023
1 parent 2e49ff9 commit 7398632
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/squint/compiler_common.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,9 @@
#_#_ns-obj " = {aliases: {}};\n"
(reduce-kv (fn [acc k _v]
(if (symbol? k)
(str acc
ns-obj "." #_".aliases." k " = " k ";\n")
(let [k (munge k)]
(str acc
ns-obj "." #_".aliases." k " = " k ";\n"))
acc))
""
@*aliases*)))))))
Expand Down
6 changes: 5 additions & 1 deletion test/squint/compiler_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,11 @@
(is (str/includes? s "local_file.some_fn();")))
(let [s (compiler/compile-string "(ns bar (:require [\"./foo.mjs\" #_#_:refer [foo-bar] :as foo-alias])) (prn foo-alias/foo-bar)")]
(is (str/includes? s "import * as foo_alias from './foo.mjs'"))
(is (str/includes? s "prn(foo_alias.foo_bar);"))))
(is (str/includes? s "prn(foo_alias.foo_bar);")))
(doseq [repl [false true]]
(let [js (compiler/compile-string "(require '[clojure.string :as str-ing]) (str-ing/join [1 2 3])" {:repl repl})]
(is (not (str/includes? js "str-ing")))
(is (str/includes? js "str_ing")))))

(deftest dissoc!-test
(is (eq #js {"1" 2 "3" 4} (jsv! '(dissoc! {"1" 2 "3" 4}))))
Expand Down

0 comments on commit 7398632

Please sign in to comment.