Skip to content

feat(attw): add profile-based filtering and configurable error levels#313

Merged
sxzz merged 8 commits intorolldown:mainfrom
christian-bromann:cb/attw-fix
Jun 12, 2025
Merged

feat(attw): add profile-based filtering and configurable error levels#313
sxzz merged 8 commits intorolldown:mainfrom
christian-bromann:cb/attw-fix

Conversation

@christian-bromann
Copy link
Contributor

Description

This PR enhances the ATTW (Are The Types Wrong) integration by adding profile-based filtering and configurable error levels, making the type checking more flexible and practical for different project requirements.

Key improvements:

  • ATTW Profiles: Added three predefined profiles (strict, node16, esmOnly) that filter out specific resolution mode failures based on the target environment:

    • strict: Requires all resolutions (default behavior)
    • node16: Ignores node10 resolution failures
    • esmOnly: Ignores CJS resolution failures (node10 and node16-cjs)
  • Configurable Error Levels: Added level option to control build behavior:

    • error: Fails the build when type issues are found
    • warn: Only warns about type issues (default behavior)
  • Improved Problem Reporting: Enhanced the output format to show structured problem details including problem kind, resolution mode, and entry point

  • Better TypeScript Integration: Added proper AttwOptions interface extending the core CheckPackageOptions with the new profile and level configurations

  • Fixed Working Directory: Set the correct working directory for npm pack command to respect project context

This enhancement addresses the common issue where ATTW reports false positives for specific environments (e.g., ESM-only packages getting CJS resolution failures) and provides better control over when type issues should fail the build vs. just warn.

Linked Issues

Additional context

Focus areas for reviewers:

  • Profile Logic: Please review the profile filtering logic in the profiles constant and the problem filtering implementation to ensure it correctly excludes the intended resolution modes
  • Type Safety: The new AttwOptions interface extends the core library types - please verify the type definitions are accurate and complete
  • Error Handling: The new error level functionality changes behavior when level: 'error' is set - please review that this works as expected and doesn't break existing workflows
  • Backward Compatibility: All new options have sensible defaults, so existing configurations should continue working unchanged

The changes maintain full backward compatibility while providing new opt-in functionality for more granular control over ATTW checking behavior.

- Add ATTW profiles (strict, node16, esmOnly) with corresponding resolution mode filters
- Add configurable level option (error/warn) to control build behavior
- Improve problem reporting with structured output format
- Add proper TypeScript types for AttwOptions with profile and level configuration
- Set working directory for npm pack command to respect project context
- Filter problems based on selected profile to reduce noise

This enhancement allows for more flexible ATTW checking by ignoring specific
resolution failures based on the target environment and controlling whether
type issues should fail the build or just warn.
@netlify
Copy link

netlify bot commented Jun 10, 2025

Deploy Preview for tsdown failed.

Name Link
🔨 Latest commit ed2c63b
🔍 Latest deploy log https://app.netlify.com/projects/tsdown/deploys/684af4b2ba21ca0008500c3a

Copy link
Member

@sxzz sxzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert the changes of the API reference. I will handle this on the main branch, as the SHA of the PR will no longer exist in the main branch once it is merged.

christian-bromann and others added 2 commits June 11, 2025 09:42
Co-authored-by: Kevin Deng <sxzz@sxzz.moe>
This reverts commit 16871b3.
@christian-bromann
Copy link
Contributor Author

@sxzz thanks for reviewing, I've reverted all changes to the docs folder. Let me know if there is anything missing.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jun 11, 2025

Open in StackBlitz

npm i https://pkg.pr.new/tsdown@313

commit: ed2c63b

@christian-bromann
Copy link
Contributor Author

@sxzz fixed

@sxzz sxzz merged commit b2453d0 into rolldown:main Jun 12, 2025
11 of 15 checks passed
@christian-bromann christian-bromann deleted the cb/attw-fix branch June 12, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants