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

fix(nuxt): interopDefault for page component imports #6468

Merged
merged 2 commits into from
Aug 9, 2022

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Aug 9, 2022

πŸ”— Linked issue

Resolves nuxt/nuxt#14445

❓ 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

Vue-router has a built-in feature to interop default export of component imports (Source code: here and here)

isESModule utility in vue-router normally works when importing in native esm (obj[Symbol.toStringTag] === 'Module') or with esm-compatible chunks (obj.__esModule). But this can be broken if there is a second transform build step (in this case was recent change in netlify builder) that converts component dynamic imports to simple { default: [getter] } without __esModule flag.

This PR, enables a more direct approach to resolve default component page exports passed to vue-router using interopDefault: true passed to knitwork.genDynamicImport that appends .then(m => m.default || m) to router component imports.

Since this change seems to fix the root-cause of regression, i'm setting default value of viteServerDynamicImports introduced in #6433 to true but keep it to opt-out until we sure issues are fixed.

PS: Thanks to @orinokai and @danielroe that help along with long journey of debugging!

πŸ“ Checklist

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

@netlify
Copy link

netlify bot commented Aug 9, 2022

βœ… Deploy Preview for nuxt3-docs canceled.

Name Link
πŸ”¨ Latest commit 350f5f0
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/62f2a5b05eb8bc00091bbdfe

@pi0 pi0 added the bug Something isn't working label Aug 9, 2022
@pi0
Copy link
Member Author

pi0 commented Aug 9, 2022

(quickly merging to verify on edge)

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

Successfully merging this pull request may close these issues.

Hydration issue with Netlify deployments
2 participants