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

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. None
  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
  3. ▰ Telegram channel, daily ▰ Voice chat, weekly ▰ Workshops,

    coming soon
  4. Today Agenda 1. What is special about Node.js? 2. Node.js

    v16 features 3. Node.js ecosystem state 4. What to learn?
  5. What is special about Node.js?

  6. None
  7. None
  8. Google pays for V8

  9. None
  10. Node.js v16: ECMAScript

  11. 8.4 ➜ 9.4

  12. 1. String.prototype.replaceAll 2. Object.hasOwn 3. ArrayLike.at 4. class static initialization

    blocks 5. Error cause 6. ...
  13. None
  14. None
  15. None
  16. Error cause:

  17. Node.js v16: Timers Promises API

  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();
  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; }
  20. Node.js v16: AbortController

  21. None
  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();
  23. Node.js v16: core modules

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

    http from 'node:http';
  25. Node.js v16: Source Maps

  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.<anonymous> (/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' }
  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"
  28. Node.js v16: npm

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

  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
  31. Node.js v16: other

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

    tracing
  34. None
  35. Running x86 vs arm64 node resulted in a ~40% improvement.

    Node.js v16 has darwin-x64 (Intel) and darwin-arm64 (Apple Silicon) builds
  36. Node.js 16 supports setting process.env.TZ on windows. Farewell set-tz package

    process.env.TZ = 'UTC'
  37. Node.js ecosystem

  38. None
  39. - TypeScript - GitHub - npm - Azure Most Affecting

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

  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
  42. What to learn?

  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
  44. Required by Business • Soft Skills (English!) • Reporting and

    analytics (Mixpanel) • Headless CMS • NoCode: use, integrate or migrate • Personalization: Internet Of Behavior
  45. QUESTIONS TIME! Slides at the channel ➡