Open siddii opened 9 years ago
@polomarcus - Let me know what you think of this issue.
Good idea, I will try to work on this soon.
Hi @siddii,
TL;DR : we should keep momentjs dependency at anytime and we can make humanize duration dependency optional
Why?
If we do this, I can see 2 options :
moment()
is called. Example : https://github.com/siddii/angular-timer/blob/master/app/js/_timer.js#L256moment().diff()
inside the code when MomentJS is not available.
If a new feature using momentJS appears, we would need to write it in our custom momentJS.I think we should not do this, but that's just my opinion:
The variables secondUnit, minuteUnit etc. containing the translated duration will not be initialized when Humanize Duration is not available.
This line will contain an if(humDurationHere)
to initialize them or not
https://github.com/siddii/angular-timer/blob/master/app/js/_timer.js#L205
FYI, The i18nService.js with Humanize Duration can be momentJS free.
Pro :
bower install humanize-duration
manually if they need itDo not hesitate to discuss about this
@polomarcus - Thanks for the write-up!
I think the biggest thing I am trying to avoid here is not to have 3 installs (or script includes) (angular-timer, momentjs, humanize-duration) to start using this module. My understanding is that we can make HumanizeDuration optional(?) easily, whereas momentjs is not that straight forward.
OK, I'll throw out something & see what you think... How about we build a distribution script called angular-timer-all.js
which includes all the dependencies (obviously checking if moment exists provide one, so as humanize duration etc.) and its up-to the developers to choose whether they want to pull just the angular-timer
or not. In that way, we can have a simple integration rather than three different includes.
Let me know...
@siddii,
This solution would be great for people using manually downloads. We cannot have a choice between angular-timer-all.js
and the other file when we use bower install angular-timer
, don't we?
When doing a bower install, the users would still need to include the angular-timer, momentjs, humanize-duration scripts in their build.config.js for example. If we choose the "all" scripts in bower, the users won't be able to use their specific version of momentjs.
build.config.js example:
vendor_files: {
js: [
'vendor/angular/angular.min.js',
'vendor/moment/min/moment-with-locales.min.js',
'vendor/humanize-duration/humanize-duration.js',
'vendor/angular-timer/dist/angular-timer.min.js',
]
The only affected files would be Gruntfile.js
We need to remove hard dependency on external scripts like moment, humanize duration etc.. We should gracefully fallback or warn if those features are requested/used without including those scripts.