पाठ 26 / 30
Transpilation Issues को Debugging करना
Transformation problems को diagnose करने के लिए tools और techniques।
Common issues: जब transpilation breaks
Transpilation के बाद runtime errors आमतौर पर mean करते हैं: (1) missing polyfill, (2) unsupported syntax, (3) wrong target config, (4) plugin conflict।
Browser dev tools को source maps के साथ use करें
Build config में source maps को enable करें transpiled code को debug करने के लिए। Errors generated code को नहीं, original source को point करते हैं, debugging को easier बनाता है।
Transpiled output को inspect करना
Problems को spot करने के लिए एक single file पर Babel/SWC को चलाएँ और output को देखें।
# Babel
npx babel src/problem.js
# SWC
npx swc src/problem.js
# Save to file for detailed inspection
npx babel src/problem.js -o debug-output.jsErrors को source में trace करने के लिए source maps का उपयोग करें
Babel/SWC config में source maps को enable करें। Browser या runtime में errors original source को point करते हैं, transpiled code को नहीं।