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

fix(vite): dedupe vue in client bundle - #6735

Merged
pi0 merged 3 commits into
mainfrom
fix/dedupe-vue
Aug 18, 2022
Merged

fix(vite): dedupe vue in client bundle#6735
pi0 merged 3 commits into
mainfrom
fix/dedupe-vue

Conversation

@danielroe

@danielroedanielroe commented Aug 18, 2022

Copy link
Copy Markdown
Member

🔗 Linked issue

resolvesnuxt/nuxt#14625, also see nuxt/nuxt#13632

❓ 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

This enables vite's dedupe functionality for vue, where we definitely want to ensure we have a single instance bundled. A previous issue with this plugin (where it emitted CJS code) seems to have been resolved in Vite 3.

Edit: enabling only for client.

It injects the following code in the server bundle:

https://github.com/vitejs/vite/blob/9e9cd23763c96020cdf1807334368e038f61ad01/packages/vite/src/node/plugins/ssrRequireHook.ts#L53-L71

We can alternatively enable this only for the client bundle. WDYT @pi0?

📝 Checklist

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

@danielroedanielroe added enhancement New feature or request vite labels Aug 18, 2022
@danielroe
danielroe requested a review from pi0August 18, 2022 07:49
@danielroedanielroe self-assigned this Aug 18, 2022
@netlify

netlifyBot commented Aug 18, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

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

pi0
pi0 approved these changes Aug 18, 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.

seems a good option to try

@pi0

pi0 commented Aug 18, 2022

Copy link
Copy Markdown
Member

Just checked SSR plugin. It seems modifying Node.js Module behavior. Probably safer to enable for client bundle only. Nitro should properly does it.

pi0
pi0 approved these changes Aug 18, 2022
@pi0pi0 changed the title feat(vite): dedupe vue by defaultfix(vite): dedupe vue in client bundleAug 18, 2022
@pi0
pi0 merged commit faf00f5 into mainAug 18, 2022
@pi0
pi0 deleted the fix/dedupe-vue branch August 18, 2022 08:06
@danielroe

Copy link
Copy Markdown
MemberAuthor

Putting this here for future reference: vitejs/vite#7454 (comment)

@pi0pi0 mentioned this pull request Aug 26, 2022
haoqunjiang added a commit to haoqunjiang/vite that referenced this pull request Nov 22, 2022
Fixesvitejs#2443Fixesvitejs#7454
It's already been set by default in Nuxt 3 for a while now nuxt/framework#6735
So I think this change should be harmless.
And technically it could be considered a fix than a feat.
Nevertheless, it's better to ship it in v4 to minimize disruptions on
the user side.
Things that are not covered in this PR:
1. SSR, because `resolve.dedupe` doesn't work for ESM build outputs, and
the CommonJS version is kinda hacky, I think it's better to skip the
config for SSR completely. Besides, most related issues are from the
client side.
2. #5958 isn't fixed by this PR.
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xenhancementNew feature or requestvite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slots break extend, if extend-folder is side by side with project-folder

2 participants

@danielroe@pi0