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

JavaScriptのimport/export

 JavaScriptのimport/export

JavaScriptのimport/exportについて、CommonJS ModulesとES Modulesの違いとWebPack, Parcelの紹介

52ecfbc87e5145ed5cd8cd81de9cffa8?s=128

Kazunori-Kimura

March 06, 2018
Tweet

Transcript

  1. JavaScriptͷ
 import/export 2018-03-17 ໦ଜ ݑن

  2. ΞδΣϯμ JavaScriptͷimport/export ES Modulesͷ࣮૷ঢ়گ webpack4͕ϦϦʔε Parcelͷ঺հ 

  3. ΞδΣϯμ JavaScriptͷimport/export ES Modulesͷ࣮૷ঢ়گ webpack4͕ϦϦʔε Parcelͷ঺հ 

  4. ෳ਺ͷJavaScriptΛಡΈࠐΉ <html>
 <body>
 :
 <script src="assets/jquery.min.js"></script>
 <script src="assets/bootstrap.min.js"></script>
 <script src="app.js"></script>


    </body>
 </html> 
  5. ෳ਺ͷJavaScriptΛಡΈࠐΉ <html>
 <body>
 :
 <script src="assets/jquery.min.js"></script>
 <script src="assets/bootstrap.min.js"></script>
 <script src="app.js"></script>


    </body>
 </html>  ଞݴޠͷJNQPSU΍JODMVEFʹ ֘౰͢Δػೳ͕ͳ͔ͬͨ
  6. JavaScriptͷimport/export  $PNNPO+4.PEVMFT &4.PEVMFT FYQPSUଆ YYYKT NPEVMFFYQPSUTYYY FYQPSUEFGBVMUYYY JNQPSUଆ JOEFYKT

    DPOTUYYYSFRVJSF YYY  JNQPSUYYYGSPNYYY
  7. JavaScriptͷimport/export  $PNNPO+4.PEVMFT &4.PEVMFT FYQPSUଆ YYYKT NPEVMFFYQPSUTYYY FYQPSUEFGBVMUYYY JNQPSUଆ JOEFYKT

    DPOTUYYYSFRVJSF YYY  JNQPSUYYYGSPNYYY /PEFKT αʔόʔαΠυ+4  ͷ࢓༷
  8. JavaScriptͷimport/export  $PNNPO+4.PEVMFT &4.PEVMFT FYQPSUଆ YYYKT NPEVMFFYQPSUTYYY FYQPSUEFGBVMUYYY JNQPSUଆ JOEFYKT

    DPOTUYYYSFRVJSF YYY  JNQPSUYYYGSPNYYY &$."4DSJQUͷ࢓༷
  9. JavaScriptͷimport/export  $PNNPO+4.PEVMFT &4.PEVMFT FYQPSUଆ YYYKT NPEVMFFYQPSUTYYY FYQPSUEFGBVMUYYY JNQPSUଆ JOEFYKT

    DPOTUYYYSFRVJSF YYY  JNQPSUYYYGSPNYYY
  10. ΞδΣϯμ JavaScriptͷimport/export ES Modulesͷ࣮૷ঢ়گ webpack4͕ϦϦʔε Parcelͷ঺հ 

  11. ϒϥ΢βͷରԠঢ়گ  JNQPSU+BWB4DSJQUc.%/ IUUQTEFWFMPQFSNP[JMMBPSHKBEPDT8FC+BWB4DSJQU3FGFSFODF 4UBUFNFOUTJNQPSU

  12. Node.jsͰES Modules ֦ுࢠΛ͢΂ͯ .mjs ͱ͢Δ --experimental-modulesϑϥάΛࢦఆ  ࢖͑Δ...͕ɺWarning͕දࣔ͞ΕΔ

  13. ΞδΣϯμ JavaScriptͷimport/export ES Modulesͷ࣮૷ঢ়گ webpack4͕ϦϦʔε Parcelͷ঺հ 

  14. όϯυϧπʔϧ ෳ਺ͷJavaScriptϑΝΠϧΛ
 ͻͱͭʹ݁߹ 

  15. όϯυϧπʔϧ  πʔϧ ಛ௃ ରԠ CSPXTFSJGZ γϯϓϧ $PNNPO+4.PEVMFT XFCQBDL ଟػೳ

    $PNNPO+4.PEVMFT &4.PEVMFT $44 *NBHFT
  16. όϯυϧπʔϧ  πʔϧ ಛ௃ ରԠ CSPXTFSJGZ γϯϓϧ $PNNPO+4.PEVMFT XFCQBDL ଟػೳ

    $PNNPO+4.PEVMFT &4.PEVMFT $44 *NBHFT
  17.  WebPack4͕ 2018-2-25 ʹϦϦʔε

  18. webpack webpack4͔ΒઃఆϑΝΠϧͳ͠Ͱಈ࡞ CLIͰ࢖͏ʹ͸ webpack ͱ webpack-cli Λ࢖༻ 

  19. ΞδΣϯμ JavaScriptͷimport/export ES Modulesͷ࣮૷ঢ়گ webpack4͕ϦϦʔε Parcelͷ঺հ 

  20.  ઃఆϑΝΠϧෆཁ js,cssͳͲͷґଘؔ܎Λ ௐࠪ͠τϥϯεύΠϧɾ όϯυϧΛߦ͏ > parcel index.html

  21. ΞδΣϯμ JavaScriptͷimport/export ES Modulesͷ࣮૷ঢ়گ webpack4͕ϦϦʔε Parcelͷ঺հ