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
pitch loaderについて
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
rchaser53
March 09, 2018
Programming
1
540
pitch loaderについて
rchaser53
March 09, 2018
Tweet
Share
More Decks by rchaser53
See All by rchaser53
LLVM IR入門
rchaser53
4
2.8k
Rustからwasmを生成してみた話
rchaser53
1
770
Base64 VLQ概要
rchaser53
2
1.6k
sourcemap規格概要
rchaser53
1
1.2k
TypeScript+React入門
rchaser53
1
880
Other Decks in Programming
See All in Programming
CSC307 Lecture 01
javiergs
PRO
0
680
Data-Centric Kaggle
isax1015
2
760
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
120
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
180
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
20
6.6k
CSC307 Lecture 05
javiergs
PRO
0
490
SourceGeneratorのススメ
htkym
0
190
開発者から情シスまで - 多様なユーザー層に届けるAPI提供戦略 / Postman API Night Okinawa 2026 Winter
tasshi
0
190
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
380
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
5.9k
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
540
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
440
Featured
See All Featured
Statistics for Hackers
jakevdp
799
230k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
55
Joys of Absence: A Defence of Solitary Play
codingconduct
1
290
Believing is Seeing
oripsolob
1
50
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.8k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2k
SEO for Brand Visibility & Recognition
aleyda
0
4.2k
Navigating Weather and Climate Data
rabernat
0
97
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
220
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
170
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
180
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
110
Transcript
webpack のpitch loader について @rchaser53
webpack のpitch loader についてです cache-loader の調査中に気になったの調べました 自作、バグ修正の足がかりに役立てば幸いです
loader とは? いつものアレ(babel-loader とかcss-loader とか) module のソースコードを変換するもの 同期/ 非同期の両方に対応している loader
は任意のファイルを出力できる(file-loader とか)
loader の処理順 { test: '/.js$/', use: [ 'abc-loader', 'def-loader' ]
} 1. def-loader 2. abc-loader ではない正確にはpitch loader が先に実行される
pitch loader とは default loader の前に実行されるoptional なloader 値を返すとdefault loader まで処理が省略される
この時点ではまだソースは読み込まれていない
default loader の前に実行されるoptional なloader // webpack.config.js { test: '/.js$/', use:
[ 'abc-loader', 'def-loader' ] } 以下が正しい処理順 1. abc-loader -- pitch 2. def-loader -- pitch 3. (read the sources) 4. def-loader -- default 5. abc-loader -- default
default loader の前に実行されるoptional なloader dom のevent bubling からデザインされたもの
値を返すとdefault loader まで処理が省略される module.exports = { pitch: function() { //
値 返 default 処理 省略 // 返 値 String Buffer return 'something' // 非同期 // const callback = this.async(); // callback(null, 'something'); // return 何 返 (undefind) 次 loader 処理 移 } default: function(sources) { return sources[0] // Array 来 単純 return } }
値を返すとdefault loader まで処理が省略される 例1 abc-loader.pitch return "abc" def-loader.pitch ( 省略)
def-loader.loader ( 省略) abc-loader.loader ( 省略)
値を返すとdefault loader まで処理が省略される 例2 abc-loader pitch return def-loader pitch return
"somethingA" def-loader default ( 省略) abc-loader default return "somethingB"
値を返すとdefault loader まで処理が省略される 使用例 cache-loader 1. pitch loader でcache と依存ファイルのmtime
を比較 2. 差異がない場合はcache を読みこみreturn 3. defalult loader でそれまでの生成物と依存ファイルの path 、mtime からcache を作成
値を返すとdefault loader まで処理が省略される mtime … 最終変更時刻 (modify time) 最後にファイルを変更した時刻のこと 正確にはファイルにwrite(2)
、またはtruncate(2) した場合 に変更されるもの
この時点ではまだソースは読み込まれていない path は取得できるので取得はできる( 非推奨) loader-utils やschema-utils は使用できるのでoption など は取得できる 第3
引数経由で他のloader に値を渡すことはできる
この時点ではまだソースは読み込まれていない 正直cache-loader くらいしか第3 引数を使っている loader を見かけない cache の依存情報やfile がコンパイル中に変更されてい ないか確認するために使用している
そもそもpitch loader 自体ほとんど使われてない(script- loader, style-loader とか)
まとめ まとめ 使う機会はあるのか? webpack に対してはないかもしれない しかしフェイズを2 つに分けて、片方ではcache 管理な どを行うという設計の仕方は使えそう まぁその時楽しめれば良いよね
が作成できた! awesome-prettier-loader
参考リンク 公式ページ( かなり充実している) Documentation for pitch vs normal loader isn't
very clear UNIX/Linux の部屋 用語集: タイムスタンプ cache-loader
ご静聴ありがとうございました! ご静聴ありがとうございました!