Can anyone please explain how the hbs are deployed into index.html in emberjs
Welcome! For now I’ll just give a brief overview.
The basic idea is the hbs files are converted into Ember-specific Javascript that can be found when needed. Then, when your app needs to use the appropriate .hbs file the app looks for appropriate component / template and then renders it.
There’s a lot more that occurs under the hood, but that’s a basic overview. Does that help? What are you wanting to understand?
I’ll expand on this.
- the build system will compile HBS source to a JavaScript module in which is a function that will provide Glimmer a specialized array of OpCodes and values.
- If the component has a backing JS file the build system will assign the new template module to the component class.
- If the component has only an HBS file (no JS backing class) the build system will generate one implicitly and run step two on it.
- This modules are concatenated to the output with all the other JS modules.
- When the rendering engine (Glimmer) is asked to render the component it will use the compiled OpCode program to run—essentially the compiled component becomes a VirtualMachine program and Glimmer is the VM running it.
- As the GlimmerVM runs these mini programs it auto-tracks dependencies and calculates optimized instructions for updating when changes happen to the underlying tracked data.
- Re-renders have Glimmer run these optimized self generated update programs.
1 Like