嵌套条件


🌐 Nested conditions

除了直接映射,Node.js 还支持嵌套条件对象。

🌐 In addition to direct mappings, Node.js also supports nested condition objects.

例如,要定义一个只在 Node.js 中使用而不在浏览器中使用的具有双模式入口点的包:

🌐 For example, to define a package that only has dual mode entry points for use in Node.js but not the browser:

{
 "exports": {
 "node": {
 "import": "./feature-node.mjs",
 "require": "./feature-node.cjs"
 },
 "default": "./feature.mjs"
 }
} 

条件会按顺序继续匹配,就像平铺的条件一样。如果嵌套条件没有任何映射,它将继续检查父条件的其余条件。通过这种方式,嵌套条件的行为类似于嵌套的 JavaScript if 语句。

🌐 Conditions continue to be matched in order as with flat conditions. If a nested condition does not have any mapping it will continue checking the remaining conditions of the parent condition. In this way nested conditions behave analogously to nested JavaScript if statements.

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