-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime: Report error positions against a sourcemap #230
Comments
Check out magic-string as a potential tool for generating source maps iteratively https://www.npmjs.com/package/magic-string |
I'm having some silly idea of generating an inline source map after the compiler transformation and adding that to the final code that's going to be executed by the vm(mostly).
It seems the major difference between source code and compiled code is some additional code that wraps it. Hence we should be able to map the lines I guess. fn(state=> state)
fn(state=> {
state.data.smth = "smth"
return state;
}) eg. compiled import {fn} from "@openfn/common"
export default [
fn(state=> state),
fn(state=> {
state.data.smth = "smth"
return state;
})
] mostly the entire source code just sits in the array. Just some random thought. |
Hi @doc-han - I'm actually half way through this story. We get a source mapping solution out-of-the-box with recast - it's just about applying it in the right places in the code. I've got a prioritised work list for you with plenty of interesting compiler and runtime stuff, and we've got a couple of bigger projects planned too. Hang tight and we'll keep you busy! |
I don't think this will be easy, but it should be possible. And it's not tracked here, so:
When an expression throws, we should report an error against its sourcemapped source, refering to the line and column number, job name, and if appropriate the file name.
This is a bit tricky right now because errors are reported from the the VM inside SourceTextModule. I'm deliberately hiding stacktrace information because what we get for free is at best useless, at worst confusing.
The reported position has to refer back to the uncompiled code - although this may give us a problem if the error is in the compiled stuff (like
import {fn }
).The text was updated successfully, but these errors were encountered: