Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(codegen): dont return data from GetModuleHook in first pass
Stencil doesn't provide any guarantees around template rendering order. This was a concious decision made to prevent overly complex templating usecases where templates aren't the best place to encapsulate said logic. However, in order for templates to be able to use module hooks, we still needed the notion of an "add to hook" and "get hook" state. This brought the two-pass render system that we have today. The first render pass is for adding to module hooks while the second is for retrieving module hook data. Only the results of the second pass are used for writing to files on the filesystem. However, due to an oversight in the original implementation, we never actually limited the `GetModuleHook` function to return data just during the second pass. It returns data even during the first pass, which means that it's possible to access data in a non-determisitic fashion during the first pass. This commit changes that behaviour to have `GetModuleHook` always return `[]any` during the first pass. This ensures that there is never any order dependent module hook data being returned. As a reminder for reviewers, module hooks only write to the module hook in-memory store during the first pass. They noop during the second pass.
- Loading branch information