导出的语法糖


如果 "." 导出是唯一的导出,则 "exports" 字段为这种情况提供了语法糖,即直接的 "exports" 字段值。

如果 "." 导出有回退数组或字符串值,则可以直接将 "exports" 字段设置为此值。

{
  "exports": {
    ".": "./main.js"
  }
}

可以写成:

{
  "exports": "./main.js"
}

If the "." export is the only export, the "exports" field provides sugar for this case being the direct "exports" field value.

If the "." export has a fallback array or string value, then the "exports" field can be set to this value directly.

{
  "exports": {
    ".": "./main.js"
  }
}

can be written:

{
  "exports": "./main.js"
}