$30 off During Our Annual Pro Sale. View Details »

Node.js v13の気になる変更点 / #kng8

Node.js v13の気になる変更点 / #kng8

関西Node学園 8時限目でNode.js v13の変更点について話しました。
https://nodejs.connpass.com/event/147459/

# Topic
- V8 7.8
- full-icu is default (full support i18n)
- http_parser (legacy HTTP Parser) is removed
- remove http, http2 default server timeout
- ES Modules without flag

Masashi Hirano

October 25, 2019
Tweet

More Decks by Masashi Hirano

Other Decks in Programming

Transcript

  1. Node.js v13
    Notable Changes
    ؔ੢NodeֶԂ 8࣌ݶ໨
    Masashi Hirano(@shisama)

    View Slide

  2. ฏ໺ ণ࢜ / Masashi Hirano
    @shisama_
    shisama
    Node.js Core Collaborator
    ؔ੢NodeֶԂOrganizer

    View Slide

  3. https://twitter.com/nodejs/status/1186695960753266689

    View Slide

  4. https://github.com/nodejs/Release
    2019/10/21 2020/10 2022/4
    2019/10/22 2020/6

    View Slide

  5. Node.js v13ͷಛʹؾʹͳͬͨ
    มߋ఺Λ঺հ͠·͢ʂ

    View Slide

  6. https://nodejs.org/en/blog/release/v12.0.0/

    View Slide

  7. V8

    View Slide

  8. https://github.com/nodejs/node/pull/29694

    View Slide

  9. V8 7.8
    • Objectͷ෼ׂ୅ೖ (`const {id, name} = user;`)ͳͲͷύϑΥʔϚϯεվ

    • ϝϞϦ࢖༻ྔͷ࡟ݮ
    • WebAssembly (WASM) ͷC/C++ͷAPIΛެࣜαϙʔτɺWASMͷى
    ಈ࣌ؒվળ
    • …etc

    View Slide

  10. https://v8.dev/blog/v8-release-78
    More details… => v8.dev

    View Slide

  11. Internationalization

    View Slide

  12. https://github.com/nodejs/node/pull/29522

    View Slide

  13. Internationalization
    • i18nΛϑϧαϙʔτ

    ɾv12·Ͱ͸Intlܥͷؔ਺ͷҰ෦΍NumberͷtoLocaleString()ͳͲ͸ӳޠͷΈ࢖͑ͨ
    • ͜Ε·Ͱ͸͢΂ͯͷݴޠαϙʔτΛ͠ͳ͍Α͏ʹNode.jsΛϏϧυ͍ͯͨ͠

    ɾNode.jsͷόΠφϦͷαΠζ͕૿͑ΔͨΊආ͚ΒΕ͍ͯͨ

    ɾϑϧαϙʔτ͢ΔϏϧυʹΑΓ~40%αΠζ͕૿͑Δ

    ɾe.g. macOSͩͱ35MB͔Β49MBʹͳΔ
    • v12·Ͱ΋ —with-intl=full-icu ϑϥάΛ෇͚ͯNode.jsΛϏϧυ͢Δ͜ͱͰϑϧαϙʔτͰ͖
    ͍ͯͨ

    View Slide

  14. https://nodejs.org/api/intl.html

    View Slide

  15. Intl.DateTimeFormatͷεϖΠϯޠͰͷྫ
    const january = new Date(9e8);
    const spanish = new Intl.DateTimeFormat('es', { month: 'long' });
    console.log(spanish.format(january));
    // 'M01' v12
    // 'enero` v13
    WҎલ TNBMMJDV
    Ͱ͸`.`ɺ
    WҎ߱ GVMMJDV
    Ͱ͸`FOFSP`

    View Slide

  16. http

    View Slide

  17. https://github.com/nodejs/node/pull/29522

    View Slide

  18. http parser
    • ॳظ͔Β͋ͬͨHTTPύʔαʔͷhttp_parserϞδϡʔϧΛ࡟আ
    • v12͔Βllhttp͕σϑΥϧτ͕ͩɺ—http-parser=legacy Φϓ
    γϣϯΛ෇͚Δ͜ͱͰhttp_parser͕࢖͑ͯͨ
    • v13͔Β—http-parser Φϓγϣϯ΋࡟আ͞Εͨ

    View Slide

  19. https://llhttp.org

    View Slide

  20. llhttp
    • http_parserͷอक͕ࠔ೉ͩͬͨͷͰҰ͔Βॻ͖௚͞Εͨ
    • llhttp͸TypeScriptͰॻ͔Ε͍ͯͯϝϯς͠΍͘͢ͳ͍ͬͯΔ
    • http_parserΑΓ࣮ߦ଎౓͕଎͍
    • llparseͰTS͔ΒCݴޠ΍LLVMϏοτίʔυʹม׵͍ͯ͠Δ

    View Slide

  21. llhttp
    https://github.com/nodejs/llhttp

    View Slide

  22. More details… => JSConf EU 2019
    https://2019.jsconf.eu/fedor-indutny/llhttp-new-http-11-parser-for-nodejs.html

    View Slide

  23. http, http2

    View Slide

  24. https://github.com/nodejs/node/pull/27558

    View Slide

  25. αʔόʔλΠϜΞ΢τͷ࣌ؒ
    • ͜Ε·Ͱ͸σϑΥϧτ2෼ͰλΠϜΞ΢τ͍ͯͨ͠
    • αʔόʔͰ2෼Λ௒͑ΔॲཧΛ͢Δͱιέοτ͕ด͡ΒΕۭͷϨεϙϯε
    ͕ฦ͖ͬͯͨ
    • v13͔Β͸αʔόʔλΠϜΞ΢τ͕ແޮʹͳͬͨ
    • ͜Ε·Ͱ௨Γserver.setTimeoutͳͲͰλΠϜΞ΢τ·Ͱͷ࣌ؒΛઃఆ͢
    Δ͜ͱ͸Մೳ

    View Slide

  26. ES Modules

    View Slide

  27. https://github.com/nodejs/node/pull/29866

    View Slide

  28. ES Modules
    • ·ͩϦϦʔεʹؚ·Ε͍ͯͳ͍͕ɺv13ͰೖΓͦ͏
    • ES Modules(import / export)͕ϑϥάͳ͠Ͱ࢖͑ΔΑ͏ʹ

    ɾ—experimental-module ͕ඞཁͩͬͨ
    • v12ʹ΋ϚΠφʔόʔδϣϯͷߋ৽ͰόοΫϙʔτ͢Δ͔΋

    ɾ12݄͕3݄ࠒʹ͸v12Ͱ΋ϑϥάͳ͠Ͱ࢖͑Δ͔΋

    View Slide

  29. https://github.com/nodejs/module/issue/400

    View Slide

  30. https://shisama.hatenablog.com/entry/2019/10/23/190842
    ͦͷଞͷมߋ఺

    View Slide

  31. ·ͱΊ
    • V8ͷߋ৽ͰύϑΥʔϚϯεվળͳͲ͕͞Εͨ
    • i18n͕ϑϧαϙʔτ͞Εͨ
    • http͸ݹ͍ύʔαʔΛ࡟আ͠ɺσϑΥϧτͰλΠϜΞ΢τແޮʹ
    • ES Modules͕ϑϥάͳ͠Ͱ࢖͑Δ༧ఆ

    View Slide

  32. એ఻
    11/30(Sat), 12/1(Sun)
    11/2(Sat)

    View Slide

  33. Thanks.
    @shisama_
    shisama

    View Slide