Is Prepack (https://github.com/facebook/prepack) going to be integrated into Meteor core, to speed things a little bit?? Prepack - A tool for making JavaScript code run faster. Prepack was open sourced by Facebook a few days ago at https://prepack.io.
Hmm, interesting. So could I just take the minified .js blob that Meteor puts out, and run it through Prepack, and itâll improve performance somewhat?
This will improve performance even further. According to the docs:
Prepack is a tool that optimizes JavaScript source code: Computations that can be done at compile-time instead of run-time get eliminated. Prepack replaces the global code of a JavaScript bundle with equivalent code that is a simple sequence of assignments. This gets rid of most intermediate computations and object allocations.
Oh, that looks very interesting, the examples on their website are really cool! I suspect the end result might be less than the examples show though, as V8 is pretty smart and probably already does a lot of these optimizations at runtime. However, doing them at compile time would be better of course, and there might be some stuff that V8 doesnât do.
Youâre right! V8 is smart already. Facebook takes things further in their implementations of âpopularâ tools. Though Prepack isnât ready for production use right now, it has several plugins already for VScode, Webpack that I want to try out on Meteor to see what performance gains it actually brings to my existing apps. https://prepack.io/getting-started.html
Hmm, I tried running it on my client blob.
First it gave the error __meteor_runtime_config__ is not defined
I fixed that by copying the __meteor_runtime_config__
inline script that is in the HTML of my site and pasting it at the top.
Now it gives this cryptic error instead:
not an object
TypeError
at client.js:4:5255
at call (native)
at client.js:4:4727
at client.js:4:2
Does anyone have actual benchmarks of anything yet?
Youâre running into this: https://github.com/facebook/prepack/issues/538
We made need to wait for this: https://github.com/facebook/prepack/issues/24
If you come up with a solution in the meantime, let me know
But I thought it said âusing environment browserâ or something when it ran. Will check againâŚ
According to the section The Environment matters! of https://prepack.io/,
Prepack has no built-in knowledge of document or window. In fact, when prepacking code which references such properties, they will evaluate to undefined.
But it says here that it uses the âbrowserâ built-in environment by default. I also now tried with --compatibility âbrowserâ, and it gave me the same error
Edit: Ah, I checked at 4:5255 now, and itâs this function:
function(){"complete"===document.readyState&&u()})
So it is indeed document that is causing trouble, even though they seem to say in the options spec that theyâve fixed that
Would be nice if there was some way to just say âignore optimizing anything that references this objectâ.
When is Prepack ready to be used in production?
Wait for our latest release to reach v1.0.
I think itâs not ready for integration but Iâm curious what performance benefits we can get from using it in a real life application.
Prepack is gonna be in alpha for a while, definitely not ready for production, unfortunately. Currently, itâs only at v0.2.2.
Perhaps we could put together an Atmosphere package (yes, those still exist) integrating it into the Meteor build process, to at least have people start playing around with it in development.