Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(svelte): Track components without <script> tags (#5957)
Make our Svelte component tracking feature track components without `<script>` tags. Previously these components would not be picked up by our preprocessor because its `script` hook is only called for components with script blocks. With this PR, we first leverage the `markup` hook to check if a script block exists. If it doesn't, we add an empty script tag which we later revisit in the `script hook` where we inject the component tracking code. Note: To determine if a script tag exists in the file, we use a regex check which has drawbacks, as it is not 100% bullet proof. However, we decided that for the lack of better options as explained in [#5923(comment)](#5923 (comment)) we'll go with this approach for now. Also, the svelte compiler internally uses the same regex to detect `<script>` tags. Add additional tests to check the new behaviour (brings up preprocessor coverage to 100%)
- Loading branch information