Is there a plug-in that converts the ES6 modules of the entire project to commonjs while preserving the directory structure?

all I want is to convert the file into commonjs so that it can be easily referenced under node, instead of using webpack to package the whole project into the same file

babel has a plug-in for converting transform-es2015-modules-commonjs, but this plug-in can only read files, generate commonjs code, and cannot analyze dependencies between modules, so each file has to be transferred once

I would like to ask you, after I confirm the entry file, I can transcode all the dependencies into commonjs plug-ins?

you need to preserve the directory structure, instead of putting everything into a js package like webpack, and it"s best not to have extra code.

Mar.18,2021

babel can compile the entire directory
babel source-- out-dir es

Menu