Please tell me how to configure babel so that only import? can be converted.

because it is customary to use import to import and export modules before writing frontend. After all, there is babel . Writing nodejs also continues this habit. Anyway, it all needs to be converted to es5

.
  "scripts": {
    "start": "nodemon src/app.js --exec babel-node --presets es2015,stage-2",
    "build": "babel src -d dist --presets es2015,stage-2",
    "serve": "node dist/app.js",

but I learned today that converting to es5 on the node side actually sacrifices a lot of efficiency. Because nodejs is up-to-date and all grammars are natively supported, except import , how can babel be configured to convert only import to require ?

Apr.14,2021

use babel-preset-env, and then target: node should be fine.

  https://babeljs.io/docs/en/en.

Menu