Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add an option for pre-built components #291

Closed
wants to merge 5 commits into from

Conversation

oubenruing
Copy link

To avoid infinite reloads caused by the introduction of dynamic components, add an option to make vite add the specified UI component library to optimizeDeps.include in the 'config' lifecycle for all prebuilds. #235 #255
(This PR is for antdv resolver and vant resolver)

Copy link
Author

@oubenruing oubenruing left a comment

Choose a reason for hiding this comment

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

Name has been changed.

@antfu
Copy link
Member

antfu commented Jan 24, 2022

I don't really like this approach and would think making deps optimization for components is out-of-scope of this project. I feel it's better to either be handled by another plugin, provide on the user side, or for libraries like antdv and vant to ship the ESM version directly.

@oubenruing
Copy link
Author

I don't really like this approach and would think making deps optimization for components is out-of-scope of this project. I feel it's better to either be handled by another plugin, provide on the user side, or for libraries like antdv and vant to ship the ESM version directly.

I actually added this option to fix that, after unplugin-vue-components imported components from the UI library (I use antdv ESM) on demand, vite always found a new style dependency (css or less in antdv) and repeatedly reloaded the page, causing it to load very slowly.

[vite] new dependencies found: ant-design-vue/es/divider/style, ant-design-vue/es/popover/style, updating...
[vite] ✨ dependencies updated, reloading page...
//......
[vite] new dependencies found: ant-design-vue/es/spin/style, updating...
[vite] ✨ dependencies updated, reloading page...

I actually have two solutions

  1. Setting importStyle to false in the options of resolver can avoid this. But this requires importing the full style file.
  2. I noticed this project vite-plugin-optimize-persist, which is awsome. But the first load still consumes a lot of time. That's why I created this PR, hoping to solve the Pre-Bundling of on-demand import on the first load to improve the experience during the development phase. (It seems pointless to make a separate plugin to set up pre-bundling without using unplugin-vue-components).

Anyway, thanks for your comments! If you still feel that this PR is not suitable, please close it.

Best regards.

@oubenruing oubenruing closed this Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants