Skip to content

import-condition

Check that exports has an import condition

PropertyValue
Rule IDexports/import-condition
Categoryexports
Severity🔴 error
Fixable⚠️ Auto-fixable (unsafe)

What it Checks

Without an "import" condition, ESM consumers can't use your package with import statements.

Examples

❌ Incorrect

json
{ "exports": { ".": { "types": "./dist/index.d.ts", "require": "./dist/index.cjs" } } }

✅ Correct

json
{ "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } } }

Configuration

Disable this rule:

bash
tspub check --ignore-rules "exports/import-condition"

Or in tspub.config.ts:

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

Released under the MIT License.