Skip to content

Conversation

@lightninglu10
Copy link
Contributor

Summary

Adds comprehensive documentation to the getAliasMap method in src/webpack-plugin.ts explaining the limitations of the regex-based tsconfig.json parsing approach.

Changes

  • Added detailed JSDoc comments to getAliasMap method explaining:

    • Why regex is used: TypeScript allows JSON5 syntax (comments, trailing commas) which breaks JSON.parse()
    • Known limitations:
      1. May fail on multi-line path definitions with nested braces
      2. Doesn't follow extends field to resolve inherited path mappings
      3. May not handle all JSON5 syntax variations
      4. Only supports simple path patterns like "@/*": ["./src/*"]
    • Fallback behavior: Falls back to Next.js convention (@ -> src) if parsing fails
  • Added inline comment clarifying regex assumptions about single-line path objects

Why This Matters

The regex-based parsing is necessary but has trade-offs. This documentation helps developers:

  • Understand why certain tsconfig setups may not work as expected
  • Debug alias resolution issues more effectively
  • Make informed decisions about tsconfig structure

Test Plan

  • Documentation is clear and comprehensive
  • Covers all major limitations
  • Explains the rationale for the approach
  • No functional changes to code

🤖 Generated with Claude Code

Add comprehensive JSDoc comments to the getAliasMap method explaining:
- Why regex parsing is used instead of JSON.parse (TypeScript allows JSON5 syntax with comments and trailing commas)
- Known limitations including multi-line paths, extends support, JSON5 edge cases, and complex path patterns
- Fallback behavior when parsing fails (Next.js convention of @ -> src)

The regex-based approach is necessary to handle tsconfig.json files with comments,
but has limitations that developers should be aware of when debugging alias resolution.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

❇️ CodePress Review Summary

👋 Hey team,

Overall the changes look great! No specific issues found.

Here's the quick rundown:

✅ Decision: APPROVE
Changes are documentation-only and improve clarity without impacting runtime behavior; no blocking issues identified.

@lightninglu10
Copy link
Contributor Author

Closing in favor of a better approach - using tsconfig-paths library instead of documenting limitations

@lightninglu10 lightninglu10 deleted the fix/tsconfig-parsing-docs branch November 29, 2025 19:59
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