-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Resolve symbolic namespaces via API #494
Comments
Although we've discussed this, I think this also falls into the category of proposing a solution rather than stating a problem. I think I prefer to have this logic as much as possible in one place such that efforts shouldn't have to be duplicated. This logic already exists for the squint CLI + |
Fair point, let me try to get more at the underlying problem: A bit of contextThese days many tools operate on ESM module graphs, they use them to create bundles, transpile files as they are imported etc. Tools like Vite and Rollup allow you to tell them how to resolve the right side of an import statement. For example import Logo from "./logo.svg?react"; In this case the plugin can tell Vite that it knows how to resolve modules ending with Why does this matter for Squint?Currently to resolve namespaces we have Right now a Vite plugin could intercept module resolution but with namespaces just being compiled to plain strings we'd need to employ heuristics to determine if a given string is in fact a namespace. (require [foo.bar :as foo]) import foo from "foo.bar"; The JS doesn't give a clear indication that Other notes
I guess import foo from "./src/foo/bar.cljs"; but then that isn't really runnable JS since the cljs file still needs to be compiled / the import needs to point at JS. But for the purpose of the Vite plugin this could work. |
Another thought: Maybe the API could also be to pass the contents of |
squint could still resolve those symbols to e.g. |
This is more in line with your second post I think, but the API could also just read |
That would also then enable using macros |
Similar discussion as #500 I think if we would expose this function: squint/src/squint/internal/cli.cljs Lines 66 to 104 in 9d24153
or this one: squint/src/squint/compiler/node.cljs Line 86 in 9d24153
or perhaps a slight variation on both then we would have both macro and symbolic namespace support |
To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.
Is your feature request related to a problem? Please describe.
I'm using squint with vite as a build tool and I'd like to explore how I could integrate library dependencies like promesa into squint. Currently when requiring a namespace it just shows up as a verbatim string which makes it difficult to implement custom resolver logic.
Describe the solution you'd like
Something like this would be great, the prefix could be configurable but also a static prefix would be enough.
Additional context
Here's a basic Rollup plugin using
resolveId
Rollup is the bundler behind
vite
and supports emitting code for the browser, node etc.The below can be used as an entry in the
plugin
array in vite's config.The text was updated successfully, but these errors were encountered: