子路径文件夹映射


稳定性: 0 - 弃用: 改为使用子路径模式。

在支持子路径模式之前,尾随 "/" 后缀用于支持文件夹映射:

{
  "exports": {
    "./features/": "./features/"
  }
}

此特性将在未来版本中删除。

而是,使用直接的子路径模式

{
  "exports": {
    "./features/*": "./features/*.js"
  }
}

模式相对于文件夹导出的好处在于,消费者始终可以导入包,而无需子路径文件扩展名。

Stability: 0 - Deprecated: Use subpath patterns instead.

Before subpath patterns were supported, a trailing "/" suffix was used to support folder mappings:

{
  "exports": {
    "./features/": "./features/"
  }
}

This feature will be removed in a future release.

Instead, use direct subpath patterns:

{
  "exports": {
    "./features/*": "./features/*.js"
  }
}

The benefit of patterns over folder exports is that packages can always be imported by consumers without subpath file extensions being necessary.