1. 语法

1.1 ES Module

导出:export / export default
导入: import * from 'module'

1.2 Commonjs

导出:module.exports
导入:const module = require('module')

 

2. 特性

2.1 ES Module

静态引入、编译时引入(支持Tree shaking)

1 // lib.mjs
2 export let a = 1
3 export const b = 2
4 export function aPlus1 () {
5    return a++  
6 }
lib.mjs

相关文章: