As Node V6 already supports ~95% of ES6, why are people using Babel on the server side? What are the pros and cons of using Babel on the server side?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- Keeping track of variable instances
There is one main reason:
import
/export
See:
There is even a special Babel preset for Node:
that doesn't transpile anything that Node already supports natively.
You can also use
babel-preset-env
which is "A Babel preset that can automatically determine the Babel plugins and polyfills you need based on your supported environments" - thanks to loganfsmyth for pinting it out in the comments. See:And Node doesn't support ES6 modules - see this answer for details on why: