Stability: 1 - Experimental

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

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

    1. {
    2. "main": "./main.js",
    3. "exports": {
    4. "node": {
    5. "import": "./feature-node.mjs",
    6. "require": "./feature-node.cjs"
    7. },
    8. "default": "./feature.mjs",
    9. }
    10. }

    Conditions continue to be matched in order as with flat conditions. If a nested conditional 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.