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

Auto-import of nitro utils stopped working in 3.14 #399

Closed
ronenteva opened this issue Dec 2, 2024 · 3 comments · Fixed by #400
Closed

Auto-import of nitro utils stopped working in 3.14 #399

ronenteva opened this issue Dec 2, 2024 · 3 comments · Fixed by #400
Labels
bug Something isn't working

Comments

@ronenteva
Copy link

Environment

- Operating System: Linux
- Node Version:     v20.18.0
- Nuxt Version:     3.14.1592
- CLI Version:      3.16.0
- Nitro Version:    2.10.4
- Package Manager:  [email protected]

Reproduction

/server/utils/sum.ts

export function useSum(a: number, b: number) { return a + b }

/server/api/result:

export default defineEventHandler(() => {
  const sum = useSum(1, 2)
  return { sum }
})

ERROR useSum is not defined

Describe the bug

Everything works fine when pinning [email protected]

Additional context

No response

Logs

No response

@ronenteva ronenteva added the bug Something isn't working label Dec 2, 2024
@vacnex
Copy link

vacnex commented Dec 2, 2024

It has been reported Issue

@danielroe
Copy link
Member

this seems like it might be a regression from #395.

@noootwo
Copy link
Contributor

noootwo commented Dec 3, 2024

The nitro passes the glob server/utils/*:
https://github.com/nitrojs/nitro/blob/575144f0efa9e8115251abb8d0bd09165ecd55f2/src/core/config/resolvers/imports.ts#L30
In versions < 3.14.x, unimport would scan the raw dirs glob and the glob like {dir glob}/*.{ts,js,...}, which worked for nitro.
After #395, unimport lost the ability to scan the raw dirs glob, as it only scanned with the glob xxx/server/utils/*/*.{ts,js}, which could not match anything, so the case of nitro was not handled.

It will be fixed in issue #400.

@antfu antfu closed this as completed in #400 Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants