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

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

Merged
merged 1 commit into from
Jul 29, 2022
Merged

Conversation

danielroe
Copy link
Member

πŸ”— Linked issue

resolves nuxt/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.

@danielroe danielroe self-assigned this Jul 27, 2022
@netlify
Copy link

netlify bot commented Jul 27, 2022

βœ… Deploy Preview for nuxt3-docs ready!

Name Link
πŸ”¨ Latest commit bfd542e
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/62e1b4d7d87d350008a7cb5a
😎 Deploy Preview https://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.

@danielroe danielroe 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 pi0 and antfu July 27, 2022 21:58
@pi0 pi0 changed the title fix(vite, webpack): hash keys based on order not exact index fix(vite, webpack): generate composable keys based on order Jul 29, 2022
Copy link
Member

@pi0 pi0 left a comment

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 main Jul 29, 2022
@pi0 pi0 deleted the fix/key-source branch July 29, 2022 09:40
@pi0 pi0 mentioned this pull request Aug 5, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
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 ❗ p4-important Priority 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