I would like to do this
var debug = require('debug')('myapp');
... in ES6 without creating an extra variable. Can it be done?
I would like to do this
var debug = require('debug')('myapp');
... in ES6 without creating an extra variable. Can it be done?
import Debug from 'debug';
const debug = Debug('myapp');
(as lemieuxster said... addressing the fact that it is still listed under unanswered questions)
Note as mentioned in the comments, this will work for modules exported with the es6 syntax, that is whenever export default expression
was used, which would give way to a require of the form var debug = require('./debug').default('myapp');
. If the module you are importing used an export syntax of the type export const Debug = expression
or export {Debug}
or module.exports = {Debug : expression}
then you will have to use import {Debug} from 'debug';