vue-ctk-date-time-picker icon indicating copy to clipboard operation
vue-ctk-date-time-picker copied to clipboard

Converted moment, moment range, and Vue to peer dependencies

Open spgoad opened this issue 6 years ago • 13 comments

This somewhat relates to issue #116 and package size as this was discussed as a possible approach for solving that problem as well.

We we're working on our first deployment using the vue-ctk-date-time-picker, and I noticed our chunk-vendors.js compiled by Webpack was pretty big. After digging into it, I discovered that this package was importing moment, vue, and moment range as npm dependencies, which means they are included in the final dist js files. This would be ok, except our app also has moment and vue as dependencies - which means we've now included them in our final package twice by including the dist version of vue-ctk-date-picker.

This PR converts VueJS, Moment, & Moment-Range to peer dependencies which allows us to only include each of them one in our application. This would be a somewhat significant change as anyone who upgrades would need to install the 3 dependencies themselves - so I welcome feedback on the approach and how that would need to be communicated in docs.

spgoad avatar May 03 '19 22:05 spgoad

hey guys!I want to ask you a question that sounds like a novice, but I've never used it. Change devDependencies to peerDependencies by modifying package. JSON directly or by command.But I couldn't find such an order in the official documents.I don't think it's a direct modification of package. json, I haven't found the command for a long time.I hope you can answer me. Thank you.

jkcs avatar May 04 '19 10:05 jkcs

@LW66666 I don't believe there is a way to do it with a command. The way I went about it is to do npm install package-name --save-dev to save it to dev dependencies, and then I manually add it to peer dependencies. This way I have the dependency installed locally for testing purposes, but then when the project is built for distribution, the dependency is not included in the final package.

spgoad avatar May 10 '19 20:05 spgoad

@spgoad Thank you.

jkcs avatar May 12 '19 01:05 jkcs

I think this is a great idea, as keeping the bundle size down would be very welcome. I'm not sure how you tackle existing installations, but think this is definitely worth considering.

ghost avatar Jul 01 '19 17:07 ghost

I'd like this PR to be merged, although it would need to be released as v3.0 as it's a breaking change.

m-mohr avatar Aug 21 '19 16:08 m-mohr

Thank you for taking the time making this PR. Indeed, removing those dependencies would be very nice for the bundle. Yet as said by @m-mohr it may break current versions. I'll do some researching in the following days to tackle this issue. Before doing so, I need to add a proper test suite to avoid silly regressions.

I'll keep you updated.

WilliamDASILVA avatar Aug 23 '19 08:08 WilliamDASILVA

Hey!

What is the reason to not merge this PR ?

It looks good to me

Thanks

guillaumebriday avatar Dec 09 '19 23:12 guillaumebriday

I'd love to see this PR merged. My bundle jumped from 159KiB to 547KiB by including this package (JS only, excludes the CSS). I wish I would have known about this when choosing which date picker to choose.

tylercollier avatar Nov 09 '20 17:11 tylercollier

Yeah, I think we are going to switch date pickers, too. The size can't be justified any longer...

m-mohr avatar Nov 12 '20 15:11 m-mohr

I switched to https://element.eleme.io/#/en-US/component/datetime-picker#datetimepicker

The api is better too imo

guillaumebriday avatar Nov 12 '20 15:11 guillaumebriday

Please have this merged... 800Kb gzipped for this bundle this is crazy.. Vue shouldn't be bundled, and moment as well because this prevents us from removing the locales which are unnecessary with the dedicated webpack plugin...

I have never seen such a big npm package, this should be addressed with top priority image

Here is the size of another package that does the same thing image

Tofandel avatar Jun 16 '21 15:06 Tofandel

I've migrated to https://github.com/mengxiong10/vue2-datepicker, which gives me a much better experience overall.

m-mohr avatar Jun 16 '21 16:06 m-mohr

I did the same, also very happy now

Tofandel avatar Jun 17 '21 09:06 Tofandel