"exports"


版本历史
版本变更
v14.13.0, v12.20.0

添加对 "exports" 模式的支持。

v13.7.0, v12.17.0

取消标记条件导出。

v13.7.0, v12.16.0

实现逻辑条件导出排序。

v13.7.0, v12.16.0

删除 --experimental-conditional-exports 选项。在 12.16.0 中,条件导出仍然落后于 --experimental-modules

v13.2.0, v12.16.0

实现条件导出。

v12.7.0

新增于: v12.7.0

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

"exports" 字段允许在通过 node_modules 查找或 self-reference 加载到其自己的名称的名称导入时定义包的 入口点。它在 Node.js 12+ 中被支持作为 "main" 的替代品,它可以支持定义 子路径导出条件导出,同时封装内部未导出的模块。

\The "exports" field allows defining the entry points of a package when imported by name loaded either via a node_modules lookup or a self-reference to its own name. It is supported in Node.js 12+ as an alternative to the "main" that can support defining subpath exports and conditional exports while encapsulating internal unexported modules.

条件导出 也可以在 "exports" 中使用,为每个环境定义不同的包入口点,包括包是通过 require 还是通过 import 引用。

\Conditional Exports can also be used within "exports" to define different package entry points per environment, including whether the package is referenced via require or via import.

"exports" 中定义的所有路径必须是以 ./ 开头的相对文件 URL。

\All paths defined in the "exports" must be relative file URLs starting with ./.

AltStyle によって変換されたページ (->オリジナル) /