squint-cljs / squint

Light-weight ClojureScript dialect
https://squint-cljs.github.io/squint
586 stars 35 forks source link

Macros get resolved as normal functions #533

Open ranfdev opened 1 month ago

ranfdev commented 1 month ago

version v0.7.110

problem following the usual clojurescript behavior, this macro should be executed during compilation:

;; file test.cljs
(ns test
  (:require-macros [test]))

(defmacro two [] 2)

;; file test_runner.cljs
(ns test-runner
  (:require [test]))

(test/two)

but test_runner.js gets compiled to

import * as squint_core from 'squint-cljs/core.js';
import './test.mjs';
test.two();

I need to provide both functions and macros in the same namespace, so that they can be used with the syntax myns/mymacro. For example, the solid namespace I'm writing should provide both solid/for (a macro) and solid/render (a normal function).

borkdude commented 1 month ago

This isn't supported in cherry / squint. Macros should always be loaded using :require-macros. This is done because files in cherry and squint can be recompiled without scanning other files in your project. It's unlikely to change any time soon I think.