Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

SyntaxError: import not found: default #62

Closed
thebrownfox opened this issue Mar 1, 2021 · 5 comments
Closed

SyntaxError: import not found: default #62

thebrownfox opened this issue Mar 1, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@thebrownfox
Copy link

Versions

nuxt-vite: 0.0.21
nuxt: 2.15.2

Reproduction

https://github.com/thefoxie/nuxt-vite-imports-issue

Description

As mentioned already (#59 (comment)), there's issue with imports.

Imported modules/exports in sfc don't work which makes the component not to render when used with components option set to true. The component renders when the import is commented out. I tried to import the component straight and had SyntaxError: import not found: default, but the component renders at least.

When components option set to true:

[Vue warn]: Failed to resolve async component: () => import('/@fs/home/foxie/Dokumenty/Code/OSS/nuxt-vite-imports-issue/components/NanoId.vue').then(c => c.default || c)
Reason: SyntaxError: import not found: default
@thebrownfox thebrownfox added the bug Something isn't working label Mar 1, 2021
@pi0 pi0 changed the title Failed to resolve async component SyntaxError: import not found: default Mar 1, 2021
@pi0
Copy link
Member

pi0 commented Mar 1, 2021

Thanks for reproduction @thefoxie! Checking error, it has nothing to do with async component imports but nanoid is incompatible. Adding this fixes issue: (

  vite: {
    optimizeDeps: {
      exclude: [
        'nanoid'
      ]
    }
  }

Will add nanoid to next version to exclude by default (added in v22)

@thebrownfox
Copy link
Author

I feel really dumb right now 😄
Haven't tried that one but it makes sense. This error should be documented as well, as it's same thing in the end.

@pi0
Copy link
Member

pi0 commented Mar 1, 2021

@thefoxie Feel free updating docs to cover both errors. BTW i'm buffering issues related to #56 to finally report to vite and fix in upstream...

@danielgroen
Copy link

danielgroen commented Mar 3, 2021

i've tried to add optimizeDeps for the package nuxt-leaflet but still got the error

vite: {
  optimizeDeps: {
    exclude: [
      'nuxt-leaflet',
    ]
  }
}

@pi0
Copy link
Member

pi0 commented Mar 3, 2021

@danielgroen Can you please help creating a small reproduction so i can debug? (update: #87)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants