What's the one line equivalent of below statement using ES6 Import
app.use('/c', require('./route/routesc')); // routes which are common
app.use('/d', require('./route/routesd')); // routes for Data Agent
app.use('/a', require('./route/routesa')); // routes for Admin
import routesc from "./route/routesc.js"
import routesd from "./route/routesd.js"
import routesa from "./route/routesa.js"
app.use('/c', routesc); // routes which are common
app.use('/d', routesd); // routes for Data Agent
app.use('/a', routesa); // routes for Admin
I am wondering is there any ONE liner for import
?
FYI, I spent 40 mins searching for this answer and finally posted here on SO.
The ONE-liner equivalent would be
import routesc from "./route/routesc.js"; app.use('/c', routesc); // routes which are common
import routesd from "./route/routesd.js"; app.use('/d', routesd); // routes for Data Agent
import routesa from "./route/routesa.js"; app.use('/a', routesa); // routes for Admin
There is no way to combine them into a single statement, an import
declaration always needs to stand on its own.