-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Bundle size significantly larger than expected when built with default vue3 setup #1593
Comments
Additionally, adding Pinia to a vue3 project that is still using vue-cli/webpack appears to add about 20kb to chunk-vendors. Appreciate that may be an unsupported configuration, but seemed worth mentioning. |
A workaround for this is to ensure the module version is used. e.g. with vite it's export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
pinia: fileURLToPath(
new URL('./node_modules/pinia/dist/pinia.mjs', import.meta.url)
),
},
},
}) |
@posva thanks very much for the rapid response. I can confirm that workaround works with vite. The equivalent workaround for webpack appears to be: // vue.config.js
module.exports = {
// ... other config
configureWebpack: (config) => {
config.resolve.alias.pinia = path.resolve(__dirname, '/node_modules/pinia/dist/pinia.mjs');
}
} That is correctly swapping to the Digging through the compiled chunk-vendors, it looks like it's not properly stripping the devtools code as dead code e.g. this: const USE_DEVTOOLS = ((process.env.NODE_ENV !== 'production') || (typeof __VUE_PROD_DEVTOOLS__ !== 'undefined' && __VUE_PROD_DEVTOOLS__)) && !(process.env.NODE_ENV === 'test') && IS_CLIENT;
// ... other code
if (USE_DEVTOOLS) {
registerPiniaDevtools(app, pinia);
} is becoming this (not using the minified names for clarity): const USE_DEVTOOLS = !1;
// ...
if (USE_DEVTOOLS) {
registerPiniaDevtools(app, pinia);
}
// registerPiniaDevtools and all dependencies also included in output bundle. I suspect this may just be a limitation of webpack / terser that I'll have to live with until we can migrate to vite. |
Thanks for the example with webpack! About the minification with webpack, does it work with |
Bumping back to Based on that I've also checked with 2.0.21 and just replacing all the current As far as I know I'm using the latest versions of vue-cli/webpack/etc. |
Reproduction
https://github.com/acoulton/bug-pinia-build-size/runs/8035964674?check_suite_focus=true
Steps to reproduce the bug
Run the following script:
Observe the following sections of the output:
Expected behavior
Per the Pinia homepage:

It is not clear whether this refers to gzipped or total size.
Actual behavior
With the default vue/vite/pinia configuration, including pinia increases the production build by ~14Kb raw / ~5Kb gzipped.
This can be confirmed in the github actions output for the reproduction case (https://github.com/acoulton/bug-pinia-build-size/runs/8035964674?check_suite_focus=true):


Additional information
This appears to be the same issue as #1015 which was closed as invalid.
I have opened as a new issue as I have a different reproduction case which I think shows more clearly that there is definitely an issue with either pinia or the documentation (e.g. details of how vue/vite should be configured to achieve the documented 1Kb package weight).
The text was updated successfully, but these errors were encountered: