Reputation: 12367
Using the Angular CLI, with the default ng new
app, I created a JIT and an AOT project to compare file sizes, bundling, inspect in Chrome DevTools etc.
I then served both of these, and inspected the files in Chrome DevTools - JIT: ng serve - AOT: ng serve --aot
For the JIT version, the ngFactory files have all be compiled by the JIT compiler (for AOT, these exact functions are in the pre-compiled main bundle).
The documentation says that the ng class factories are created in memory in the JIT version of the app
JIT compilation generates these same NgFactories in memory where they are largely invisible.
When I veiw the JIT app in DevTools, (see screenshot) I can see the JIT compiled factory files under no domain. Are these actually in-memory, or does the compiler generate temporary files, or what??
Upvotes: 2
Views: 202
Reputation: 214175
They are in browser memory when you're running JIT compilation.
Angular generates them through new Function()
For example:
var expression = `
function Yurzui() {
this.param1 = name;
}
Yurzui.prototype.hello = function() {
return 'Hello ' + this.param1;
}
return Yurzui;
//# sourceURL=/yurzui/say-hello/my.factory.js
`;
var func = new Function('name', expression);
var clazz = func('Some name');
alert((new clazz()).hello());
Upvotes: 3