Esport and Import analysis in modularization

export exposed interface

    import {} from “module name/path”

1. Define the module and expose the interface through export

//module1.js

export let a
= 3;
export
function sayHello(){

}
//index.js
import {a,sayHello} from
'./module1'

2. Define the module and expose the interface through export default

//module1.js

let a = 3;
function sayHello(){

}
export
default {
a,
sayHello
}
//index.js
import module1 from ‘./module1‘
module1.sayHello

3. How does nodejs support es6 modules Transformation
1) es6->es5

4. Case:

//module1.js

let name= "module1";
// separate exposure
export function sayName(){
console.log(
"my name is",this.name) ;
}
export
function sayHello(){
console.log(
"hello world");
}

//index.js
import {sayName} from'./module1'

5. Cases

< div class="code">

//module1.js

let name= "module1";
function sayAge(){},
function sayGender(){}
// Default collective exposure
export default {
sayAge,
sayGender
}
//index.js
import m from ‘./module1‘
m.sayAge()

//module1.js

export let a
= 3;
export
function sayHello(){

}
//index.js
import {a,sayHello} from
'./module1'

//module1.js

let a = 3;
function sayHello(){

}
export
default {
a,
sayHello
}
//index.js
import module1 from ‘./module1‘
module1.sayHello

//module1.js

let name= "module1";
// separate exposure
export function sayName(){
console.log(
"my name is",this.name) ;
}
export
function sayHello(){
console.log(
"hello world");
}

//index.js
import {sayName} from'./module1'

//module1.js

let name= "module1";
function sayAge(){},
function sayGender(){}
// Default collective exposure
export default {
sayAge,
sayGender
}
//index.js
import m from ‘./module1‘
m.sayAge()

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4002 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.