3
rated 0 times
[
5]
[
2]
/ answers: 1 / hits: 24453
/ 7 Years ago, tue, august 15, 2017, 12:00:00
Is there any difference between:
import utils from 'utils'
and
import * as utils from 'utils'
?
In case A:
//utils.js
export function doSomething()
{
//...
}
In case B:
//utils.js
export function doSomething()
{
//...
}
export default function doSomethingDefault()
{
//...
}
UPDATE:
I was mislead by intellisense feature of vscode, but as recommended a small test on node+babel showed the difference:
//index.js
import utilsCaseA from './utils1'
import * as utilsCaseAWildcard from './utils1'
var utilsCaseARequire = require('./utils1')
import utilsCaseB from './utils2'
import * as utilsCaseBWildcard from './utils2'
var utilsCaseBRequire = require('./utils2')
var compareObjects =
{
utilsCaseA, utilsCaseAWildcard, utilsCaseARequire,utilsCaseB,utilsCaseBWildcard,utilsCaseBRequire
};
console.log(compareObjects);
More From » ecmascript-6