ESM / CommonJs
TODO
ESM
Commonjs
自动采用严格模式,忽略 'use strict'
每个 ESM 模块都是单独的私有作用域
ESM 是通过 CORS 去请求外部 JS 模块的
ESM 的 script 标签会延迟执行脚本
在 Node 中使用 ESM
注意点
ES Module 中可以导入 CommonJS 模块
CommonJS 中不能导入 ES Module 模块
CommonJS 始终只会导出一个默认成员
注意 import 不是解构导出对象
Last updated
Was this helpful?