Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
sourcemap規格概要
Search
rchaser53
June 15, 2017
Programming
1
1.1k
sourcemap規格概要
rchaser53
June 15, 2017
Tweet
Share
More Decks by rchaser53
See All by rchaser53
LLVM IR入門
rchaser53
4
2.6k
pitch loaderについて
rchaser53
1
520
Rustからwasmを生成してみた話
rchaser53
1
740
Base64 VLQ概要
rchaser53
2
1.5k
TypeScript+React入門
rchaser53
1
850
Other Decks in Programming
See All in Programming
効率的な開発手段として VRTを活用する
ishkawa
0
140
初学者でも今すぐできる、Claude Codeの生産性を10倍上げるTips
s4yuba
16
11k
チームで開発し事業を加速するための"良い"設計の考え方 @ サポーターズCoLab 2025-07-08
agatan
1
430
スタートアップの急成長を支えるプラットフォームエンジニアリングと組織戦略
sutochin26
1
6k
Deep Dive into ~/.claude/projects
hiragram
14
2.6k
Modern Angular with Signals and Signal Store:New Rules for Your Architecture @enterJS Advanced Angular Day 2025
manfredsteyer
PRO
0
220
Railsアプリケーションと パフォーマンスチューニング ー 秒間5万リクエストの モバイルオーダーシステムを支える事例 ー Rubyセミナー 大阪
falcon8823
5
1.1k
Python型ヒント完全ガイド 初心者でも分かる、現代的で実践的な使い方
mickey_kubo
1
130
VS Code Update for GitHub Copilot
74th
2
650
状態遷移図を書こう / Sequence Chart vs State Diagram
orgachem
PRO
1
120
イベントストーミング図からコードへの変換手順 / Procedure for Converting Event Storming Diagrams to Code
nrslib
2
850
レベル1の開発生産性向上に取り組む − 日々の作業の効率化・自動化を通じた改善活動
kesoji
0
230
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
960
Making the Leap to Tech Lead
cromwellryan
134
9.4k
Optimising Largest Contentful Paint
csswizardry
37
3.3k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.9k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Thoughts on Productivity
jonyablonski
69
4.7k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
Scaling GitHub
holman
460
140k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.3k
Writing Fast Ruby
sferik
628
62k
Transcript
Source Map Revision 3 概要 @rchaser53
CAUTION! 発表内容は発表者の独自調査によるものです 間違ってたらすみません
規格(Source Map Revision 3) 2011/4/12 年に初版に初版が公開 非常に短く実質7p くらいしかないので気軽に読める量 ( 気軽に読める内容とは言っていない)
sourcemap の出力結果 実際は1 行だけど見づらいから改行している { "version" : 3, "file": "out.js",
"sourceRoot": "", "sources": ["foo.js", "bar.js"], "sourcesContent": [null, null], "names": ["src", "maps", "are", "fun"], "mappings": "A,AAAB;;ABCDE;" }
interface と概要 { version: 3; // version 3 3固定 file:
string; // 対象 sourceRoot?: string; // 基準 sources: string[]; // 対象 元 sourcesContent?: string[]; // 変換元 names: string[]; // 対象 出力 mappings: string; // 生成前 位置 }
sourcesRoot とsources 変換前のファイルの位置を示す ファイルが存在しないと参照した際に何も表示されない sourcesRoot が空文字なケースもある (sources に全部書かれている)
対象のファイルが存在する場合
対象のファイルが存在しない場合
sourcesContent 変換前のソース ts=>js であればts のファイルの内容が出力されている sources より優先される
こんな感じに書かれている サーバに変換前のファイルを配置しなくてよくなる
name 変換後のファイルにの単語が配列として保存されている mappings で使用される 重複されて記述されることはない [] でも普通に動く
mappings Base64 VLQ というので記述されている 絶対的に情報を指定せず、相対的に情報を指定する 複雑だけど規格書には詳細は定義されていない こんなの ;AAAAA,EAAE,gBABC,CAAEB;
別資料へ… Base64 VLQ 概要
その他の情報 ・inline sourcemap ・X-Sourcemap
inline sourcemap ファイルに直接sourcemap の情報を書き込む xxx.js.map とかいらない ファイルのサイズはお察し
こんな感じになる
sourceMappingURL=data:application/json;base64 json でbase64 フォーマットだということを示して eyJ2ZXJzaW9uIjozLCJmaWxlIjoic291cmNlbWFwVGVzdC5qcyIsInN base64 ベースの情報を続けて記述する
eyJ2ZXJzaW9uIjozLCJmaWxlIjoic291cmNlbWFwVGVzdC5qcyIsInN ↓ { "version":3, "file":"sourcemapTest.js", "sourceRoot":"", "sources":["../src/sourcemapTest.ts"], "names":[], "mappings":"AAGA,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;AACpB,OAAO,CAAC,G "sourcesContent":["interface
Poyo {\n hoge : string;\n}\nconsole.log }
X-Sourcemap sourcemap の位置をヘッダーで指定する ソースに不要な情報が表示されなくなる 正直ソース読む人はheader も読みそうな気はする
便利なライブラリ集 mozilla/source-map sourcemap を作成やsourcemap 同士の関連付けに使える babel, webpack, uglify などが使用(TypeScript は未使用)
azu/multi-stage-sourcemap お手軽簡単に多段ソースマップが作成できる 上のライブラリのサンプルコードとして使える
ご静聴ありがとうございました!