I have nodejs app that needs to reuse model hierarchy written in ES6 with all those exports which is not supported in the server's node version (v10).
And to make it work I use webpack+bable to transpile only the model-related classes with the structure as below
index.js //app entry point, not webpacked/not transpiled
model.js//webpack entry point, transpiled with babel, hub for all models that needs to be transiled
import ObjClass1 from "some/path/ObjClass1"
exports.ObjClass1 = ObjClass1
...
Now as soon as I add require('module-alias/register')to the index.js with an alias in package.json (like @root) I'm starting to get the following error in node complaining about model.js:
SyntaxError: Cannot use import statement outside a module
If I remove require('module-alias/register') everything starts to work again.
It seems like the plugin breaks something for babel - do you have any suggestions on how to overcome that?
Thanks for reporting. I'm not very familiar with babel, I'm not even sure where to start. Could you please share a minimal project showcasing this problem + instructions, so I can investigate ?
Hi, I have the following use case.
I have nodejs app that needs to reuse model hierarchy written in ES6 with all those exports which is not supported in the server's node version (v10). And to make it work I use webpack+bable to transpile only the model-related classes with the structure as below
index.js //app entry point, not webpacked/not transpiled
model.js//webpack entry point, transpiled with babel, hub for all models that needs to be transiled
Now as soon as I add
require('module-alias/register')
to the index.js with an alias in package.json (like @root) I'm starting to get the following error in node complaining about model.js:SyntaxError: Cannot use import statement outside a module
If I remove
require('module-alias/register')
everything starts to work again.It seems like the plugin breaks something for babel - do you have any suggestions on how to overcome that?