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.2k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
sourcemap規格概要
rchaser53
June 15, 2017
More Decks by rchaser53
See All by rchaser53
LLVM IR入門
rchaser53
4
2.9k
pitch loaderについて
rchaser53
1
580
Rustからwasmを生成してみた話
rchaser53
1
810
Base64 VLQ概要
rchaser53
2
1.7k
TypeScript+React入門
rchaser53
1
910
Other Decks in Programming
See All in Programming
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
720
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
7.7k
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4.2k
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
2
1.1k
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
490
初めての模倣学習とVLA
natsutan
0
220
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
130
Building a Meta Ray-Ban display app
akkeylab
0
180
My Marp Sample
sinoue0108
0
120
今さら聞けない .NET CLI
htkym
0
210
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
370
AWS DevOps AgentのAzure接続機能を検証して見えた活用法/Use Cases Verified for the AWS DevOps Agent's Azure Connectivity Feature
masakiokuda
1
270
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
247
13k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
250
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.4k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.6k
Building Adaptive Systems
keathley
44
3.2k
How to Think Like a Performance Engineer
csswizardry
28
2.7k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
220
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
180
30 Presentation Tips
portentint
PRO
1
380
A better future with KSS
kneath
240
18k
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 お手軽簡単に多段ソースマップが作成できる 上のライブラリのサンプルコードとして使える
ご静聴ありがとうございました!