turbo
131c370a - Fix source map tracing for HMR updates (#3063)

Commit
3 years ago
Fix source map tracing for HMR updates (#3063) HMR is handled via an `eval(newCode)`, and that eval will inherit the filepath of the currently running file (in our case, the chunk file that contains the runtime code). To properly trace, we need to know both the chunk and the item ids, so we trace via the correct item's source map. Thankfully, we can use the (underspecified) [`//# sourceUrl` ](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/javascript/source-maps#use--sourceurl-to-name-evaluated-files-in-the-sources-tool) meta comment to name the file we're currently evaluating. That'll get used as the stack frame's file. We can then encode the chunk path and item id into the filename, and let next's stack tracing code handle the rest. This also fixes an off-by-one on the column. Source maps are 0-based, but the line/column of a file as displayed in an editor or dev tools are 1-based.
Author
Parents
Loading