Closed kostaa closed 5 years ago
It is likely because Firebase bundles all dependencies in the same archive. And most of those dependencies are regular Node.js packages, which we do not control from Dart.
Building Dart code only affects your final main.dart.js
file (or whatever name you gave it) and you should only compare this file.
Based on your logs it does go down by more than 60% it looks like.
Ok that makes sense but in that case there is not much point in minifying I guess since the bulk of the code will always be in the libraries. Unless there is a way to minify the Node.js packages as well.
Yeah, I'm not sure if Firebase provides any tool to minify everything.
But it's really not that critical for server-side code. Minification is important for browser apps as far as I understand, since it improves latency. Server-code is loaded in memory and sits there.
That is true. Unless you have to debug your code by constantly re-compiling and re-deploying it to the server which I have been doing over the last seven days or so :-) But I am pretty much done now.
You can at least write tests for you own code which does not depend on FirebaseFunctions.
I usually do one of two things:
Write a regular Dart test for any code that can be tested without depending on cloud stuff. I mark those tests with @TestOn('node')
and just run them with pub run test
.
Create a simple console app which invokes more complex logic, so I can test it without having to re-deploy every time I change something (I only need to re-build the script, but that's tolerable).
This way I can catch 99% of errors before having to deploy with Firebase tool.
I should probably write a blog post or something about this with more details. :)
This was sort of one off a proof of concept if you like. Going forward I will definitely need to adopt a bit more structured approach. So any thoughts you can share will be most welcome.
I have noticed that running the build with the
minify
flag does not seem to make much difference when it comes to the size of the actual code that is uploaded to the server.Without the flag I get:
and with the flag:
Since the minified code is less then half of the non-minified I would expect much bigger reduction in the code that is uploaded as well.