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

fix(nuxt): fix lazy import of named components #25286

Merged
merged 5 commits into from Jan 19, 2024

Conversation

becem-gharbi
Copy link
Contributor

@becem-gharbi becem-gharbi commented Jan 18, 2024

πŸ”— Linked issue

resolves #23768

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 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)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

When lazy loading components the dynamic import always return the exported default. So named exported components cannot be lazy loaded.

imports.add(`const ${identifier} = __defineAsyncComponent(${genDynamicImport(component.filePath, { interopDefault: true })}${isClientOnly ? '.then(c => createClientOnly(c))' : ''})`)

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.

Copy link

stackblitz bot commented Jan 18, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@danielroe
Copy link
Member

Any chance you could add a regression test to the basic/ test suite? (Just an example usage that previously would have failed.)

@github-actions github-actions bot added the 3.x label Jan 18, 2024
@becem-gharbi
Copy link
Contributor Author

I have added test named lazy import components that checks if components are lazy loaded correctly considering import type (named) and rendering mode (client/server/all)

@danielroe danielroe merged commit 10af369 into nuxt:main Jan 19, 2024
34 checks passed
@github-actions github-actions bot mentioned this pull request Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Module-added component throws 'src.replace is not a function' if prefixed with Lazy and is not a vue file
2 participants