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
Vue.js Extend with Compiler
Search
kazupon
September 15, 2017
Programming
4.2k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Vue.js Extend with Compiler
kazupon
September 15, 2017
More Decks by kazupon
See All by kazupon
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
1k
Oxlint JS plugins
kazupon
1
1.4k
gunshi
kazupon
1
240
Nitro v3
kazupon
2
560
わたしのOSS活動
kazupon
3
630
Vapor Revolution
kazupon
3
4.2k
Vue.js最新動向
kazupon
3
1.6k
Vue 3.4
kazupon
13
4.9k
Vue & Vite Rustify
kazupon
4
2.5k
Other Decks in Programming
See All in Programming
20260623_Loop Engineeringで自分の分身の問い合わせBotを作る
ryugen04
0
210
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
520
act2-costs.pdf
sumedhbala
0
110
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
140
Vite+ Unified Toolchain for the Web
naokihaba
0
740
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
8
4.1k
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
2.4k
【やさしく解説 設計編・中級 #1】一つの車に、運転手は一人 ~ある倉庫システムの事例から~
panda728
PRO
0
170
【やさしく解説 設計編 #0】DDDのコード、読めるのに分からない人へ
panda728
PRO
2
260
Claude Opus 4.6以後の受託開発エンジニアの変化(Claude Code開発ノウハウ大公開スペシャルbyクラスメソッド)
iidatakuma
1
630
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
2.4k
AI駆動開発を妨げる技術的負債の解消アプローチ / ai-refactoring-approach
minodriven
17
9k
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
174
15k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.1k
Paper Plane
katiecoart
PRO
2
52k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
630
WENDY [Excerpt]
tessaabrams
11
38k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Everyday Curiosity
cassininazir
0
250
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
760
Transcript
Vue.js Extend with Compiler ToKyotoJS 2017-09-15 @kazupon
Who are you ?
kazupon Vue.js Core Team Vue.js japan users group organizer vue-i18n,
vue docs maintainer storybook vue support member CUUSOO SYSTEM CTO @kazu_pon kazupon
[PR]
2017-10-04
Vue.js v-meetup #5 https://vuejs-meetup.connpass.com/event/65442/
Nuxt.js at Genba Specials! 1.0 coming soon !? Nuxt.js!! Nuxt.js!!
We are hiring!! Let’s building Open Innovation Platform!! http://www.cuusoo.co.jp
Introduction
Vue 2.x Rendering Engine Virtual DOM
• Declarative • Template Flexible Rendering Intuitive, Designer friendly !!
• Imperative • render function + hyperscript Flexible Rendering Programmatic,
Powerful !!
• (Declarative + Imperative ) / 2 ? • JSX
Flexible Rendering
However, Sometimes, we would like to …
• e.g. Pre-Translation of i18n Extend with compiler! I’d like
to Improve Performance !!
Today: Speaking
How to extend with compiler
Overall flow
Overall flow Compilation Phase Rendering Phase
Hookable Compilation Phase AST Optimized AST About detail of Compilation
Phase, See the bellow https://speakerdeck.com/kazupon/vue-dot-js-2-dot-0-server-side-rendering#23 Tokyo Node Festival 2016 : “Vue.js 2.0 αʔόαΠυϨϯμϦϯά” ({JS}) ({JS}) ({JS}) compile optimize generate Hooks Hooks Optimize Keys HTML Parser Optimizer Code Generator
How to compile with yourself
• Vue.compile • vue-template-compiler Provide API or package
• Full build only, Core built-in https://unpkg.com/vue • Generate render,
staticRenderFns function Vue.compile
• Full build only, Core built-in https://unpkg.com/vue • Generate render,
staticRenderFns function Vue.compile Damn…
• Vue Compiler Package https://www.npmjs.com/package/vue-template-compiler • No Vue Runtime, Vue
Compiler only! • Need to install NPM vue-template-compiler npm install -D vue-template-compiler
• Provide some APIs • compiler.compile(template, [options]) • compiler.compileToFunctions(template) •
compiler.ssrCompile(template, [options]) • compiler.ssrCompileToFunction(template) • compiler.parseComponent(file, [options]) vue-template-compiler
• Provide some APIs • compiler.compile(template, [options]) • compiler.compileToFunctions(template) •
compiler.ssrCompile(template, [options]) • compiler.ssrCompileToFunction(template) • compiler.parseComponent(file, [options]) vue-template-compiler Bravo!
Compiler options
• modules • directives • preserveWhitespace We can specify the
following options
• An array of compiler module • compiler module type:
`ModuleOptions` `modules` option
Hooking of compiler module AST Optimized AST compile optimize generate
HTML Parser Optimizer Code Generator compiler module preTransformNode transformNode postTransformNode staticKeys genData transformCode
• An object where have pairs key-value • key: directive
name • value: transform an AST node function `directives` option
Hooking of directive AST Optimized AST compile optimize generate HTML
Parser Optimizer directive1 directiveX directives Code Generator directive2 Call directive hooks before genData hooks
Compilation Examples
• Vue core (for web) https://github.com/vuejs/vue/tree/dev/src/platforms/web/compiler/modules • Weex (for native)
https://github.com/vuejs/vue/tree/dev/src/platforms/weex/compiler/modules • vue-loader (assets <img>,<image> in-line) https://github.com/vuejs/vue-loader/tree/master/lib/template-compiler/ modules • vue-18n-extensions (pre-translation) https://github.com/kazupon/vue-i18n-extensions compiler module
• Vue core (for web) https://github.com/vuejs/vue/tree/dev/src/platforms/web/compiler/directives • Weex (for native)
https://github.com/vuejs/vue/tree/dev/src/platforms/weex/compiler/directives directive
Tips
• Vue official bundler libs(Internal used with it) • vue-loader
: compilerModules • rollup-plugin-vue: compilerOptions Alternative: vue-template-compiler https://vuejs.github.io/rollup-plugin-vue/#/en/2.3/?id=template
Conclusion
Compilation hooks is very powerful! • Vue compiler provide compilation
hooks • It's powerful to extend the library/plugins by Vue compiler
Please well consider • However, In about Apps, don’t abuse
• Your apps breaks down easily in order to depenpent vue compiler • If you’d like to use it, Please well consider
One more thing …
Maybe, Vue compiler evolve?
Thanks!