This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-23
Channels
- # admin-announcements (25)
- # beginners (3)
- # boot (308)
- # cider (5)
- # clojure (93)
- # clojure-bangladesh (2)
- # clojure-italy (1)
- # clojurescript (63)
- # core-logic (23)
- # datascript (6)
- # editors (1)
- # emacs (2)
- # hoplon (320)
- # incanter (1)
- # jobs (6)
- # jvm (1)
- # melbourne (1)
- # om (2)
- # re-frame (9)
- # reagent (2)
- # slack-help (5)
- # spacemacs (2)
- # yada (1)
Just to confirm my [lack of] understanding: When all of the tasks in a pipeline have been run, all files that are in the final fileset's temporary folders (even when not committed (?)) and that have output roles—those files are automatically copied into the environment's actual target folder. Is this correct?
And if that’s correct…is the actual target folder subject to being wiped clean any time before a pipeline’s final output-role temporary files are copied into it? Testing this gave me equivocal results.
I'm trying to set up a project where I use boot-http with a ring handler. I set resource-paths to #{"resources"}, ring's middleware resources to "public" (so that the ring server will serve static resources from resources/public), create a resources/public/js/main.cljs.edn so that my main.js will end up there. When I start the server if I go to localhost:3000/js/main.js it is indeed there which is cool, but the index page can't find goog's base.js. The created main.js points to main.out/goog/base.js while it should be pointing to js/main.out/goog/base.js. Can this somehow be set up to work correctly?
@xifi: :compiler-options {:asset-path “js/main.out”
Asset-path works automatically if you use “js” prefix instead of public for middleware.
the target directory is the place where the pipeline ends, where the final fileset is emitted to the real filesystem
it must be because you could have more than one boot process running, sharing that directory
the contents of the target directory after the pipeline has completed should reflect the last fileset commit! operation
@juhoteperi: i retested with latest cljs and the problem still exists
i need to investigate further but it seems like namespaces are bleeding from one build into another
main namespaces?
Cljs namespaces or could it be problem with macro reloading (clj/cljc)?
Is there any exception or is it really slow (or doesn’t finish)?
@micha: Thanks for the reply! I think I understand better now. But, when you say that "the contents of the target directory after the pipeline has completed should reflect the last fileset commit! operation", this only includes temporary files with the output role, right? Otherwise, from what I understand, all the source files would get written into the target folder too, but I could be wrong.
@micha: Thanks, I see! And, lastly, are any already-existing files in the target directory deleted before the final fileset gets written into the target?
@cigitia: the contents are merged, that is to say similar to the behavior of rsync --delete ...
nothing is written there unless a task has created a new file in the fileset with the output role
tasks that just read things from the fileset and use their own private temp dirs therefore don't affect the target dir
I see, thanks, this is very helpful! I think I might add this information to the wiki for others too…unless it's already there and I just missed it, heh.
@juhoteperi: this is a real puzzle
@juhoteperi: thanks for the tip. What I wanted to achieve was having 1 folder on the classpath that has static subfolders for css, js, images and such. The problem is that boot-cljs probably expects main.js and main.out to be emitted somewhere on the classpath so it always injects it as 'main.js'. I thought there might be a way to instrument it to consider a different root folder
@micha: I put main.cljs.edn under resources/public/js/ but main.js will try to link in main.out/goog/base.js instead of js/main.out/goog/base.js
you know, the small basic snippet you get in main.js,
if (typeof ... = undefined) {} {goog.require ...})
or something like thatcorrect. I have :resource-paths set to #{"resources"} and the ring middleware for resources points to "public", so the web server can look into resources/public
now my edn is under the js folder and the generated main.js tries to load main.out/goog/base.js
people usually do that because they have supersecret/namespace.clj
on the classpath mixed in with their static resources
so the easiest thing to do is to put the static resources in some arbitrary directory, like public/
I'm plunging into this like a crazy person No js/html/css or web server experience whatsoever. Fun fun fun!
My situation is that I have some source files that I want to compile using task #1, and I also want to use those output files in task #2. But task #1 takes hours to do, and the source files that I’m compiling with change relatively rarely. I don’t want to run task #1 every time I want to run task #2, but task #2 cannot see task #1’s output unless it runs right after task #1 in the same pipeline; it can’t see any files in the target directory.
The source files are going to change at most once or twice a year—they’re Unicode Character Database data.
one thing you can do in this case is make a jar file of task #1 and then depend on that
I’d have preferred keeping everything in one project, sigh, but you’re probably right: this might be the best way, yes.
…Well, actually, I was wrong: the cache files are going to change way more often than that, because I’m going to be continuously adding new data to them.
I’ve made it such that when I run Task #1 on consecutive source files (some of which are big and slow, some small and fast), it merges the cache data together.
I’d like to be able to run Task #1 on small files often, but Task #1 on big files rarely, with the automatic merging of preexisting output files.
so they can be merged into the fileset really fast, with everything precomputed and hashed and whatnot
This cache-dir!
might just be what I’m looking for.
What would be the difference between that new thing and cache-dir!
?
the money is here https://github.com/boot-clj/boot/blob/b04ed7bcd2dbef49c24e8c283114cd601fa480ae/boot/core/src/boot/core.clj#L413
Oh, ah, so then is using cache-dir!
slower than import-cache!
, since it still has to compute a lot of stuff at the beginning of a pipeline?
then you can use export-cache!
to populate it with the contents of any directory you specify
this will populate your cache dir with files and a manifest in a special format that will allow boot to merge the contents with any fileset very efficiently
because the work of importing the things into the fileset is done when you do export-cache! and then amortized over all the time you merge
then once you have exported the dir to a cache dir you can use (add-resource fileset the-cache-dir :cached? true)
it's like 50% complete, we still need to have it use the existing merge strategies (in case of name collisions boot allows the user to specify different merge strategies and bind to a dynamic var so add-resource et al will use those merge fns)
I see—that sounds amazing and exactly what I need.
So cache-dir!
is part of this; it’s not ready yet, either.
The problem with using JARs is that the output files are actually going to change often: just only a few hundred output files at a time, but still frequently, at least while I’m developing.
That is, I’m going to be running Task #1 often on small source files, and I wish to be able to use the data in already-existing output files, whenever they already exist, and merge that old data into the new data.
well cache-dir!
will at least give you a place to cache things that will persist across multiple builds
Right, that’s what I’ll probably do. It’ll probably take a while to load the millions of files in the cache, though, right?
it's basically just giving you a directory you can use as if you made a directory outside of boot
It won’t copy the cache into temporary files every time I run a task pipeline, right?
I might eventually if another project needs to use those compiled files, but that’s further in the future anyway.
If I’m understanding correctly, will import-cache!
be for when you want to use cached files as a proper part of the fileset, e.g., when you want some of those cached files to be outputted into the target directory?
as it is right now the uber
task is used in the pipline with the jar
, war
, zip
tasks, etc
and for each JAR it extracts all the entries and writes them to files which are added to the fileset
so this is nice from the composition perspective, because now we don't need separate uberjar, uberwar, uberzip etc tasks
but it's not so nice for performance, because it's writing a ton of files, and adding entries directly to jars, wars, zips, etc would be faster
we extract all the files from a JAR into the fileset only once, when we first see this JAR
so my task runs fine, boot-reload up through the websocket, then when I save a file I get this error
Load failed: Jsloader error (code #0): Error while loading script /public/main.out/stair_cljs/core.js?zx=s10xz74tt4l5
reload.js (line 222)
if I click on reload.js I don't get to the script file. Not sure if firebug in FF is the best developmetn option
@juhoteperi: i figured it out
these errors can get pretty cryptic. Like now,
TypeError: src is null
Line 933
I have no idea what is thatand the examples you and @alandipert posted have no server-side code
@micha: PR looks good. I'll merge that and do a release?
Ouch, looks like automatically set asset-path is broken
Probably not
js/main.cljs.edn sets asset-path as "main.out"
when it should be "js/main.out"
Ah, could be caused by your patch
or no
I'm trying to decipher how the relative path is set
The test is now using simple optimization so asset-path doesn't matter
We should have separate tests for none and simple
the tests happen to work as index.html is also inside demo path
It is in the same dir
But it's broken when it's not
It doesn't need to
It should work and it has worked
It should currently set the asset-path relative to root of fileset
but it doesn't do that
But I should talk with David about improving Cljs version
Saapas used to work...
having a requirement that the js file and output dir have a specific relationship with the html file seems totally reasonable to me
Before having .cljs.edn inside js/ folder would set asset-path as js/out
e.g. it used the relative path inside fileset
Okay, I see where this changed https://github.com/adzerk-oss/boot-cljs/commit/ffa254a69a93fd52a8a029cfb2fb4020d23c5d8a
I'll have to think how to setup my projects
For now manually setting asset-path works
And probably that is the best solution, but we could make it possible to set asset-path without knowing about output dir name
Should be simple and allow all use cases
or html files?
quite possible to load the same file from multiple paths
If my blog used cljs I would need that
Because each post is in it's own folder and there is only one js file
Sure I can
I just need to set absolute path manually
"/js/main.out"
There could be asset-path task option which wouldn't need to have output dir name appended
It would be really simple to document how to use that with all the use cases (and when it's not needed)
Anyhow, 1.7.48-3 is now released
lol typo