解析用户条件


\Resolving user conditions

新增于: v14.9.0, v12.19.0

运行 Node.js 时,可以使用 --conditions 标志添加自定义用户条件:

\When running Node.js, custom user conditions can be added with the --conditions flag:

node --conditions=development index.js 

然后将解析包导入和导出中的 "development" 条件,同时根据需要解析现有的 "node""node-addons""default""import""require" 条件。

\which would then resolve the "development" condition in package imports and exports, while resolving the existing "node", "node-addons", "default", "import", and "require" conditions as appropriate.

可以使用重复标志设置任意数量的自定义条件。

\Any number of custom conditions can be set with repeat flags.

典型条件应仅包含字母数字字符,如有必要,使用 ":"、"*" 或 "=" 作为分隔符。任何其他操作都可能在节点之外遇到兼容性问题。

\Typical conditions should only contain alphanumerical characters, using ":", "-", or "=" as separators if necessary. Anything else may run into compability issues outside of node.

在节点中,条件几乎没有限制,但具体包括:

\In node, conditions have very few restrictions, but specifically these include:

  1. 它们必须至少包含一个字符。

    \They must contain at least one character.

  2. 它们不能以 "." 开头,因为它们可能出现在也允许相对路径的地方。

    \They cannot start with "." since they may appear in places that also allow relative paths.

  3. 它们不能包含 ",",因为它们可能会被某些 CLI 工具解析为逗号分隔的列表。

    \They cannot contain "," since they may be parsed as a comma-separated list by some CLI tools.

  4. 它们不能是像 "10" 这样的整数属性键,因为这会对 JS 对象的属性键排序产生意外影响。

    \They cannot be integer property keys like "10" since that can have unexpected effects on property key ordering for JS objects.

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