What is the difference between qualified and unskilled imports in the new javascript ES6 lingo module?

I came across this difference that was not well explained in ExploringJS

Skilled and unskilled imports work the same way (they are both indirect)

What is the difference and therefore what does this statement mean?

+5
source share
1 answer

Strictly speaking, there is no such thing as qualified / unskilled import in JavaScrpit. These terms were used in the study of ES6 by Dr. Axel Rauschmeier in the context of cyclic dependencies and roughly mean:

Unskilled import (directly import part of the module):

Commonjs

var foo = require('a').foo // doesn't work with cyclic dependencies 

ES2015

 import {foo} from 'a' // can work with cyclic dependencies* 

Qualified import (import of the entire module as a namespace):

Commonjs

 var a = require('a') function bar() { a.foo() // can work with cyclic dependencies* } exports.bar = bar 

ES2015

 import * as a from 'a' export function bar() { a.foo() // can work with cyclic dependencies* } 

In ES2015, default imports can also be qualified imports (although some people disagree) if they serve as a namespace:

 export default { fn1, fn2 } 

* with cyclic dependencies, you cannot access the import in the module body:

 import {foo} from 'a' // 'a' is a cyclic dependency foo() // doesn't work 
+1
source

Source: https://habr.com/ru/post/1241270/


All Articles