import 语句


import statements】

import 语句可以引用 ES 模块或 CommonJS 模块。 import 语句只允许在 ES 模块中使用,但在 CommonJS 中支持动态 import() 表达式以加载 ES 模块。

【An import statement can reference an ES module or a CommonJS module. import statements are permitted only in ES modules, but dynamic import() expressions are supported in CommonJS for loading ES modules.】

在导入 CommonJS 模块 时,module.exports 对象会作为默认导出提供。命名导出可能也可用,通过静态分析提供,以便更好地与生态系统兼容。

【When importing CommonJS modules, the module.exports object is provided as the default export. Named exports may be available, provided by static analysis as a convenience for better ecosystem compatibility.】