Skip to content

default-last

Check that "default" is the last key in every condition map

PropertyValue
Rule IDexports/default-last
Categoryexports
Severity🔴 error
Fixable🔧 Auto-fixable (safe)

What it Checks

Node.js processes export conditions top-to-bottom. "default" is a catch-all — if it appears before specific conditions like "import" or "require", those conditions are unreachable.

Examples

❌ Incorrect

json
{ "exports": { ".": { "default": "./dist/index.js", "import": "./dist/index.mjs" } } }

✅ Correct

json
{ "exports": { ".": { "import": "./dist/index.mjs", "default": "./dist/index.js" } } }

Configuration

Disable this rule:

bash
tspub check --ignore-rules "exports/default-last"

Or in tspub.config.ts:

typescript
export default {
  check: {
    severityOverrides: {
      "exports/default-last": "off",  // or "warning", "error", "info"
    },
  },
};

Released under the MIT License.