Tuesday, June 4, 2024
188
rated 0 times [  193] [ 5]  / answers: 1 / hits: 34749  / 9 Years ago, thu, july 23, 2015, 12:00:00

Previously:



var debug = require('debug')('http')
, http = require('http')
, name = 'My App';


With es6, how can I import and invoke right away like the first line?



import debug from 'debug'();


is a no no?


More From » ecmascript-6

 Answers
8

You'll need two lines:



import debugModule from 'debug';
const debug = debugModule('http');


The import syntax is a declarative import syntax, it does not execute any functions.


[#65696] Wednesday, July 22, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
daren

Total Points: 577
Total Questions: 114
Total Answers: 120

Location: Malaysia
Member since Fri, Dec 3, 2021
3 Years ago
daren questions
Wed, May 12, 21, 00:00, 3 Years ago
Wed, Nov 27, 19, 00:00, 5 Years ago
Thu, Oct 17, 19, 00:00, 5 Years ago
;