Tensegritics / ClojureDart

Clojure dialect for Flutter and Dart
1.41k stars 90 forks source link

Transitive dart dependencies #280

Closed cgrand closed 3 months ago

cgrand commented 11 months ago

The problem is allowing a package (typically a CLJC package) to declare dependencies to a Dart package and this dependencies declaration to be preserved irrespective of the packaging and of the number of intermediate dependency.

When a clojure lib is packaged as a jar, only "classes", resources are preserved. deps.edn is lost. pom.xml is sometimes embedded under a descendant path of META-INF. Whatever we need we should put it under META-INF.

We could write in MANIFEST.MF but this would mean being dependent on the packaging of the lib and we would need something else for git or local deps.

We'd like to be be able to add dart deps under :deps in deps.edn. But it's unclear how to make it participate to tools.deps. Even if it's not critical, dart deps are not namespaced, they use a single identifier but tools.deps complain about non-namespaced symbol so it could mean using symboles like pub/shared_preferences.

We are not interested into publishing clj libs to pub.dev so dart deps don't make sense for tools.deps in general to care about dart deps. Thus it may be easiest to follow the same route as shadow-cljs and use a :dart/deps key.

momerath42 commented 11 months ago

I don't know about others, but only the local/root case matters to me (and it would definitely be nice to have soon); I'd be happy to work on this, if it's a good candidate for getting my feet wet.

cgrand commented 11 months ago

After more thoughts on the problem:

dupuchba commented 11 months ago

@momerath42 that's very nice but I think but we need it ASAP so we are going to do it. But we could need some help on review, testing, design & co

momerath42 commented 11 months ago

a76c09a41 is working great, with a bunch of dart dependencies pulled in from my other (root/local) project, as well as use of several of its .cljd files. Thanks!

cgrand commented 11 months ago

In a76c09a we implemented a way to handle dart dependencies (transitively across deps.edn).

For lib users: it should just work, add the lib to deps.edn and the next cljd command (compile, flutter, clean) will retrieve dart deps if needed.

For lib authors:

dupuchba commented 11 months ago

[ ] TODO: document it