Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extend generated tsconfig paths from aliases #2964

Open
wants to merge 5 commits into
base: v2
Choose a base branch
from

Conversation

gioboa
Copy link
Contributor

@gioboa gioboa commented Jan 3, 2025

πŸ”— Linked issue

Fixes: #2476

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

To manage aliases inside the configuration and create the correct tsconfig file I merged the alias object with the typescript one ( that already works )
To prevent errors we need to check the complex typescript object 😭
I added typeof checks to prevent errors with wrong configs like eg. alias: 0 or paths: true

export default defineNitroConfig({
  alias: {  πŸ‘ˆ the PR manage this config
    foo: fileURLToPath(new URL("../bar", import.meta.url)),   
  },
  typescript: {
    strict: true,
    tsConfig: {
      files: [],
      compilerOptions: {
        allowJs: true,
        paths: {
          baz: [ fileURLToPath(new URL("../bar", import.meta.url)) ]
        }
      }
    }
  },
});

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@gioboa gioboa requested a review from pi0 as a code owner January 3, 2025 02:02
src/core/config/loader.ts Outdated Show resolved Hide resolved
@gioboa gioboa requested a review from pi0 January 3, 2025 11:20
@pi0 pi0 changed the title fix: set ts config paths from aliases config fix: extend aliases from options.typescript.tsConfig.compilerOptions.paths Jan 4, 2025
@pi0 pi0 changed the title fix: extend aliases from options.typescript.tsConfig.compilerOptions.paths feat: extend generated tsconfig paths from aliases Jan 4, 2025
@gioboa
Copy link
Contributor Author

gioboa commented Jan 6, 2025

Do I need to do the same change to v3?

@pi0
Copy link
Member

pi0 commented Jan 6, 2025

It will be ported to v3 branch. i need to test it little bit to merge for next minor (after patch)

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.

Set ts config paths from aliases config
2 participants