Stability: 1 - Experimental

    In addition to the ["exports"][] field, it is possible to define internal package import maps that only apply to import specifiers from within the package itself.

    Entries in the imports field must always start with # to ensure they are disambiguated from package specifiers.

    For example, the imports field can be used to gain the benefits of conditional exports for internal modules:

    1. // package.json
    2. {
    3. "imports": {
    4. "#dep": {
    5. "node": "dep-node-native",
    6. "default": "./dep-polyfill.js"
    7. }
    8. },
    9. "dependencies": {
    10. "dep-node-native": "^1.0.0"
    11. }
    12. }

    where import '#dep' does not get the resolution of the external package dep-node-native (including its exports in turn), and instead gets the local file ./dep-polyfill.js relative to the package in other environments.

    Unlike the "exports" field, the "imports" field permits mapping to external packages.

    The resolution rules for the imports field are otherwise analogous to the exports field.