question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

allow disabling auto imports

See original GitHub issue

Describe the feature

First mentioned here by @nikolay-zoteev and @cawa-93 in https://github.com/nuxt/framework/discussions/2271.

I would like to be able to disable auto import, so I can make explicit imports from respective vendor library required in the codebase.

import { ref } from '#imports'

Would become:

import { ref } from 'vue'

Additional, from https://github.com/nuxt/framework/discussions/2271#discussioncomment-2906232:

I still need a reliable and documented way to turn off auto-import.

  • Auto-import does not work for the server part
  • Auto-import doesn’t work for everyone. You still have business logic modules, helpers, utilities, services that you have to import on your own (actually IDE will do everything for you).
  • Only top level files can be auto-imported.
  • Auto-import of asynchronous components (such as those created by defineAsyncComponent) is not possible.

In addition

  • Auto-import complicates IDE code analysis (jet brains have issues with deep import analysis)
  • It takes twice as long to go from calling a component to declaring it

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
antfucommented, Aug 8, 2022

In addition to @danielroe’s note:

Only top level files can be auto-imported.

Supported since https://github.com/nuxt/framework/pull/6025

1reaction
danielroecommented, Aug 8, 2022

This is a reasonable request, but just to address some of your comments:

Only top level files can be auto-imported.

You can configure this with autoImports.dirs

Auto-import does not work for the server part

Auto imports can be configured for nitro within nitro.autoImport

Auto-import of asynchronous components

You can use resolveComponent('SomeAsyncComponent') if they are registered or marked as global components.

Read more comments on GitHub >

github_iconTop Results From Across the Web

D78923 [LLD] [COFF] Add options for disabling auto import ...
Allow disabling either the full auto import feature, or just forbidding the cases that require runtime fixups. As long as all auto imported...
Read more >
rdar://FB9816645: Remove auto import or make a setting to be ...
I want to disable this now. Also every so often during a code review I will notice that some random resource is being...
Read more >
Auto import | IntelliJ IDEA Documentation - JetBrains
Disable auto import . If you want to completely disable auto-import, make sure that: All import tooltips are disabled.
Read more >
How to disable automatic import statements in VsCode ...
Updated for new version of VSCode 2019 for using the UI to modify the setting. So choose the File > Preference > Setting...
Read more >
Auto Import -- how to disable? - Adobe Support Community
I believe Canon software on a Mac allows you to specify what program is launched when you hook up your camera to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found