在应用中一直对es6 和 commonjs 中的模块管理没有明确的界限和区别一直是混这用,感觉有点乱,下面对两个标准的模块管理进行对比和学习
ES6 模块管理
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| export function a(){} export default {b:'v'}
import lib,{a} from 'lib' import * as lib fron 'lib'
export * from 'src/other_module'; import 'lib' export { foo, bar } from 'src/other_module'; export { foo as myFoo, bar } from 'src/other_module';
System.import('some_module') .then(some_module => { }) .catch(error => { ... });
|
commonjs 模块管理
1 2 3 4 5 6
|
module.exports ={} exports.a = function(){}
var lib = require('lib')
|