Commit e3dda4c
authored
fix(sveltekit): Ensure target file exists before applying auto instrumentation (#8881)
In our auto instrumentation Vite plugin for SvelteKit, we read
`+(page|layout)(.server).(js|ts)` files' code to determine if we should
add our wrapper to the file or not. We previously didn't check for a
file id's existence before reading the file if the id matched that
certain pattern, wrongly assuming that these ids would always map to
actually existing files.
It seems like Vite plugins such as Houdini's plugin add file ids to the
build for files that actually don't exist (#8846, #8854) . When our
plugin's `load` hook was called for such an id, it then tried to access
and read the file which caused a build error.
This patch now adds a file existence guard to ensure we simply no-op for
these files.1 parent ff0da3e commit e3dda4c
File tree
2 files changed
+29
-6
lines changed- packages/sveltekit
- src/vite
- test/vite
2 files changed
+29
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
93 | 104 | | |
| 105 | + | |
94 | 106 | | |
95 | 107 | | |
96 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
| |||
198 | 204 | | |
199 | 205 | | |
200 | 206 | | |
201 | | - | |
| 207 | + | |
202 | 208 | | |
203 | 209 | | |
204 | 210 | | |
205 | 211 | | |
206 | 212 | | |
207 | 213 | | |
208 | | - | |
| 214 | + | |
209 | 215 | | |
210 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
211 | 222 | | |
212 | 223 | | |
0 commit comments