My backend folder is an express server that will run on a Node.js environment on the Cloud.
Here is my project structure:
backend
// FOLDERS AND FILES FROM BACKEND
index.ts
frontend
some-file.js
I need to transpile my backend folder with babel, but it contain some imports from another folder. In this example: the frontend/some-file.js.
Obs: In my real case, it's a lot of files. Like util functions, common constants files, etc. I also transpile most of the frontend code in order to do SSR.
If I just do babel backend/src, it will only transpile the contents of backend/src and the some-file.js file will be missing.
Is there any way around this? I mean, how can I transpile a folder with babel and stoll include the imports that it makes from outside that folder (except node_modules for obvious reasons).
Maybe @babel/register would help? Link
I could try to use webpack, but I get the feeling that this is not what webpack was designed for. Webpack implements a module system for the browswer, while Node.js has a module system, so it shouldn't need webpack.
How do people usually handle this?