Skip to content

Instantly share code, notes, and snippets.

@twada
Last active August 29, 2015 14:05
Show Gist options
  • Save twada/103d34a3237cecd463a6 to your computer and use it in GitHub Desktop.
Save twada/103d34a3237cecd463a6 to your computer and use it in GitHub Desktop.
power-assert 多段 SourceMap 対応の方針

power-assert 多段 SourceMap 対応の方針

試験は twada/battlefield-sourcemaps で行っている

power-assert 出力行の補正

  • SourceMap 対応が入った espower 0.9.0 を使う
  • espower(ast, options) の第二引数 options に sourceMap というキーで上流の SourceMap オブジェクトを入れる
  • options.sourceMap が与えられた場合、 AST 変換時のファイル名、ファイル行番号を補正する
  • AST の段階でできるのはここまで

各 instrumentor 対応方針

基本方針

  • 方針が安定するまで SourceMap 対応の espower 0.9.0 を直接使う (espower-source ではなく)
  • 上流の SourceMap を探す (探し方は各 instrumentor によって異なる)
  • 上流 SourceMap を発見した場合 espower の options に入れる
  • escodegen から出てきた SourceMap を上流の SourceMap とつなぐ
  • 下流に流す (流し方は各 instrumentor によって異なる)

grunt-espower

作業 PR support multistage sourcemap by vvakame · Pull Request #2 · twada/grunt-espower -> リリース完了

grunt では上流 SourceMap がどう来るか調べる必要がある。

  • js と同一ディレクトリに外部 .map ファイルのパターン
  • js ファイル末尾に base64 コメントで付いているパターン

gulp-espower

espower-loader

  • しくみとして下流は存在しないので、読み込んだファイルに base64 形式の SourceMap が付いていた場合 espower に渡すだけで良い?

espowerify

  • 作業 PR SourceMap transform chain by twada · Pull Request #4 · twada/espowerify -> リリース完了
  • 参考: browserify v2 adds source maps
  • browserify の多段 SourceMap は各 transform がファイル末尾コメントの SourceMap に base64 で埋め込む責務を担う
  • stream から読み込んだコード末尾に上流の SourceMap が付いている可能性がある
  • 上流 SourceMap が付いていた場合は espower が出した SourceMap とつないでからコメントにして末尾に付ける

espower-coffee

  • CoffeeScript コンパイラから出てきた SourceMap を espower に渡す
@vvakame
Copy link

vvakame commented Aug 27, 2014

https://twitter.com/azu_re/statuses/504429825516244992
microsoft/TypeScript#496
えっあっ file:// が出てくるのってバグだったの…??? ってなってるなどしてます(まだよくわからない

@twada
Copy link
Author

twada commented Aug 27, 2014

おおお、 file:// が出るのは TypeScript コンパイラのバグの可能性があるのですか……

@twada
Copy link
Author

twada commented Sep 6, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment