shama / yo-yoify

Transform choo, yo-yo or bel template strings into pure and fast document calls
111 stars 17 forks source link

add source maps, closes #39 #60

Closed goto-bus-stop closed 6 years ago

goto-bus-stop commented 6 years ago

transform-ast is similar to falafel but generates source maps using magic-string. if the input source code already contains a source map, the generated source map takes that into account and maps back to the original source.

with babelify + yo-yoify, using https://sokra.github.io/source-map-visualization:

image

it maps back mooostly to the correct places--some things aren't perfect, for example if you have a big inline function

html`
  <div onclick=${function () {
    throw Error('xyz')
  } />
`

it is not mapped individually, so you only know that the error was thrown somewhere in the template string.

that's still better than the current situation though, because not doing source maps at all means other transforms's source maps will be thrown off by N lines, and then errors would be pointing to the wrong thing entirely.

yoshuawuyts commented 6 years ago

v4.3.0 :grin: