Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Change your source with AST

Change your source with AST

For Roppongi.js#4

893f54413c2bd9ba41d11d753aacaf2c?s=128

Yosuke Kurami

June 26, 2018
Tweet

Transcript

  1. "45Λ࢖ͬͨ ιʔείʔυฤूͷ࿩ 3PQQPOHJKT CZ!2VSBNZ

  2. গ͠લʹCFUUFSOBNFͱ͍ ͏$-*πʔϧΛͭ͘Γ·ͨ͠ https://github.com/Quramy/better-name

  3. ͳͥ࡞ͬͨͷ͔

  4. ͳͥ࡞ͬͨͷ͔ w ಛʹ࢓ࣄͰ Ұ౓ॻ͍ͨKTϑΝΠϧͷ৔ॴΛɺޙ͔Βม͑ ͨ͘ͳΔ͜ͱ͕݁ߏ͋Δ w FYQPSU͢ΔGVODUJPODMBTT໊͸ࡶʹਖ਼نදݱͰ΋͍͍͚Ͳɺ JNQPSUͷ૬ରύεΛ௚͢ͷ͸ׂͱμϧ͍ w *%&ʹΑΒͣɺڞ௨ͷಈ࡞͕อূ͞Εͯ΄͍͠


    WJNNFSͳͷͰɺྡͷಉ྅͕εΠεΠ8FC4UPSNͱ͔࢖ͬ ͯΔͷݟΔͱෲཱͭ
  5. Ͱ͖ͨ΋ͷ w NWίϚϯυͱେମҰॹɻGSPN'JMFͷύε͕UP'JMF΁ҠΔ ͚ͩ better-name [options] <fromFile> <toFile> w JNQPSUจͷ੔߹ੑΛҠಈલޙͰ୲อͯ͘͠ΕΔ

  6. ͜Μͳ͔Μ͡

  7. JNQPSUͱ"45 w -5λΠτϧʹ΋͋Δ௨Γɺ͜ͷπʔϧ͸+BWB4DSJQUͷ "45 ந৅ߏจ໦ Λղੳ͍ͯ͠Δ w JNQPSUFYQPSU͸จ๏ͷ੍໿͕ݫ͍͠
 ཪΛฦ͢ͱΊͬͪΌղੳ͠΍͍͢

  8. ͙͢࡞Εͦ͏ w ࣮૷ϓϥϯ KTKTYͷέʔε  w CBCZMPOͰιʔείʔυΛ"45΁QBSTF w !CBCFMUSBWFSTFͰ"45 ͷJNQPSUจ

    Λม׵ w !CBCFMHFOFSBUFͰ"45͔ΒιʔείʔυΛੜ੒
  9. ͪͳ54ͷ৔߹ w ࣮૷ϓϥϯ UTUTYͷέʔε  w UTDSFBUF4PVSDF'JMFͰιʔείʔυΛ"45΁QBSTF w UTUSBOTGPSN $VTUPN5SBOTGPSNFSͰ"45

    ͷ JNQPSUจ Λม׵ w UTDSFBUF1SJOUFSͰ"45͔ΒιʔείʔυΛੜ੒
  10. Ұ௨Γ࣮૷ͯ͠ؾͮ͘

  11. ͋ΕɺJNQPSUจ͔͠ม׵ͯ͠ͳ͍ͷʹɺ
 ࣮ߦલޙͰEJ⒎ग़ա͗͡ΌͶʜ 

  12. ͓·ΘΓ͞ΜίΠπͰ͢ w ࣮૷ϓϥϯ KTKTYͷέʔε  w CBCZMPOͰιʔείʔυΛ"45΁QBSTF w !CBCFMUSBWFSTFͰ"45 ͷJNQPSUจ

    Λม׵ w !CBCFMHFOFSBUFͰ"45͔ΒιʔείʔυΛੜ੒
  13. ΍ͬͪ·ͬͨ w ͦ΋ͦ΋ "45ιʔείʔυ͸Մٯม׵͡Όͳ͍
 FHηϛίϩϯ Πϯσϯτ ετϦϯάϦςϥϧ FUD  w

    QSFUUJFS͔͚Ε͹͍͍΍ɺͱࢥ͍ͬͯͨ  w ۭߦ͕࡟আ͞Εͯ͠·͏݅͸Ͳ͏͠Α͏΋ͳ͍
  14. ΍Γ௚͠

  15. "45ͷमਖ਼Λιʔε΁൓ө͞ ͤΔʹ͸ w !CBCFMHFOFSBUF࢖Θͳ͍ ࢖͏ʹͯ͠΋ہॴతʹ  w "45Λղੳͨ͠ޙɺมߋ͍ͨ͠಺༰ͱର৅OPEFͷMPDBUJPO ͔Β5FYU$IBOHFΛ࡞Γɺιʔείʔυͷจࣈྻʹద༻͞ ͤΔͷ͕ਖ਼ղ

    ʮ"45͔Βੜ੒ʯͰ͸ͳ͘ʮ"45ͷมߋΛద༻ʯʹ͢Δ
  16. 5FYU$IBOHF w ԫ৭ͷ෦෼͸Ұ੾มߋ͕ͳ͍ ιʔείʔυͦͷ··  w มߋ͕ෳ਺ͷ৔߹͸ɺιʔείʔυͷޙΖ͔Βద༻͢Δ import { someFn

    } from "./target"; export default function main() { someFn(); } import { someFn } from “./new-target”; export default function main() { someFn(); } textChanges = [{ start: 24, end: 32, text: 'new-target' }]  
  17. ·ͱΊ w !CBCFMHFOFSBUPS΍UT1SJOUFSΛιʔείʔυमਖ਼ͷ໨ తͰ࢖Θͳ͍ɻཚ༻͠ͳ͍ w 5FYU$IBOHFͷύλʔϯΛ͓֮͑ͯ͘ͱɺͲ͔͜Ͱ໾ʹཱ ͔ͭ΋ʜ

  18. 5IBOLZPV