Just wondering, am I able to import ES6 modules without creating a "placeholder" variable and run it immediately?
for instance, instead of ES6's import that creates an unused express
variable:
import express from 'express'
const app = express();
In CommonJS I can do it without it:
const app = require("express")();
This is particularly useful for one time only imports such as dotenv
:
require("dotenv").config();
Instead of
import dotenv from 'dotenv'
dotenv.config();
//or
import {} from 'dotenv/config'
config()
Which I think CommonJS syntax is much cleaner, but it seems ES6 imports are the future.
Thanks