Babel preset ENV yog dab tsi?
Babel preset ENV yog dab tsi?

Video: Babel preset ENV yog dab tsi?

Video: Babel preset ENV yog dab tsi?
Video: #58 How to use Babel with WordPress theme? | using webpack in wordpress | @babel/preset-env 2024, Hlis ntuj nqeg
Anonim

@ babel ua / preset - env yog tus ntse preset uas tso cai rau koj siv qhov tseeb JavaScript yam tsis tas yuav micromanage uas syntax hloov pauv (thiab xaiv tau, browser polyfills) xav tau los ntawm koj lub hom phiaj ib puag ncig. Qhov no ua rau koj lub neej yooj yim dua thiab JavaScript pob me me! Nruab.

Yog li ntawd, dab tsi yog preset hauv Babel?

Hauv Babel , a preset yog ib txheej ntawm plugins siv los txhawb cov lus tshwj xeeb. Ob tug presets Babel siv los ntawm lub neej ntawd: es2015: Ntxiv kev txhawb nqa rau ES2015 (los yog ES6) JavaScript. react: Ntxiv kev txhawb nqa rau JSX.

Tom qab ntawd, lo lus nug yog, dab tsi Babel version kuv siv? Koj tuaj yeem tshawb xyuas qhov version ntawm babel -cli los ntawm kev nrhiav cov babel ua -cli folder hauv node_modules thiab saib cov version khoom ntawm pob. json uas yog nyob rau hauv lub hauv paus ntawm lub folder. Yog babel ua -cli tau teeb tsa thoob ntiaj teb ntawm -g chij ntawm npm nruab, koj ua tau kuaj cov version los ntawm kev ua tiav cov lus txib babel ua -- version.

Hauv qhov no, koj siv Babel preset tshuaj tiv thaiv li cas?

Yog koj xav tau siv qhov no Babel preset nyob rau hauv ib qhov project tsis tsim nrog Tsim Teb App, koj tuaj yeem nruab nws nrog cov kauj ruam hauv qab no. Ua ntej, nruab Babel . Ces nruab babel ua - preset - teb -app. Qhov no preset siv cov kev xaiv useBuiltIns nrog transform-object-so-spread thiab transform- teb -jsx, uas xav tias Object.

Puas yog Babel deprecated?

Cov tsis pom zoo kev siv ntawm babel ua -core / sau npe tau raug tshem tawm hauv Babel 7; es tsis txhob siv lub pob standalone @ babel ua / npe. @ babel ua /register tseem yuav tam sim no tsuas yog sau cov ntaub ntawv hauv qhov tam sim no ua haujlwm ncaj qha (tau ua tiav los kho cov teeb meem nrog symlinking).

Pom zoo: