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

docs: Add usage instructions to imports option in readme #840

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

deleteme
Copy link
Contributor

πŸ”— Linked issue

❓ 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 like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This modifies the example Bridge config in the readme to include a line of usage instructions for the imports option.

This imports option 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/bridge package or the #imports alias.

πŸ“ Checklist

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

@@ -273,6 +273,7 @@ export default defineNuxtConfig({
// transpile: false,

// Disable composables auto importing
// If opting out of auto importing, import Nuxt composables from '#app'.
Copy link
Collaborator

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

Copy link
Contributor Author

@deleteme deleteme Jun 28, 2023

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)

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nuxt.options.alias['#app'] = resolve(distDir, 'runtime/index')
is this where it is defined?

Copy link
Member

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.

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.

None yet

3 participants