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

fix(vite, webpack): generate composable keys based on order - #6191

Merged
pi0 merged 1 commit into
mainfrom
fix/key-source
Jul 29, 2022
Merged

fix(vite, webpack): generate composable keys based on order#6191
pi0 merged 1 commit into
mainfrom
fix/key-source

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

resolvesnuxt/nuxt#14442

❓ 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

Introduced in #4955, we were creating hashed based on code index. But this differs between server + client for vue components (among others) due to differences in the code generated in the two environments. However, I think the order of keyed composables is more solid and likely to remain fixed between client/server.

Other approaches I also tried:

  1. using sourcemaps to get original LOC - I think the best approach conceptually. This did not match however (1 line out), surprisingly, due to a bug (I think) in vite's vue plugin - I'll need to investigate further and report. Additionally, we don't yet have isomorphic support for sourcemaps in unplugin (expose sourcemap utilities via this context unjs/unplugin#146) so it would add some complexity for webpack.

  2. moving the key generation 'up' to earlier in the pipeline (via enforce: pre). Also much more reliable as an approach. This would work except that acorn can't handle TS. I could add an additional esbuild transform in before parsing with acorn, but it felt like this would be too heavy.

📝 Checklist

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

@danielroedanielroe self-assigned this Jul 27, 2022
@netlify

netlifyBot commented Jul 27, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs ready!

NameLink
🔨 Latest commitbfd542e
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/62e1b4d7d87d350008a7cb5a
😎 Deploy Previewhttps://deploy-preview-6191--nuxt3-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@danielroedanielroe added bug Something isn't working ❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf labels Jul 27, 2022
@danielroe
danielroe requested review from antfu and pi0July 27, 2022 21:58
@pi0pi0 changed the title fix(vite, webpack): hash keys based on order not exact indexfix(vite, webpack): generate composable keys based on orderJul 29, 2022
pi0
pi0 approved these changes Jul 29, 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 approach!

@pi0
pi0 merged commit 3f2eb3a into mainJul 29, 2022
@pi0
pi0 deleted the fix/key-source branch July 29, 2022 09:40
@pi0pi0 mentioned this pull request Aug 5, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xbugSomething isn't working❗ p4-importantPriority 4: bugs that violate documented behavior, or significantly impact perf

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prerender pages cause return value of useFetch() is wrong

2 participants

@danielroe@pi0