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

Node.js Development in 2022

Node.js Development in 2022

Nikita Galkin

November 27, 2021
Tweet

More Decks by Nikita Galkin

Other Decks in Programming

Transcript

  1. View Slide

  2. Nikita
    Galkin
    Love and Know:
    ▰ How to make developers and business happy
    ▰ Technical and process debt elimination
    Believe that:
    ▰ Any problem must be solved at the right level
    ▰ Software is easy. People are hard
    ▰ A problem should be highlighted, an idea should
    be "sold", a solution should be demonstrated
    Links:
    Site GitHub Twitter Facebook
    2

    View Slide

  3. ▰ Telegram channel, daily
    ▰ Voice chat, weekly
    ▰ Workshops, coming soon

    View Slide

  4. Today Agenda
    1. What is special about Node.js?
    2. Node.js v16 features
    3. Node.js ecosystem state
    4. What to learn?

    View Slide

  5. What is
    special about
    Node.js?

    View Slide

  6. View Slide

  7. View Slide

  8. Google pays for V8

    View Slide

  9. View Slide

  10. Node.js v16:
    ECMAScript

    View Slide

  11. 8.4 ➜ 9.4

    View Slide

  12. 1. String.prototype.replaceAll
    2. Object.hasOwn
    3. ArrayLike.at
    4. class static initialization blocks
    5. Error cause
    6. ...

    View Slide

  13. View Slide

  14. View Slide

  15. View Slide

  16. Error cause:

    View Slide

  17. Node.js v16:
    Timers
    Promises API

    View Slide

  18. // Before
    function wait(timeout) {
    return new Promise((r) =>
    setTimeout(r, timeout));
    }
    // Node.js v16
    import {setTimeout as wait } from "timers/promises";
    async function example() {
    await wait(5000);
    console.log('After 500ms');
    }
    example();

    View Slide

  19. import {
    setInterval,
    } from 'timers/promises';
    const interval = 100;
    for await (const startTime of
    setInterval(interval, Date.now())) {
    const now = Date.now();
    console.log(now);
    if ((now - startTime) > 1000) break;
    }

    View Slide

  20. Node.js v16:
    AbortController

    View Slide

  21. View Slide

  22. const http = require('http');
    const ac = new AbortController();
    const signal = ac.signal;
    http.request('https://example.org',
    { signal }, (res) => {
    /** … **/
    });
    // Cancel the request!
    ac.abort();

    View Slide

  23. Node.js v16:
    core modules

    View Slide

  24. // Before
    import http from 'http';
    // Node.js v16
    import http from 'node:http';

    View Slide

  25. Node.js v16:
    Source Maps

    View Slide

  26. node:net:1420
    throw new ERR_SERVER_ALREADY_LISTEN();
    ^
    Error [ERR_SERVER_ALREADY_LISTEN]: Listen method has been called more than once without
    closing.
    at new NodeError (node:internal/errors:371:5)
    at Server.listen (node:net:1420:11)
    at Object. (/Users/example.js:10:8)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
    code: 'ERR_SERVER_ALREADY_LISTEN'
    }

    View Slide

  27. // Before
    npm install source-map-support
    // Node.js v16
    node server.js --enable-source-maps
    // or use env var
    NODE_OPTIONS="--enable-source-maps"

    View Slide

  28. Node.js v16:
    npm

    View Slide

  29. Corepack: the Node.js' manager of
    package managers

    View Slide

  30. 1. npm install as fast as yarn
    2. package-lock.json v2 format
    3. npm exec
    4. workspaces
    5. overrides (resolutions from yarn)
    are in development

    View Slide

  31. Node.js v16:
    other

    View Slide

  32. View Slide

  33. AsyncLocalStorage and
    AsyncResource API are
    stable now. Perfect use
    case: tracing

    View Slide

  34. View Slide

  35. Running x86 vs arm64
    node resulted in a ~40%
    improvement.
    Node.js v16 has darwin-x64
    (Intel) and darwin-arm64
    (Apple Silicon) builds

    View Slide

  36. Node.js 16 supports
    setting process.env.TZ
    on windows.
    Farewell set-tz package
    process.env.TZ = 'UTC'

    View Slide

  37. Node.js
    ecosystem

    View Slide

  38. View Slide

  39. - TypeScript
    - GitHub
    - npm
    - Azure
    Most Affecting Company

    View Slide

  40. Top Contributor
    - Fastify
    - pino
    - Node
    - undici

    View Slide

  41. Open Source Startups Funding
    ● Gatsby – round B, May 2020, 28m
    ● Strapi – round A, may 2020, 10m
    ● Cube Dev – round A, Jul 2021, 15.5m
    ● Bubble – round A, Jul 2021, 100m
    ● Apollo – round D, Aug 2021, 130m
    ● Vercel – round D, Nov 2021, 150m

    View Slide

  42. What to
    learn?

    View Slide

  43. Required by industry
    ● EcmaScript & TypeScript
    ● DevOps: CI/CD, IoS, 12factor
    ● Cloud Native: one of AWS, GCP,
    Azure and Kubernetes
    ● Web API: OpenAPI, GraphQL,
    AsyncAPI, etc

    View Slide

  44. Required by Business
    ● Soft Skills (English!)
    ● Reporting and analytics (Mixpanel)
    ● Headless CMS
    ● NoCode: use, integrate or migrate
    ● Personalization: Internet Of Behavior

    View Slide

  45. QUESTIONS TIME!
    Slides
    at the channel ➡

    View Slide