duct-framework / duct

Server-side application framework for Clojure
MIT License
1.13k stars 51 forks source link

Remove 'target/resources' from resource-path #63

Closed dsteurer closed 7 years ago

dsteurer commented 7 years ago

I believe having target/resources in the class path may cause subtle bugs related to reloading. The reason is that some tools like figwheel (as configured in duct.module.cljs) populate this path with .cljc files (maybe to support source maps). By default clojure.tools.namespace.repl/refresh reloads all clojure files in the class path including those files produced by figwheel. This behavior does not seem desirable because there is no reason to reload these files. Furthermore, it may be a source for bugs if those namespaces were not meant to be reloadable.

dsteurer commented 7 years ago

Correspondingly, duct.module.web should be changed so that the default middleware serves files in the path target/resources/.../public. (The function core/target-path should be used in forming this path.)

weavejester commented 7 years ago

We can't remove target/resources from the classpath. As the name implies, that's where we store generated resources.

I do think it's worth using set-refresh-dirs to set the refresh paths, however, as that also solves another issue that people have had when they've changed the source paths. Adding a line to dev.clj would make most sense.

dsteurer commented 7 years ago

Using set-refresh-dirs sounds good.

I guess instead of target/resources you would want to compute the path in the same way as duct.core/target-path. That may not be a problem because it's the same by default.

weavejester commented 7 years ago

Unfortunately the target/resources directory needs to be defined when the JVM starts up, because it needs to be on the classpath. The target-path should always point to whatever the Leiningen target path is set to.