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: warn about modules with side-effects #19592

Merged
merged 4 commits into from Mar 11, 2023

Conversation

huang-julien
Copy link
Member

πŸ”— Linked issue

resolve #19506

❓ 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

Hi πŸ‘‹
Some users reported that some of their pages fails to render due to window being undefined. The reason is this was caused by importing modules containing side-effects. Even if the user expect the code to work because it calls the import in a onMounted, the component crash at render because the import is not treeshaken in server-side.
This pr warns about importing modules with side-effects.
Maybe can it be improved by adding an example to the error handling ? Or as mentionned by @manniL , listing a small list of modules containing side-effects (leaflet) ?

πŸ“ Checklist

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

@codesandbox
Copy link

codesandbox bot commented Mar 10, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@danielroe danielroe changed the title docs(rendering): warn about modules with side-effects docs: warn about modules with side-effects Mar 11, 2023
@danielroe danielroe merged commit 4163bb8 into nuxt:main Mar 11, 2023
@danielroe danielroe mentioned this pull request Mar 11, 2023
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.

Imports are not treeshaken when only called within onMounted
2 participants