You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I don't know if a solution for this already exists.
I understand that it is possible to use normal dynamic import syntax like so:
(js/import"./test.mjs")
however, it would be nice for Squint to resolve paths with the ability to provide a namespace just like top level requires do, as this would make things much nicer.
Describe the solution you'd like
I'd like to be able to do something like:
(js/import 'test)
;; or
(js/import (find-ns 'test))
I know that using symbols in Squint may be out of scope, as when compiled it attempts to use the cljs.core module, which comes from Cherry, I'm assuming? But possibly providing a built in way to do this within Squint could be beneficial?
(I'm still relatively new to Clojure so I'm not sure the right way to go about this.)
Edit: A possible idea is to have a universal way in Squint (a compile-time macro?) to turn a namespace into a javascript url path, that can be used by Squint developers, as well as internally as part of the normal :require syntax. Just a thought. :D
Describe alternatives you've considered
I've considered creating my own function that transforms a keyword into a namespace url. This could work like so:
(import-from-module:test.core)
which would translate to this at runtime:
(js/import"./test/core.mjs")
This would work as keywords are just compiled into strings at compile time in Squint.
However, this will likely have the runtime cost of not allowing bundlers like Vite to code split these modules properly (as the paths aren't defined properly at build time.)
Additional context
N/A
Thank you in advance Mr. Bork!
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I don't know if a solution for this already exists.
I understand that it is possible to use normal dynamic import syntax like so:
however, it would be nice for Squint to resolve paths with the ability to provide a namespace just like top level requires do, as this would make things much nicer.
Describe the solution you'd like
I'd like to be able to do something like:
I know that using symbols in Squint may be out of scope, as when compiled it attempts to use the cljs.core module, which comes from Cherry, I'm assuming? But possibly providing a built in way to do this within Squint could be beneficial?
(I'm still relatively new to Clojure so I'm not sure the right way to go about this.)
Edit: A possible idea is to have a universal way in Squint (a compile-time macro?) to turn a namespace into a javascript url path, that can be used by Squint developers, as well as internally as part of the normal
:require
syntax. Just a thought. :DDescribe alternatives you've considered
I've considered creating my own function that transforms a keyword into a namespace url. This could work like so:
which would translate to this at runtime:
This would work as keywords are just compiled into strings at compile time in Squint.
However, this will likely have the runtime cost of not allowing bundlers like Vite to code split these modules properly (as the paths aren't defined properly at build time.)
Additional context
N/A
Thank you in advance Mr. Bork!
The text was updated successfully, but these errors were encountered: