Skip to content

feat: expose vite's default manualChunks function#5585

Closed
ygj6 wants to merge 2 commits intovitejs:mainfrom
ygj6:merge-manualChunks
Closed

feat: expose vite's default manualChunks function#5585
ygj6 wants to merge 2 commits intovitejs:mainfrom
ygj6:merge-manualChunks

Conversation

@ygj6
Copy link
Copy Markdown
Member

@ygj6 ygj6 commented Nov 8, 2021

Description

fix: #5487

  • The easiest way is to expose createMoveToVendorChunkFn so that users can reuse it in custom manualChunks.
  • Merging is also a way, but after that, the user cannot completely override the vite default manualChunks, and the vendor.hash.js will always output. Maybe we can add an option to turn it on or off, thinking we need to discuss 🤔

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@patak-cat patak-cat added the p2-nice-to-have Not breaking anything but nice to have (priority) label Nov 8, 2021
import vuePlugin from '@vitejs/plugin-vue'
import { vueI18nPlugin } from './CustomBlockPlugin'
import { createMoveToVendorChunkFn } from 'vite'
const viteChunks = createMoveToVendorChunkFn()
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.

The cache is not going to be cleaned up correctly during build watch if it is defined in this way. I think we are having an issue in Vite here, no? This cache should be cleaned in buildStart. Maybe we should move it out of the function, and into the plugin control.
Maybe we could end up exposing a single function instead of factory afterwards?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Re-analyzed the building logic, the problem does exist, I will push a new commit for review : )

Copy link
Copy Markdown
Member Author

@ygj6 ygj6 Nov 10, 2021

Choose a reason for hiding this comment

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

Please focus on checking whether it needs to be cleared here?

b9f1826#diff-aa53520bfd53e6c24220c44494457cc66370fd2bee513c15f9be7eb537a363e7R564-R565

Will the parallelCallCounts introduced by 4a955bc actually be greater than 1? I tested several scenarios that I expected and found nothing. If it is greater than, maybe parallel build will affect the shared cache?

Open a new thread below for tracking.

@ygj6 ygj6 changed the title feat: expose createMoveToVendorChunkFn API to partially override it feat: expose vite's default manualChunks function Nov 10, 2021
@ygj6 ygj6 mentioned this pull request Nov 25, 2021
9 tasks
@Shinigami92 Shinigami92 self-requested a review December 17, 2021 13:55
Comment on lines +564 to +565
// clear cache for parallel builds
cacheVendorChunks.clear()
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Please focus on checking whether it needs to be cleared here?
Will the parallelCallCounts introduced by 4a955bc actually be greater than 1? I tested several scenarios that I expected and found nothing. If it is greater than, maybe parallel build will affect the shared cache?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p2-nice-to-have Not breaking anything but nice to have (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow partial override of rollup manualChunks

2 participants