Repository navigation
Conversation
Prior to this commit every application shipped the runtime `ProfilerEvent` object, because the framework's own profiler calls referenced it. Only Angular DevTools reads that object, and its reverse number to name map is never read at all. Internal calls now use an inlined `const enum`, so they compile down to plain numbers. The runtime enum is still exported as `ɵProfilerEvent` for DevTools, and the application bundler now drops it: about 1.8 kB less raw JavaScript, around 350 bytes gzipped, in every Angular application.
| * applications no longer ship the runtime `ProfilerEvent` object, which only Angular DevTools | ||
| * reads. The members must stay identical to `ProfilerEvent`, which `profiler_spec.ts` asserts. | ||
| */ | ||
| export const enum ProfilerEvent { |
There was a problem hiding this comment.
I don't like very much that this is a distinct enum.
If the one in packages/core/primitives/devtools/src/profiler_types.ts is changed, nothing will warn us here.
There was a problem hiding this comment.
the drift is covered bc the assertion in profiler_spec.ts is typed against both enums, so adding or removing a member on either side fails to compile, and re-numbering fails the test
There was a problem hiding this comment.
BUT i can move that const enum into profiler_types.ts next to the public enum and initialize the public members from it (TemplateCreateStart = ProfilerEventInternal.TemplateCreateStart). Values can then never diverge, and a member added to the public enum fails immediately, WDYT?
There was a problem hiding this comment.
And why not make the enum a const object (and also expose its type) ?
Prior to this commit every application shipped the runtime
ProfilerEventobject, because the framework's own profiler calls referenced it. Only Angular DevTools reads that object, and its reverse number to name map is never read at all.Internal calls now use an inlined
const enum, so they compile down to plain numbers. The runtime enum is still exported asɵProfilerEventfor DevTools, and the application bundler now drops it: about 1.8 kB less raw JavaScript, around 350 bytes gzipped, in every Angular application.