Skip to content

Conversation

harlan-zw
Copy link
Collaborator

πŸ”— Linked issue

#483

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ 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

Add TypeScript path mapping configuration to ensure #nuxt-scripts/* imports work correctly in Nuxt 4.

  • Add prepare:types hook to configure TypeScript paths
  • Ensure #nuxt-scripts/* resolves to runtime/* in TypeScript configuration
  • Maintains backward compatibility with Nuxt 3.16+

Add TypeScript path mapping configuration to ensure #nuxt-scripts/* imports work correctly in Nuxt 4.

- Add prepare:types hook to configure TypeScript paths
- Ensure #nuxt-scripts/* resolves to runtime/* in TypeScript configuration
- Maintains backward compatibility with Nuxt 3.16+

Resolves #483

πŸ€– Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link

vercel bot commented Sep 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
scripts-docs Ready Ready Preview Comment Sep 18, 2025 0:07am
scripts-playground Ready Ready Preview Comment Sep 18, 2025 0:07am

Copy link

pkg-pr-new bot commented Sep 18, 2025

Open in StackBlitz

npm i https://pkg.pr.new/nuxt/scripts/@nuxt/scripts@499

commit: 0758161

Comment on lines +113 to +120
nuxt.hooks.hook('prepare:types', async (options) => {
// Ensure paths are configured in TypeScript
if (options.tsConfig?.compilerOptions?.paths) {
options.tsConfig.compilerOptions.paths['#nuxt-scripts/*'] = [
await resolvePath('./runtime/*'),
]
}
})
Copy link
Member

Choose a reason for hiding this comment

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

If it's only for Nuxt 4, this cold be wrapped with isNuxtMajorVersion ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah ye this is just what Claude code spat out it may be completely off, I'd ignore all the draft prs while I go through them

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