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

fix(nuxt): ensure component helper methods do not create side-effects - #6789

Merged
pi0 merged 1 commit into
mainfrom
fix/component-side-effects
Aug 22, 2022
Merged

fix(nuxt): ensure component helper methods do not create side-effects#6789
pi0 merged 1 commit into
mainfrom
fix/component-side-effects

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

resolvesnuxt/nuxt#14650

❓ 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

Lazy components (defined with defineAsyncComponent) were marked as having a side effect, so were persisting into the routes bundle. We should certainly not be including async component statements within the entry bundle, which also had the effect of marking them as dependencies of the entry rather than the page they correspond to (resulting in over-prefetching - see nuxt/nuxt#14584).


Note that I encountered this when debugging what I believe to be an upstream rollup bug that I'm still looking into, which is difficult to reproduce but essentially boils down to two modules which each contain:

defineAsyncComponent(()=>__vitePreload(()=>import('./Text.3d3cd0e1.js'),true?"__VITE_PRELOAD__":void0,import.meta.url));constmeta=undefined;

being transformed into:

defineAsyncComponent(()=>__vitePreload(()=>import('./Text.3d3cd0e1.js'),true?"__VITE_PRELOAD__":void0,import.meta$1.url));constmeta$1=undefined;defineAsyncComponent(()=>__vitePreload(()=>import('./Text.3d3cd0e1.js'),true?"__VITE_PRELOAD__":void0,import.meta.url));constmeta=undefined;

(This seems like an over-zealous search + replace on the part of rollup.)

📝 Checklist

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

@danielroedanielroe added bug Something isn't working 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage labels Aug 19, 2022
@danielroe
danielroe requested a review from pi0August 19, 2022 22:16
@danielroedanielroe self-assigned this Aug 19, 2022
@netlify

netlifyBot commented Aug 19, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

NameLink
🔨 Latest commit0ac4ae6
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/63000ba7525707000946529a

pi0
pi0 approved these changes Aug 22, 2022

@pi0pi0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!!

@pi0
pi0 merged commit 80abca9 into mainAug 22, 2022
@pi0
pi0 deleted the fix/component-side-effects branch August 22, 2022 08:50
@pi0pi0 mentioned this pull request Aug 26, 2022
@alex-korniienko

alex-korniienko commented Sep 5, 2022

Copy link
Copy Markdown

@danielroe Hey, I am not sure if this is something on my side or after the new changes.
But after upgrading to a new rc.9 I am having this error, on the rc.8 all is working.

Expected "meta" but found "meta$k"
13877|
13878| defineAsyncComponent(() =>
13879| __vitePreload(() => import('./Test.0f9d27a0.js'),true?"__VITE_PRELOAD__":void 0,import.meta$k.url)
13881| const meta$k = {
``

@danielroe

Copy link
Copy Markdown
MemberAuthor

@simirka can you create a minimal reproduction?

@alex-korniienko

Copy link
Copy Markdown

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xbugSomething isn't working🔨 p3-minor-bugPriority 3: a bug in an edge case that only affects very specific usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expected "meta" but found "meta$1" - rollup error with dynamic imports

3 participants

@danielroe@alex-korniienko@pi0