Comments (12)
Hey, thanks for the extensive write-up!
I can do PR to merge them here.
Happy to merge.
import-js
I think currently runs every time watch is triggered
Meant to make this also run only once but didn't get to it yet.
We could check if java.class.path has changed after previous run?
Sounds like a good test. Probably (get-env :dependencies)
would also work (?)
In production build the target path has no meaning and the files need not be present on .jar. Thus add-source should be used instead of add-resource to add the files to fileset.
Are you saying this with CDNs in mind? I think I'd actually prefer to just serve one combined preamble from my domain vs. loading multiple files from Javascript CDNs. Probably there is a way to support both scenarios. Maybe just not run the tasks for production? But then externs would be missing.
from boot-cljsjs.
Maybe import-js
could just be (combine-preamble :output-to "public/preamble.js)
from boot-cljsjs.
[01:41:54] you're probably right about the concatenation, I still don't see an issue with it but it's a separate thing reall
[01:42:12] No issue but no advantage in this case I think
The advantage to me was that no matter how many .inc.js
files there are you can just include that one file and it'll contain them. So HTML is same for no optimisations and advanced. Also you can add .inc.js files and they'll be loaded without you needing to add script tags.
from boot-cljsjs.
Maybe it'd make sense to put all the helpers to move files from classpath into fileset into one namespace.
from boot-cljsjs.
Okay, for output there could be at least following options:
- Development,
:unified-mode true, :optimizations :none
- Cljs task finds all the .inc.js and .lib.js files and writes shim shile which will load these files -> no need for separate htmls
- One script tag
- Classpath should contain all these files because they need to be served to browser separately in dev mode:
add-resource
- Production, normal cljsbuild, preamble files are concatenaed into the output file which contains the whole application
- One script tag
- Classpath only needs to contain the output file because .inc.js & co are already concatenaed onto it
- Production, with preamble in different file for CDN
- Two script tags
- Like 3. but concatenate task would run before cljs
- Find all files and concatenate
- *.inc.js -> some.js which shouldn't be named .inc.js because cljs shouldn't concatenate them into output file
- *.inc.js files should be removed so cljs doesn't see them
- *.lib.js should maybe be left untouched. Separating them would require some magic with Closure compiler I think
- *.ext.js don't need to be touched at all
Case 3. is only where the is multiple script tags required. Perhaps simples way to solve this would be that your app contained an empty file with the same path in development mode, thus you could use the same index.html for both and don't need to do concatenation for development.
from boot-cljsjs.
And, it might be that cljsjs isn't the proper place to do concatenation at all: If boot-cljs will support shadow-build like modules, it would handle the concatenation into multiple files.
I'm not really familar with shadow-build but I think something like this would work there, and would create one file with external libraries concatenated and other with only the app code:
:modules [{:name :preamble
:main empty-ns}
{:name :the-app
:depends-on #{:preamble}}]
This would also take care of Closure stuff requires for *.lib.js files. If empty-ns did import stuff from Closure libraries, code from those libs would be written to preamble.
from boot-cljsjs.
Seeing thet e.g. cljsjs react is now packaged as separate jars for development and minified build.
How would user automatically use non-minified for development flow and minified for packaged build? The development and minified react builds differ hugely because minified version eliminates some important debugging stuff.
from boot-cljsjs.
Cljs task finds all the .inc.js and .lib.js files and writes shim shile which will load these files -> no need for separate htmls
Is boot-cljs
handling shims for inc.js
files? I thought boot-cljs
dropped any special handling of .inc.js files.
How would user automatically use non-minified for development flow and minified for packaged build?
You'd just set the dependencies in a dev
and prod
task where you use whatever variant you want.
from boot-cljsjs.
Yes, the shim written by boot-cljs includes .inc.js files: https://github.com/adzerk/boot-cljs/blob/master/src/adzerk/boot_cljs.clj#L39-L40
from boot-cljsjs.
Production, normal cljsbuild, preamble files are concatenaed into the output file which contains the whole application
I somehow think that splitting preamble and application code is the way to go so I probably wouldn't use this. Still if it can be implemented without much pain it's probably a nice-to-have.
And, it might be that cljsjs isn't the proper place to do concatenation at all: If boot-cljs will support shadow-build like modules, it would handle the concatenation into multiple files.
I'm not sure if it's worth thinking about this just yet. I'd like to get cljsjs in a usable and somewhat stable state so people can start using it, so this also means
Tasks
So roughly we end up with these three kinds of tasks:
- Packaging tasks to make CLJSJS compatible jars
- Import tasks that add files form classpath to files
- Concat tasks that combine multiple files into one.
The third one is fairly trivial so while it could be a separate project I don't see an issue of just having the implementation within boot-cljsjs
.
Does that sound right to you?
from boot-cljsjs.
I somehow think that splitting preamble and application code is the way to go so I probably wouldn't use this. Still if it can be implemented without much pain it's probably a nice-to-have.
That is the part that is already working fine, :advanced
compilation just cocnatenates any .inc.js files to output file. And I would probably use this :) I dont regularly use CDN's and preamble is usually so small it doesn't matter (especially for intranet stuff) to just download it again whenever the app code changes.
No issue in having concat tasks here, probably good to have most of JS tasks here. They just should be separate tasks and everything would work without using them.
from boot-cljsjs.
That is the part that is already working fine
Oh dang. Wasn't aware of that. I somehow thought all handling of inc.js files has been removed from the cljs
task.
from boot-cljsjs.
Related Issues (20)
- Provide a way to have multiple externs HOT 3
- Browserified npm modules HOT 4
- Allow users to specify additional provides clauses HOT 3
- Trouble with tasks for DraftJS HOT 1
- Provide Extern generation task
- npm task HOT 5
- Sanity check task HOT 1
- Replace content fails on Windows HOT 2
- The minify task doesn't seem to work on Windows HOT 1
- Downloaded file cannot be deleted in Windows HOT 3
- Mark is not supported HOT 2
- D3 externs error HOT 1
- deps-cljs task produces invalid deps.cljs on Windows (backslashes in :externs array)
- Incorrect handling of tgz archives HOT 8
- Weird directory structure HOT 1
- Invalid cookie header when fetching zip from git
- Minifying es6 HOT 3
- validate-checksums doesn't see files from minify task
- ClassNotFoundException on Java 12 HOT 3
- it is valid for :global-exports key to be a string HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boot-cljsjs.