Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Vue.js Extend with Compiler
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
1.6k
Oxlint JS plugins
kazupon
1
1.4k
gunshi
kazupon
1
250
Nitro v3
kazupon
2
600
わたしのOSS活動
kazupon
3
640
Vapor Revolution
kazupon
3
4.3k
Vue.js最新動向
kazupon
3
1.7k
Vue 3.4
kazupon
13
4.9k
Vue & Vite Rustify
kazupon
4
2.5k
Other Decks in Programming
See All in Programming
kubernetes コンポーネント開発入門 / 新卒N年目の勉強会&交流会!〜〇〇への誘い〜 #n_study
mazrean
0
240
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
280
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
110
Are APIs Still Relevant in the AI Era?
soyuka
0
210
cdk deploy JawsSonic #MARATHONしながらAWSリソースをデプロイしてみよう
akihisaikeda
2
130
自分的「カンファレンスの楽しみ方」
syumai
0
200
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
190
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
0
270
AI に Inclusive UI を書かせよう — Design Rules Skill で Compose UI を作り直す
theoriatec2024
1
490
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
240
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
140
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
390
Featured
See All Featured
Practical Orchestrator
shlominoach
191
12k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Are puppies a ranking factor?
jonoalderson
2
3.9k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.9k
Typedesign – Prime Four
hannesfritz
42
3.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
990
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.1k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
480
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
460
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
280
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!