From 649730065b80837d87820c2053cc9668b9d827fc Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 7 May 2024 16:50:54 +0200 Subject: [PATCH] Fix export of class name with dashes, #526 (#528) --- CHANGELOG.md | 1 + src/squint/compiler_common.cljc | 2 +- test/squint/compiler_test.cljs | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d25ebf1a..de9e73fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ## v.0.7.108 - [#492](https://github.com/squint-cljs/squint/issues/492): defclass static methods and fields +- [#526](https://github.com/squint-cljs/squint/issues/526): Fix export of class name with dashes ## v0.7.107 diff --git a/src/squint/compiler_common.cljc b/src/squint/compiler_common.cljc index 3fbb2ac3..aeebb0ab 100644 --- a/src/squint/compiler_common.cljc +++ b/src/squint/compiler_common.cljc @@ -1079,7 +1079,7 @@ break;}" body) (defmethod emit-special 'squint.defclass/defclass* [_ env form] (let [name (second form)] - (swap! *public-vars* conj name) + (swap! *public-vars* conj (munge* name)) (defclass/emit-class env emit (fn [async body-fn] diff --git a/test/squint/compiler_test.cljs b/test/squint/compiler_test.cljs index e684cb28..c7b8b169 100644 --- a/test/squint/compiler_test.cljs +++ b/test/squint/compiler_test.cljs @@ -1704,8 +1704,8 @@ (deftest defclass-test (async done #_(println (jss! (str (fs/readFileSync "test-resources/defclass_test.cljs")))) - (is (str/includes? (compiler/compile-string "(defclass Foo (constructor [this]))") - "export { Foo }")) + (is (str/includes? (compiler/compile-string "(defclass Foo-bar (constructor [this]))") + "export { Foo_bar }")) (is (str/includes? (:javascript (compiler/compile-string* "(defclass Foo (constructor [this]))" {:repl true :context :return})) "return Foo"))