Skip to content

Package Validation (publint & attw)

tsdown integrates with publint and Are the types wrong? (attw) to validate your package before publishing. These tools check for common issues in your package.json configuration and type definitions.

Installation

Both tools are optional dependencies — you only need to install them if you want to use them:

bash
npm install -D publint
bash
npm install -D @arethetypeswrong/core
bash
npm install -D publint @arethetypeswrong/core

publint

publint checks that your package is correctly configured for publishing. It validates package.json fields like exports, main, module, and types against your actual output files.

Enable publint

tsdown.config.ts
ts
import { defineConfig } from 'tsdown'

export default defineConfig({
  publint: true,
})

Configuration

Pass options directly to customize publint's behavior:

tsdown.config.ts
ts
import { defineConfig } from 'tsdown'

export default defineConfig({
  publint: {
    level: 'error', // 'warning' | 'error' | 'suggestion'
  },
})

CLI

bash
tsdown --publint

attw (Are the types wrong?)

attw verifies that your TypeScript declaration files are correct across different module resolution strategies (node10, node16, bundler). It catches issues like false ESM/CJS type declarations that can cause runtime errors for consumers.

Enable attw

tsdown.config.ts
ts
import { defineConfig } from 'tsdown'

export default defineConfig({
  attw: true,
})

Configuration

tsdown.config.ts
ts
import { defineConfig } from 'tsdown'

export default defineConfig({
  attw: {
    // Resolution profile:
    //   'strict'   - requires all resolutions (default)
    //   'node16'   - ignores node10 resolution failures
    //   'esm-only' - ignores CJS resolution failures
    profile: 'node16',

    // Level: 'warn' (default) or 'error' (fails the build)
    level: 'error',

    // Ignore specific problem types
    ignoreRules: ['false-cjs', 'cjs-resolves-to-esm'],
  },
})

Profiles

ProfileDescription
strictRequires all resolutions to pass (default)
node16Ignores node10 resolution failures
esm-onlyIgnores node10 and node16-cjs resolution failures

Ignore Rules

You can suppress specific problem types using ignoreRules:

RuleDescription
no-resolutionModule could not be resolved
untyped-resolutionResolution succeeded but has no types
false-cjsTypes indicate CJS but implementation is ESM
false-esmTypes indicate ESM but implementation is CJS
cjs-resolves-to-esmCJS resolution points to an ESM module
fallback-conditionA fallback/wildcard condition was used
cjs-only-exports-defaultCJS module only exports a default
named-exportsNamed exports mismatch between types and implementation
false-export-defaultTypes declare a default export that doesn't exist
missing-export-equalsTypes are missing export = for CJS
unexpected-module-syntaxFile uses unexpected module syntax
internal-resolution-errorInternal resolution error in type checking

CLI

bash
tsdown --attw

CI Integration

Both publint and attw support CI-aware options. This is useful for running package validation only in CI:

tsdown.config.ts
ts
import { defineConfig } from 'tsdown'

export default defineConfig({
  publint: 'ci-only',
  attw: {
    enabled: 'ci-only',
    profile: 'node16',
    level: 'error',
  },
})

NOTE

Both tools require a package.json in your project directory. If no package.json is found, a warning is logged and the check is skipped.

Released under the MIT License.