पाठ 14 / 30

Node.js Versions को Target करना

Backend Node.js environments के लिए transpilation को कॉन्फ़िगर करें।

Node 16+ अधिकांश ES2021 विशेषताओं को support करता है

आधुनिक Node.js versions (16+, 18+, 20+) async/await, const, arrow functions, destructuring, और अधिक को natively support करते हैं। आपको अक्सर transpilation की कोई जरूरत नहीं है।

Node target configuration

Minimum Node version निर्दिष्ट करने के लिए targets.node को सेट करें। Babel फिर केवल incompatible विशेषताओं को transpile करता है।

// Target Node 18+: minimal transpilation
{
  "presets": [
    ["@babel/preset-env", { "targets": { "node": "18" } }]
  ]
}

// Target Node 12: more transpilation
{
  "presets": [
    ["@babel/preset-env", { "targets": { "node": "12" } }]
  ]
}

आधुनिक Node backends को rarely Babel की जरूरत है

यदि आपका backend Node 18+ चलाता है, तो Babel को पूरी तरह skip करने पर विचार करें और type checking के लिए केवल TypeScript का उपयोग करें। तेजी से builds, simpler setup।