Commit 9c66c39
authored
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%)1 parent 80dd0e1 commit 9c66c39
File tree
2 files changed
+262
-112
lines changed- packages/svelte
- src
- test
2 files changed
+262
-112
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
27 | 49 | | |
28 | 50 | | |
29 | 51 | | |
| |||
99 | 121 | | |
100 | 122 | | |
101 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
0 commit comments