You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
App context type-checking server files causes it to fail when importing from #imports #33979
Similar to #33627, running typecheck fails when users import server-only code from #imports in server files because the app context, where the server-only code isn't available, ends up checking the files too.
For utils from h3, for example, it is fine to import them directly from the package. However, utils from modules, which are added via addServerImports or addServerImportsDir, this can be a serious issue.
This is often the only way to import such functions, like it is the case in nuxt-auth-utils, for example.
We should probably add something like an #imports/server alias, as Daniel suggested.
#28682 - feat(schema,nuxt): add shared folder to alias and auto-imports [merged] #32594 - fix(nuxt): include shared types in tsconfig.server.json [merged] #33308 - fix(vite): duplicate server style imports [merged] #33870 - feat(schema): add #server alias for server directory imports [merged] #33927 - fix(webpack,rspack): resolve deep imports in virtual files [merged]
changed the title [-]App context type-checking server endpoints causes it to fail when importing from `#imports`[/-][+]App context type-checking server files causes it to fail when importing from `#imports`[/+]on Dec 28, 2025
Is this still open? There's no open PR here, so I'd like to pick it up. I did #35697.
I've read the code and would go with your #imports/server: point it at the nitro-imports.d.ts Nitro already writes instead of generating a second copy, and register it on the Nitro side only, so importing it from a component still fails rather than bundling server code into the client. @danielroe suggested #imports/nuxt + #imports/nitro in nuxt/cli#1143 though, so let me know if you'd rather have the pair.
One thing I found while reproducing: .nuxt/tsconfig.json rebuilds its exclude from scratch and drops the server dir Nitro adds to tsconfig.app.json, so the legacy single config type-checks server files directly. Should I fix it in this PR too, or keep it separate?
After #35938 the server imports run regardless of experimental.nitroAutoImports, so this hits default v5 apps too.
I went with #imports/server. Importing it from a component still fails the build rather than bundling server code into the client. I can modify it into #imports/nuxt + #imports/nitro pair if needed.
Activity
bolt-new-by-stackblitz commentedon Dec 28, 2025
coderabbitai commentedon Dec 28, 2025
📝 CodeRabbit Plan Mode
Generate an implementation plan and prompts that you can use with your favorite coding agent.
Examples
🔗 Similar Issues
Possible Duplicates
typeCheck: true,vue-tscchecks/serverdir with the wrongtsconfigfile #31989🔗 Related PRs
#28682 - feat(schema,nuxt): add
sharedfolder to alias and auto-imports [merged]#32594 - fix(nuxt): include shared types in tsconfig.server.json [merged]
#33308 - fix(vite): duplicate server style imports [merged]
#33870 - feat(schema): add
#serveralias for server directory imports [merged]#33927 - fix(webpack,rspack): resolve deep imports in virtual files [merged]
👤 Suggested Assignees
🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
cernymatej commentedon Dec 28, 2025
as @amandesai01 pointed out, this is a problem not only for server endpoints but also for other files in the server part
[-]App context type-checking server endpoints causes it to fail when importing from `#imports`[/-][+]App context type-checking server files causes it to fail when importing from `#imports`[/+]chairulakmal commentedon Aug 4, 2026
Hi @cernymatej
Is this still open? There's no open PR here, so I'd like to pick it up. I did #35697.
I've read the code and would go with your
#imports/server: point it at thenitro-imports.d.tsNitro already writes instead of generating a second copy, and register it on the Nitro side only, so importing it from a component still fails rather than bundling server code into the client. @danielroe suggested#imports/nuxt+#imports/nitroin nuxt/cli#1143 though, so let me know if you'd rather have the pair.One thing I found while reproducing:
.nuxt/tsconfig.jsonrebuilds itsexcludefrom scratch and drops the server dir Nitro adds totsconfig.app.json, so the legacy single config type-checks server files directly. Should I fix it in this PR too, or keep it separate?After #35938 the server imports run regardless of
experimental.nitroAutoImports, so this hits default v5 apps too.I'll open a PR once you confirm the naming.
chairulakmal commentedon Aug 11, 2026
Opened #36039
I went with
#imports/server. Importing it from a component still fails the build rather than bundling server code into the client. I can modify it into#imports/nuxt+#imports/nitropair if needed.danielroe commentedon Sep 6, 2026
this has been resolved in #36265 and will be present in nuxt v5; server files will import from
#imports/serverinstead