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
docs: Add usage instructions to imports option in readme #840
base: main
Are you sure you want to change the base?
docs: Add usage instructions to imports option in readme #840
Conversation
| @@ -273,6 +273,7 @@ export default defineNuxtConfig({ | |||
| // transpile: false, | |||
|
|
|||
| // Disable composables auto importing | |||
| // If opting out of auto importing, import Nuxt composables from '#app'. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can use #imports as well as Nuxt 3, so I would prefer to match it.
https://nuxt.com/docs/guide/concepts/auto-imports#explicit-imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was unable to use the #imports alias, it throws an error:
ERROR Failed to compile with 1 errors friendly-errors 09:23:14
This dependency was not found: friendly-errors 09:23:14
friendly-errors 09:23:14
* #imports in ./node_modules/unplugin/dist/webpack/loaders/transform.js?unpluginName=nuxt-legacy-vue-transform!./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./node_mo
dules/unplugin/dist/webpack/loaders/transform.js?unpluginName=nuxt-legacy-capi-key-transform!./pages/useroute.vue?vue&type=script&lang=js&
friendly-errors 09:23:14
To install it, you can run: npm install --save #imports friendly-errors 09:23:14
If it helps I've disabled the Nitro server with nitro: false.
Edit: Enabling Nitro doesn't fix that problem either. Same error, different call stack:
[nuxt] [request error] [unhandled] [500] Cannot find module '#imports' 9:26:33 AM
at webpackMissingModule (./.nuxt/dist/server/pages/useroute.js:36:45)
at ./node_modules/unplugin/dist/webpack/loaders/transform.js?unpluginName=nuxt-legacy-vue-transform!./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./node_modules/unplugin/dist
/webpack/loaders/transform.js?unpluginName=nuxt-legacy-capi-key-transform!./pages/useroute.vue?vue&type=script&lang=js& (./.nuxt/dist/server/pages/useroute.js:36:128)
at __webpack_require__ (./.nuxt/dist/server/server.js:27:30)
at ./pages/useroute.vue?vue&type=script&lang=js& (./.nuxt/dist/server/pages/useroute.js:108:394)
at __webpack_require__ (./.nuxt/dist/server/server.js:27:30)
at ./pages/useroute.vue (./.nuxt/dist/server/pages/useroute.js:74:96)
at __webpack_require__ (./.nuxt/dist/server/server.js:27:30)
at async ./.nuxt/dist/server/server.js:2269:21
at async Promise.all (index 0)
at async getRouteData (./.nuxt/dist/server/server.js:2296:3)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems it might be a webpack issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bridge/packages/bridge/src/app.ts
Line 13 in ccb7c86
| nuxt.options.alias['#app'] = resolve(distDir, 'runtime/index') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should advise disabling auto-imports by setting imports.autoImports to false rather than fully disabling imports.
This modifies the example Bridge config in the readme to include a line of usage instructions for the
importsoption.This
importsoption might be used by people who want to preserve explicit import statements when upgrading to Nuxt Bridge.Providing a convenient example of where the Nuxt composables would be imported from (
#app), this might help avoid incorrectly assuming that they're available from the@nuxt/bridgepackage or the#importsalias.