Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
/frameworkPublic archive

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

Merged
pi0 merged 2 commits into
mainfrom
fix/router-import-interop
Aug 9, 2022
Merged

fix(nuxt): interopDefault for page component imports#6468
pi0 merged 2 commits into
mainfrom
fix/router-import-interop

Conversation

@pi0

@pi0pi0 commented Aug 9, 2022

Copy link
Copy Markdown
Member

🔗 Linked issue

Resolvesnuxt/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

netlifyBot commented Aug 9, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

NameLink
🔨 Latest commit350f5f0
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/62f2a5b05eb8bc00091bbdfe

@pi0pi0 added the bug Something isn't working label Aug 9, 2022
@pi0

pi0 commented Aug 9, 2022

Copy link
Copy Markdown
MemberAuthor

(quickly merging to verify on edge)

@pi0
pi0 merged commit 3e27c1c into mainAug 9, 2022
@pi0
pi0 deleted the fix/router-import-interop branch August 9, 2022 18:25
@pi0pi0 mentioned this pull request Aug 11, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xbugSomething isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hydration issue with Netlify deployments

2 participants

@pi0@danielroe